source: rtems/c/src/exec/score/inline/rtems/score/coresem.inl @ 21e2b2b

4.104.114.84.95
Last change on this file since 21e2b2b was 8d5b438b, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/00 at 19:27:03

Added _CORE_semaphore_Seize_isr_disable.

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*  inline/coresem.inl
2 *
3 *  This include file contains all of the inlined routines associated
4 *  with the CORE semaphore.
5 *
6 *  COPYRIGHT (c) 1989-1999.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16#ifndef __INLINE_CORE_SEMAPHORE_inl
17#define __INLINE_CORE_SEMAPHORE_inl
18
19#include <rtems/score/thread.h>
20#include <rtems/score/threadq.h>
21
22/*PAGE
23 *
24 *  _CORE_semaphore_Is_priority
25 *
26 *  DESCRIPTION:
27 *
28 *  This function returns TRUE if the priority attribute is
29 *  enabled in the attribute_set and FALSE otherwise.
30 */
31
32RTEMS_INLINE_ROUTINE boolean _CORE_semaphore_Is_priority(
33  CORE_semaphore_Attributes *the_attribute
34)
35{
36   return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY );
37}
38
39/*PAGE
40 *
41 *  _CORE_semaphore_Get_count
42 *
43 *  DESCRIPTION:
44 *
45 *  This routine returns the current count associated with the semaphore.
46 */
47 
48RTEMS_INLINE_ROUTINE unsigned32 _CORE_semaphore_Get_count(
49  CORE_semaphore_Control  *the_semaphore
50)
51{
52  return the_semaphore->count;
53}
54
55/*PAGE
56 *
57 *  _CORE_semaphore_Seize_isr_disable
58 *
59 *  DESCRIPTION:
60 *
61 *  This routine attempts to receive a unit from the_semaphore.
62 *  If a unit is available or if the wait flag is FALSE, then the routine
63 *  returns.  Otherwise, the calling task is blocked until a unit becomes
64 *  available.
65 *
66 *  NOTE: There is currently no MACRO version of this routine.
67 */
68 
69RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
70  CORE_semaphore_Control  *the_semaphore,
71  Objects_Id               id,
72  boolean                  wait,
73  Watchdog_Interval        timeout,
74  ISR_Level               *level_p
75)
76{
77  Thread_Control *executing;
78  ISR_Level       level = *level_p;
79
80  /* disabled when you get here */
81 
82  executing = _Thread_Executing;
83  executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
84  if ( the_semaphore->count != 0 ) {
85    the_semaphore->count -= 1;
86    _ISR_Enable( level );
87    return;
88  }
89
90  if ( !wait ) {
91    _ISR_Enable( level );
92    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
93    return;
94  }
95
96  _Thread_Disable_dispatch();
97  _ISR_Enable( level );
98  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
99  executing->Wait.queue          = &the_semaphore->Wait_queue;
100  executing->Wait.id             = id;
101  _ISR_Enable( level );
102
103  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
104  _Thread_Enable_dispatch();
105}
106#endif
107
108#endif
109/* end of include file */
Note: See TracBrowser for help on using the repository browser.