Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/mutex.c

    rc0699467 rfce7b43  
    4040#include <debug.h>
    4141#include <arch.h>
     42#include <stacktrace.h>
    4243
    4344/** Initialize mutex.
     
    6162        return semaphore_count_get(&mtx->sem) <= 0;
    6263}
     64
     65#define MUTEX_DEADLOCK_THRESHOLD        100000000
    6366
    6467/** Acquire mutex.
     
    8790                ASSERT(!(flags & SYNCH_FLAGS_INTERRUPTIBLE));
    8891               
     92                unsigned int cnt = 0;
     93                bool deadlock_reported = false;
    8994                do {
     95                        if (cnt++ > MUTEX_DEADLOCK_THRESHOLD) {
     96                                printf("cpu%u: looping on active mutex %p\n",
     97                                    CPU->id, mtx);
     98                                stack_trace();
     99                                cnt = 0;
     100                                deadlock_reported = true;
     101                        }
    90102                        rc = semaphore_trydown(&mtx->sem);
    91103                } while (SYNCH_FAILED(rc) &&
    92104                    !(flags & SYNCH_FLAGS_NON_BLOCKING));
     105                if (deadlock_reported)
     106                        printf("cpu%u: not deadlocked\n", CPU->id);
    93107        }
    94108
Note: See TracChangeset for help on using the changeset viewer.