source: rtems/cpukit/itron/src/ref_sem.c @ fb27af76

4.104.114.84.95
Last change on this file since fb27af76 was fb27af76, checked in by Joel Sherrill <joel.sherrill@…>, on 11/15/99 at 16:39:01

Split ITRON semaphore manager into multiple files.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  The license and distribution terms for this file may be
3 *  found in the file LICENSE in this distribution or at
4 *  http://www.OARcorp.com/rtems/license.html.
5 *
6 *  $Id$
7 */
8
9#include <itron.h>
10
11#include <rtems/itron/semaphore.h>
12#include <rtems/itron/task.h>
13#include <rtems/score/tod.h>
14
15/*
16 *  ref_sem - Reference Semaphore Status
17 *
18 *  This function implements the ITRON 3.0 ref_sem() service.
19 */
20
21ER ref_sem(
22  ID      semid,
23  T_RSEM *pk_rsem
24)
25{
26  ITRON_Semaphore_Control *the_semaphore;
27  Objects_Locations        location;
28 
29  if ( !pk_rsem )
30    return E_PAR;   /* XXX check this error code */
31
32  the_semaphore = _ITRON_Semaphore_Get( semid, &location );
33  switch ( location ) {   
34    case OBJECTS_REMOTE:               /* Multiprocessing not supported */
35    case OBJECTS_ERROR:
36      return _ITRON_Semaphore_Clarify_get_id_error( semid );
37 
38    case OBJECTS_LOCAL:
39      /*
40       *  Fill in the current semaphore count
41       */
42
43      pk_rsem->semcnt = _CORE_semaphore_Get_count( &the_semaphore->semaphore );
44
45      /*
46       *  Fill in whether or not there is a waiting task
47       */
48
49      if ( !_Thread_queue_First( &the_semaphore->semaphore.Wait_queue ) )
50        pk_rsem->wtsk = FALSE;
51      else
52        pk_rsem->wtsk = TRUE;
53
54      _Thread_Enable_dispatch();
55      return E_OK;
56  }   
57  return E_OK;
58}
59
Note: See TracBrowser for help on using the repository browser.