Changeset 8013637 in mainline for kernel/generic/src/synch/mutex.c


Ignore:
Timestamp:
2012-07-20T13:51:28Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
8fccd42
Parents:
c5bff3c (diff), 7030bc9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

More mainline changes.

File:
1 edited

Legend:

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

    rc5bff3c r8013637  
    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.