Loading [MathJax]/extensions/tex2jax.js
CS350 COS
COS
All Data Structures Files Functions Variables Typedefs Macros
mutex.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  CoreMutex
 

Typedefs

typedef struct CoreMutex CoreMutex
 

Functions

void CoreMutex_Init (CoreMutex *mtx)
 
void CoreMutex_Lock (CoreMutex *mtx)
 
bool CoreMutex_TryLock (CoreMutex *mtx)
 
void CoreMutex_Unlock (CoreMutex *mtx)
 

Data Structure Documentation

◆ CoreMutex

struct CoreMutex

Definition at line 5 of file mutex.h.

Collaboration diagram for CoreMutex:
[legend]
Data Fields
uint64_t lock

Typedef Documentation

◆ CoreMutex

typedef struct CoreMutex CoreMutex

Function Documentation

◆ CoreMutex_Init()

void CoreMutex_Init ( CoreMutex mtx)

Definition at line 9 of file mutex.c.

10{
11 mtx->lock = 0;
12}
uint64_t lock
Definition: mutex.h:6
Here is the caller graph for this function:

◆ CoreMutex_Lock()

void CoreMutex_Lock ( CoreMutex mtx)

Definition at line 16 of file mutex.c.

17{
18 while (__sync_lock_test_and_set(&mtx->lock, 1) == 1) {
20 }
21}
int OSThreadSleep(uint64_t time)
Definition: syscall.c:125
Here is the call graph for this function:
Here is the caller graph for this function:

◆ CoreMutex_TryLock()

bool CoreMutex_TryLock ( CoreMutex mtx)

Definition at line 24 of file mutex.c.

25{
26 if (__sync_lock_test_and_set(&mtx->lock, 1) == 1) {
27 return false;
28 } else {
29 return true;
30 }
31}

◆ CoreMutex_Unlock()

void CoreMutex_Unlock ( CoreMutex mtx)

Definition at line 34 of file mutex.c.

35{
36 __sync_lock_release(&mtx->lock);
37}
Here is the caller graph for this function: