Changeset e0e2264 in mainline


Ignore:
Timestamp:
2025-01-12T15:38:16Z (15 hours ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Parents:
82ff0a1
Message:

Fix printing the incorrect blocking chain when deadlock is detected.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/fibril_synch.c

    r82ff0a1 re0e2264  
    11/*
     2 * Copyright (c) 2025 Jiri Svoboda
    23 * Copyright (c) 2009 Jakub Jermar
    34 * All rights reserved.
     
    112113#define AWAITER_INIT { .fid = fibril_get_id() }
    113114
    114 static void print_deadlock(fibril_owner_info_t *oi)
     115/** Print deadlock message nad blocking chain.
     116 *
     117 * @param oi Owner info for the resource being acquired
     118 * @param f Fibril that is trying to acquire the resource
     119 */
     120static void print_deadlock(fibril_owner_info_t *oi, fibril_t *f)
    115121{
    116122        // FIXME: Print to stderr.
    117 
    118         fibril_t *f = (fibril_t *) fibril_get_id();
    119123
    120124        if (deadlocked) {
     
    143147}
    144148
    145 static void check_fibril_for_deadlock(fibril_owner_info_t *oi, fibril_t *fib)
    146 {
     149/** Check whether fibril trying to acquire a resource will cause deadlock.
     150 *
     151 * @param wanted_oi Owner info for the primitive that the fibril wants
     152 * @param fib Fibril that wants to aquire the primitive
     153 */
     154static void check_fibril_for_deadlock(fibril_owner_info_t *wanted_oi,
     155    fibril_t *fib)
     156{
     157        fibril_owner_info_t *oi;
     158
    147159        futex_assert_is_locked(&fibril_synch_futex);
    148160
     161        oi = wanted_oi;
    149162        while (oi && oi->owned_by) {
    150163                if (oi->owned_by == fib) {
    151164                        futex_unlock(&fibril_synch_futex);
    152                         print_deadlock(oi);
     165                        print_deadlock(wanted_oi, fib);
    153166                        abort();
    154167                }
     
    157170}
    158171
     172/** Check whether trying to acquire a resource will cause deadlock.
     173 *
     174 * @param oi Owner info for the primitive that the current fibril wants
     175 */
    159176static void check_for_deadlock(fibril_owner_info_t *oi)
    160177{
Note: See TracChangeset for help on using the changeset viewer.