MentOS  0.8.0
The Mentoring Operating System
Macros | Typedefs | Functions
spinlock.h File Reference

Go to the source code of this file.

Macros

#define SPINLOCK_FREE   0
 Determines if the spinlock is free.
 
#define SPINLOCK_BUSY   1
 Determines if the spinlock is busy.
 

Typedefs

typedef atomic_t spinlock_t
 Spinlock structure.
 

Functions

void spinlock_init (spinlock_t *spinlock)
 Initialize the spinlock. More...
 
void spinlock_lock (spinlock_t *spinlock)
 Try to lock the spinlock. More...
 
void spinlock_unlock (spinlock_t *spinlock)
 Try to unlock the spinlock. More...
 
int spinlock_trylock (spinlock_t *spinlock)
 Try to unlock the spinlock. More...
 

Detailed Description

Function Documentation

◆ spinlock_init()

void spinlock_init ( spinlock_t spinlock)

Initialize the spinlock.

Parameters
spinlockThe spinlock we initialize.

◆ spinlock_lock()

void spinlock_lock ( spinlock_t spinlock)

Try to lock the spinlock.

Parameters
spinlockThe spinlock we lock.

◆ spinlock_trylock()

int spinlock_trylock ( spinlock_t spinlock)

Try to unlock the spinlock.

Parameters
spinlockThe spinlock we try to block.
Returns
1 if succeeded, 0 otherwise.

◆ spinlock_unlock()

void spinlock_unlock ( spinlock_t spinlock)

Try to unlock the spinlock.

Parameters
spinlockThe spinlock we unlock.