Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

include/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:

Include dependency graph

Go to the source code of this file.

Classes

struct  critsec
 critical section data structure More...


Defines

#define __critsec_h__
#define locked_decrement(counter)   atomic_dec(counter)
 don't use locked_decrement anymore but atomic_dec()

#define initialize_critical_section(cs)   (cs)->count=0
 initialize critical section

#define leave_critical_section(cs)   atomic_dec(&(cs)->count)
 leave critical section

#define destroy_critical_section(cs)
 destroy critical section (does nothing)


Typedefs

typedef critsec critsec_t
 critical section type definition


Functions

wakeup_t wait_critical_section (wakeup_t data)
 wakeup when critical section is available

int enter_critical_section (critsec_t *cs)
 enter critical section


Detailed Description

Interface: critical section management.

Author:
Joseph A. Woolley <jawoolley@users.sourceforge.net>
Defines types and functions to implement critical sections.

Definition in file critsec.h.


Define Documentation

#define __critsec_h__
 

Definition at line 29 of file critsec.h.

#define destroy_critical_section cs   ) 
 

destroy critical section (does nothing)

currently there are no resources that are dynamically allocated.

Parameters:
cs pointer 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:
cs pointer 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:
cs pointer 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.

Referenced by CriticalSectionBlock::CriticalSectionBlock(), enter_critical_section(), and wait_critical_section().


Function Documentation

int enter_critical_section critsec_t cs  ) 
 

enter critical section

check and lock critical section if it is available; otherwise, wait until it is available, then lock it.

Parameters:
cs pointer to critical section (critsec_t)
Returns:
1 if successful, 0 upon failure
See also:
initialize_critical_section

leave_critical_section

destroy_critical_section

Definition at line 96 of file critsec.c.

References critsec::count, critsec_t, locked_check_and_increment(), critsec::task, wait_critical_section(), wait_event(), and wakeup_t.

Referenced by CriticalSectionBlock::CriticalSectionBlock().

wakeup_t wait_critical_section wakeup_t  data  ) 
 

wakeup when critical section is available

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

Definition at line 78 of file critsec.c.

References critsec::count, critsec_t, locked_check_and_increment(), critsec::task, and wakeup_t.


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

Generated on Mon Feb 16 21:02:17 2004 for brickOS Kernel Developer by doxygen 1.3.5