source: rtems/cpukit/score/inline/rtems/score/coresem.inl @ 86436f44

4.104.115
Last change on this file since 86436f44 was 86436f44, checked in by Joel Sherrill <joel.sherrill@…>, on 11/09/09 at 14:52:28

2009-11-09 Joel Sherrill <joel.sherrill@…>

  • score/inline/rtems/score/coremutex.inl, score/inline/rtems/score/coresem.inl: Eliminate use of local variable. This local variable causes unused variable warnings on some ports.
  • Property mode set to 100644
File size: 3.1 KB
Line 
1/**
2 *  @file  rtems/score/coresem.inl
3 *
4 *  This include file contains all of the inlined routines associated
5 *  with the SuperCore semaphore.
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2006.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#ifndef _RTEMS_SCORE_CORESEM_H
20# error "Never use <rtems/score/coresem.inl> directly; include <rtems/score/coresem.h> instead."
21#endif
22
23#ifndef _RTEMS_SCORE_CORESEM_INL
24#define _RTEMS_SCORE_CORESEM_INL
25
26/**
27 *  @addtogroup ScoreSemaphore
28 *  @{
29 */
30
31#include <rtems/score/thread.h>
32#include <rtems/score/threadq.h>
33
34/**
35 *  This function returns true if the priority attribute is
36 *  enabled in the @a attribute_set and false otherwise.
37 *
38 *  @param[in] the_attribute is the attribute set to test
39 *  @return true if the priority attribute is enabled
40 */
41RTEMS_INLINE_ROUTINE bool _CORE_semaphore_Is_priority(
42  CORE_semaphore_Attributes *the_attribute
43)
44{
45   return ( the_attribute->discipline == CORE_SEMAPHORE_DISCIPLINES_PRIORITY );
46}
47
48/**
49 *  This routine returns the current count associated with the semaphore.
50 *
51 *  @param[in] the_semaphore is the semaphore to obtain the count of
52 *  @return the current count of this semaphore
53 */
54RTEMS_INLINE_ROUTINE uint32_t  _CORE_semaphore_Get_count(
55  CORE_semaphore_Control  *the_semaphore
56)
57{
58  return the_semaphore->count;
59}
60
61/**
62 *  This routine attempts to receive a unit from the_semaphore.
63 *  If a unit is available or if the wait flag is false, then the routine
64 *  returns.  Otherwise, the calling task is blocked until a unit becomes
65 *  available.
66 *
67 *  @param[in] the_semaphore is the semaphore to obtain
68 *  @param[in] id is the Id of the owning API level Semaphore object
69 *  @param[in] wait is true if the thread is willing to wait
70 *  @param[in] timeout is the maximum number of ticks to block
71 *  @param[in] level_p is a temporary variable used to contain the ISR
72 *         disable level cookie
73 *
74 *  @note There is currently no MACRO version of this routine.
75 */
76RTEMS_INLINE_ROUTINE void _CORE_semaphore_Seize_isr_disable(
77  CORE_semaphore_Control  *the_semaphore,
78  Objects_Id               id,
79  bool                     wait,
80  Watchdog_Interval        timeout,
81  ISR_Level               *level_p
82)
83{
84  Thread_Control *executing;
85
86  /* disabled when you get here */
87 
88  executing = _Thread_Executing;
89  executing->Wait.return_code = CORE_SEMAPHORE_STATUS_SUCCESSFUL;
90  if ( the_semaphore->count != 0 ) {
91    the_semaphore->count -= 1;
92    _ISR_Enable( *level_p );
93    return;
94  }
95
96  if ( !wait ) {
97    _ISR_Enable( *level_p );
98    executing->Wait.return_code = CORE_SEMAPHORE_STATUS_UNSATISFIED_NOWAIT;
99    return;
100  }
101
102  _Thread_Disable_dispatch();
103  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
104  executing->Wait.queue          = &the_semaphore->Wait_queue;
105  executing->Wait.id             = id;
106  _ISR_Enable( *level_p );
107
108  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
109  _Thread_Enable_dispatch();
110}
111
112/**@}*/
113
114#endif
115/* end of include file */
Note: See TracBrowser for help on using the repository browser.