Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
mutex.h File Reference

Go to the source code of this file.

Data Structures

struct  Mutex
 

Macros

#define MTX_STATUS_UNLOCKED   0
 
#define MTX_STATUS_LOCKED   1
 

Typedefs

typedef struct Mutex Mutex
 

Functions

void Mutex_Init (Mutex *mtx, const char *name)
 
void Mutex_Destroy (Mutex *mtx)
 
void Mutex_Lock (Mutex *mtx)
 
int Mutex_TryLock (Mutex *mtx)
 
void Mutex_Unlock (Mutex *mtx)
 

Macro Definition Documentation

◆ MTX_STATUS_LOCKED

#define MTX_STATUS_LOCKED   1

Definition at line 6 of file mutex.h.

◆ MTX_STATUS_UNLOCKED

#define MTX_STATUS_UNLOCKED   0

Definition at line 5 of file mutex.h.

Typedef Documentation

◆ Mutex

typedef struct Mutex Mutex

Function Documentation

◆ Mutex_Destroy()

void Mutex_Destroy ( Mutex mtx)

Definition at line 39 of file mutex.c.

40{
43 return;
44}
void Spinlock_Destroy(Spinlock *lock)
Definition: spinlock.c:61
WaitChannel chan
Definition: mutex.h:12
Spinlock lock
Definition: mutex.h:11
void WaitChannel_Destroy(WaitChannel *wc)
Definition: waitchannel.c:40
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mutex_Init()

void Mutex_Init ( Mutex mtx,
const char *  name 
)

Definition at line 30 of file mutex.c.

31{
33 WaitChannel_Init(&mtx->chan, name);
34
35 return;
36}
#define SPINLOCK_TYPE_NORMAL
Definition: spinlock.h:12
void Spinlock_Init(Spinlock *lock, const char *name, uint64_t type)
Definition: spinlock.c:43
void WaitChannel_Init(WaitChannel *wc, const char *name)
Definition: waitchannel.c:28
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mutex_Lock()

void Mutex_Lock ( Mutex mtx)

Mutex_Lock –

Acquires the mutex.

Definition at line 52 of file mutex.c.

53{
54 /*
55 * You cannot hold a spinlock while trying to acquire a Mutex that may
56 * sleep!
57 */
58 ASSERT(Critical_Level() == 0);
59
60 /* XXXFILLMEIN */
61}
uint32_t Critical_Level()
Definition: critical.c:45
#define ASSERT(_x)
Definition: kassert.h:8
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Mutex_TryLock()

int Mutex_TryLock ( Mutex mtx)

Mutex_TryLock –

Attempts to acquire the user mutex. Returns EBUSY if the lock is already taken, otherwise 0 on success.

Definition at line 70 of file mutex.c.

71{
72 /* XXXFILLMEIN */
73
74 return 0;
75}

◆ Mutex_Unlock()

void Mutex_Unlock ( Mutex mtx)

Mutex_Unlock –

Releases the user mutex.

Definition at line 83 of file mutex.c.

84{
85 /* XXXFILLMEIN */
86
87 return;
88}
Here is the caller graph for this function: