OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [score/] [inline/] [rtems/] [score/] [coresem.inl] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*  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
 *  coresem.inl,v 1.11 2001/05/25 16:59:28 joel Exp
14
 */
15
 
16
#ifndef __INLINE_CORE_SEMAPHORE_inl
17
#define __INLINE_CORE_SEMAPHORE_inl
18
 
19
#include 
20
#include 
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
 
32
RTEMS_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
 
48
RTEMS_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
 
69
RTEMS_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
  _Thread_queue_Enter_critical_section( &the_semaphore->Wait_queue );
98
  executing->Wait.queue          = &the_semaphore->Wait_queue;
99
  executing->Wait.id             = id;
100
  _ISR_Enable( level );
101
 
102
  _Thread_queue_Enqueue( &the_semaphore->Wait_queue, timeout );
103
  _Thread_Enable_dispatch();
104
}
105
 
106
#endif
107
/* end of include file */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.