Changeset 2965d18 in mainline for uspace/lib/c/generic/fibril_synch.c


Ignore:
Timestamp:
2018-07-30T20:15:38Z (7 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d4b7b29
Parents:
8080262
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 19:53:13)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-30 20:15:38)
Message:

Add debug counter for rmutex locks.

File:
1 edited

Legend:

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

    r8080262 r2965d18  
    5050#include "private/async.h"
    5151#include "private/fibril.h"
     52
     53void fibril_rmutex_initialize(fibril_rmutex_t *m)
     54{
     55        futex_initialize(&m->futex, 1);
     56}
     57
     58/**
     59 * Lock restricted mutex.
     60 * When a restricted mutex is locked, the fibril may not sleep or create new
     61 * threads. Any attempt to do so will abort the program.
     62 */
     63void fibril_rmutex_lock(fibril_rmutex_t *m)
     64{
     65        futex_lock(&m->futex);
     66        fibril_self()->rmutex_locks++;
     67}
     68
     69bool fibril_rmutex_trylock(fibril_rmutex_t *m)
     70{
     71        if (futex_trylock(&m->futex)) {
     72                fibril_self()->rmutex_locks++;
     73                return true;
     74        } else {
     75                return false;
     76        }
     77}
     78
     79void fibril_rmutex_unlock(fibril_rmutex_t *m)
     80{
     81        fibril_self()->rmutex_locks--;
     82        futex_unlock(&m->futex);
     83}
    5284
    5385static fibril_local bool deadlocked = false;
Note: See TracChangeset for help on using the changeset viewer.