critsec.h File Reference

Interface: critical section management. More...

#include <config.h>
#include <sys/tm.h>
#include <atomic.h>
Include dependency graph for critsec.h:

Go to the source code of this file.

Macros

#define locked_decrement(counter)   atomic_dec(counter)
 don't use locked_decrement anymore but atomic_dec() More...
 
#define initialize_critical_section(cs)   (cs)->count=0
 initialize critical section More...
 
#define leave_critical_section(cs)   atomic_dec(&(cs)->count)
 leave critical section More...
 
#define destroy_critical_section(cs)
 destroy critical section (does nothing) More...
 

Typedefs

typedef struct critsec critsec_t
 critical section type definition More...
 

Functions

wakeup_t wait_critical_section (wakeup_t data)
 wakeup when critical section is available More...
 
int enter_critical_section (critsec_t *cs)
 enter critical section More...
 

Detailed Description

Interface: critical section management.

Author
Joseph A. Woolley jawoo.nosp@m.lley.nosp@m.@user.nosp@m.s.so.nosp@m.urcef.nosp@m.orge.nosp@m..net

Defines types and functions to implement critical sections.

Definition in file critsec.h.

Macro Definition Documentation

#define destroy_critical_section (   cs)

destroy critical section (does nothing)

currently there are no resources that are dynamically allocated.

Parameters
cspointer to critical section (critsec_t)
See also
initialize_critical_section
enter_critical_section
leave_critical_section

Definition at line 111 of file critsec.h.

#define initialize_critical_section (   cs)    (cs)->count=0

initialize critical section

sets count field of critical section to zero

Parameters
cspointer to critical section (critsec_t)
Returns
always 0
See also
enter_critical_section
leave_critical_section
destroy_critical_section

Definition at line 79 of file critsec.h.

#define leave_critical_section (   cs)    atomic_dec(&(cs)->count)

leave critical section

allow other tasks to enter critical regions of code protected by this critical section.

Parameters
cspointer to critical section (critsec_t)
Returns
results of locked_decrement (always 0)
See also
initialize_critical_section
enter_critical_section
destroy_critical_section

Definition at line 101 of file critsec.h.

Referenced by CriticalSectionBlock::~CriticalSectionBlock().

#define locked_decrement (   counter)    atomic_dec(counter)

don't use locked_decrement anymore but atomic_dec()

Deprecated:
use atomic_dec() instead

Definition at line 60 of file critsec.h.

Typedef Documentation

typedef struct critsec critsec_t

critical section type definition

Definition at line 55 of file critsec.h.

Function Documentation

int enter_critical_section ( critsec_t cs)

enter critical section

block other tasks if they attempt to enter a region of code protected by the same critical section.

Parameters
cspointer to critical section (critsec_t)
Returns
1 if successful, 0 if failure
See also
initialize_critical_section
leave_critical_section
destroy_critical_section

Referenced by CriticalSectionBlock::CriticalSectionBlock().

wakeup_t wait_critical_section ( wakeup_t  data)

wakeup when critical section is available

wakeup function used to sleep a task until a critical section is available. called while processing an interrupt, so interrupts are already disabled.

Returns
0 to continue waiting, non-zero to wakeup task.
See also
enter_critical_section

brickOS is released under the Mozilla Public License.
Original code copyright 1998-2005 by the authors.

Generated on Sat Feb 14 2015 23:12:04 for brickOS C++ by doxygen 1.8.9.1