brickOS C v0.9.0
critsec.h
Go to the documentation of this file.
1
8/*
9 * The contents of this file are subject to the Mozilla Public License
10 * Version 1.0 (the "License"); you may not use this file except in
11 * compliance with the License. You may obtain a copy of the License
12 * at http://www.mozilla.org/MPL/
13 *
14 * Software distributed under the License is distributed on an "AS IS"
15 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 * the License for the specific language governing rights and
17 * limitations under the License.
18 *
19 * The Original Code is legOS code, released October 17, 1999.
20 *
21 * The Initial Developer of the Original Code is Markus L. Noga.
22 * Portions created by Markus L. Noga are Copyright (C) 1999
23 * Markus L. Noga. All Rights Reserved.
24 *
25 * Contributor(s): Joseph A. Woolley <jawoolley@users.sourceforge.net>
26 */
27
28#if !defined(__critsec_h__)
29#define __critsec_h__
30
31#if defined(__cplusplus)
32extern "C" {
33#endif // __cplusplus
34
35#include <config.h>
36
37#if defined(CONF_TM) && defined(CONF_CRITICAL_SECTIONS)
38#include <sys/tm.h>
39#include <atomic.h>
40
41#ifndef DOXYGEN_SHOULD_SKIP_INTERNALS
43
48struct critsec {
49 atomic_t count;
50 tdata_t* task;
51};
52#endif // DOXYGEN_SHOULD_SKIP_INTERNALS
53
55typedef struct critsec critsec_t;
56
58
60#define locked_decrement(counter) atomic_dec(counter)
61
63
70
72
79#define initialize_critical_section(cs) (cs)->count=0
80
82
91
93
101#define leave_critical_section(cs) atomic_dec(&(cs)->count)
102
104
111#define destroy_critical_section(cs)
112
113#endif // CONF_TM && CONF_CRITICAL_SECTIONS
114
115#if defined(__cplusplus)
116}
117#endif // __cplusplus
118
119#endif // __critsec_h__
Interface: critical section management.
volatile unsigned char atomic_t
The data type that allows for atomic count operations.
Definition atomic.h:43
int enter_critical_section(critsec_t *cs)
enter critical section
struct critsec critsec_t
critical section type definition
Definition critsec.h:55
wakeup_t wait_critical_section(wakeup_t data)
wakeup when critical section is available
unsigned long wakeup_t
wakeup data area type
Definition tm.h:57