Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/mutex.h

    re88eb48 r9f2f5ee  
    4444        MUTEX_PASSIVE,
    4545        MUTEX_RECURSIVE,
    46         MUTEX_ACTIVE
    4746} mutex_type_t;
    4847
     
    5150typedef struct {
    5251        mutex_type_t type;
     52        int nesting;
    5353        semaphore_t sem;
    54         struct thread *owner;
    55         unsigned nesting;
     54        _Atomic(struct thread *) owner;
    5655} mutex_t;
    5756
    58 #define mutex_lock(mtx) \
    59         _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     57#define MUTEX_INITIALIZER(name, mtype) (mutex_t) { \
     58        .type = (mtype), \
     59        .nesting = 0, \
     60        .sem = SEMAPHORE_INITIALIZER((name).sem, 1), \
     61        .owner = NULL, \
     62}
    6063
    61 #define mutex_trylock(mtx) \
    62         _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
    63 
    64 #define mutex_lock_timeout(mtx, usec) \
    65         _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
     64#define MUTEX_INITIALIZE(name, mtype) \
     65        mutex_t name = MUTEX_INITIALIZER(name, mtype)
    6666
    6767extern void mutex_initialize(mutex_t *, mutex_type_t);
    6868extern bool mutex_locked(mutex_t *);
    69 extern errno_t _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int);
     69extern errno_t mutex_trylock(mutex_t *);
     70extern void mutex_lock(mutex_t *);
     71extern errno_t mutex_lock_timeout(mutex_t *, uint32_t);
    7072extern void mutex_unlock(mutex_t *);
    7173
Note: See TracChangeset for help on using the changeset viewer.