Subversion Repositories HelenOS

Rev

Rev 2787 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2787 Rev 3425
Line 37... Line 37...
37
 
37
 
38
#include <arch/types.h>
38
#include <arch/types.h>
39
#include <synch/semaphore.h>
39
#include <synch/semaphore.h>
40
#include <synch/synch.h>
40
#include <synch/synch.h>
41
 
41
 
-
 
42
typedef enum {
-
 
43
    MUTEX_PASSIVE,
-
 
44
    MUTEX_ACTIVE
-
 
45
} mutex_type_t;
-
 
46
 
42
typedef struct {
47
typedef struct {
-
 
48
    mutex_type_t type;
43
    semaphore_t sem;
49
    semaphore_t sem;
44
} mutex_t;
50
} mutex_t;
45
 
51
 
46
#define mutex_lock(mtx) \
52
#define mutex_lock(mtx)         \
47
    _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
53
    _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
48
#define mutex_trylock(mtx) \
54
#define mutex_trylock(mtx)      \
49
    _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
55
    _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
50
#define mutex_lock_timeout(mtx, usec) \
56
#define mutex_lock_timeout(mtx, usec)   \
51
    _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
57
    _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
52
 
58
 
53
extern void mutex_initialize(mutex_t *mtx);
59
extern void mutex_initialize(mutex_t *, mutex_type_t);
54
extern int _mutex_lock_timeout(mutex_t *mtx, uint32_t usec, int flags);
60
extern int _mutex_lock_timeout(mutex_t *, uint32_t, int);
55
extern void mutex_unlock(mutex_t *mtx);
61
extern void mutex_unlock(mutex_t *);
56
 
62
 
57
#endif
63
#endif
58
 
64
 
59
/** @}
65
/** @}
60
 */
66
 */