Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
mutex.c File Reference
#include <stdbool.h>
#include <stdint.h>
#include <string.h>
#include <sys/cdefs.h>
#include <sys/kassert.h>
#include <sys/kconfig.h>
#include <sys/kdebug.h>
#include <sys/kmem.h>
#include <sys/mp.h>
#include <sys/queue.h>
#include <sys/thread.h>
#include <sys/spinlock.h>
#include <sys/waitchannel.h>
#include <sys/mutex.h>
#include <errno.h>
Include dependency graph for mutex.c:

Go to the source code of this file.

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)
 

Variables

ThreadcurProc [MAX_CPUS]
 

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:

Variable Documentation

◆ curProc

Thread* curProc[MAX_CPUS]
extern

Current thread executing on a given CPU.

Definition at line 41 of file sched.c.