source: rtems/cpukit/itron/src/ref_sem.c @ 7fcc26ac

4.104.114.84.95
Last change on this file since 7fcc26ac was 9d9a3dd, checked in by Jennifer Averett <Jennifer.Averett@…>, on 11/17/99 at 16:47:58

+ Updated copyright information.

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