brickOS Kernel Developer v0.9.0
CriticalSectionBlock.H
Go to the documentation of this file.
1// The contents of this file are subject to the Mozilla Public License
2// Version 1.0 (the "License"); you may not use this file except in
3// compliance with the License. You may obtain a copy of the License
4// at http://www.mozilla.org/MPL/
5//
6// Software distributed under the License is distributed on an "AS IS"
7// basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
8// the License for the specific language governing rights and
9// limitations under the License.
10//
11// Contributor Henner Zeller <H.Zeller@acm.org>
12
13#ifndef __CRITICALSECTIONBLOCK_H
14#define __CRITICALSECTIONBLOCK_H
15
16#include <critsec.h>
17
102
131#define synchronized(cs) for(CriticalSectionBlock __currentlocked(cs);__currentlocked.checkonce();/* */)
132
133/*
134 * Local variables:
135 * c-basic-offset: 8
136 * End:
137 */
138
139#endif /* __CRITICALSECTIONBLOCK_H */
A CriticalSectionBlock locks a critical section for the lifetime of the CriticalSectionBlock.
CriticalSectionBlock(critsec_t *critsec)
Constructor locks the critical section.
~CriticalSectionBlock()
destructor automatically unlocks the critical section.
char _checkonceHackCounter
little hack, to make it possible to implement the synchronized() macro with the for(;;) loop below.
int enter_critical_section(critsec_t *cs)
lock a critical section, or wait until it is available.
Definition critsec.c:96
#define leave_critical_section(cs)
leave critical section
Definition critsec.h:101
critical section data structure
Definition critsec.h:48