blob: 6a2223760515ad7c94f5cd92ebf79326e465d1d7 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
/* macros/coresem.h
*
* This include file contains all of the inlined routines associated
* with core semaphores.
*
* COPYRIGHT (c) 1989-1999.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.OARcorp.com/rtems/license.html.
*
* $Id$
*/
#ifndef __MACROS_CORE_SEMAPHORE_h
#define __MACROS_CORE_SEMAPHORE_h
/*PAGE
*
* _CORE_semaphore_Is_priority
*
*/
#define _CORE_semaphore_Is_priority( _the_attribute ) \
( (_the_attribute)->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY )
/*PAGE
*
* _CORE_semaphore_Get_count
*
*/
#define _CORE_semaphore_Get_count( _the_semaphore ) \
( (_the_semaphore)->count )
/*PAGE
*
* _CORE_semaphore_Seize_isr_disable
*/
#define _CORE_semaphore_Seize_isr_disable( \
_the_semaphore, _id, _wait, _timeout, _level_p) \
{ \
Thread_Control *executing; \
ISR_Level level = *(_level_p); \
\
/* disabled when you get here */ \
\
executing = _Thread_Executing; \
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL; \
if ( (_the_semaphore)->count != 0 ) { \
(_the_semaphore)->count -= 1; \
_ISR_Enable( level ); \
} else if ( !(_wait) ) { \
_ISR_Enable( level ); \
executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT; \
} else { \
_Thread_Disable_dispatch(); \
_ISR_Enable( level ); \
_Thread_queue_Enter_critical_section( &(_the_semaphore)->Wait_queue ); \
executing->Wait.queue = &(_the_semaphore)->Wait_queue; \
executing->Wait.id = (_id); \
_ISR_Enable( level ); \
\
_Thread_queue_Enqueue( &(_the_semaphore)->Wait_queue, (_timeout) ); \
_Thread_Enable_dispatch(); \
} \
}
#endif
/* end of include file */
|