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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [itron/] [src/] [ref_sem.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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
 *  ref_sem.c,v 1.3 2001/01/24 14:15:04 joel Exp
10
 */
11
 
12
#if HAVE_CONFIG_H
13
#include "config.h"
14
#endif
15
 
16
#include <itron.h>
17
 
18
#include <rtems/itron/semaphore.h>
19
#include <rtems/itron/task.h>
20
#include <rtems/score/tod.h>
21
 
22
/*
23
 *  ref_sem - Reference Semaphore Status
24
 *
25
 *  This function implements the ITRON 3.0 ref_sem() service.
26
 */
27
 
28
ER ref_sem(
29
  ID      semid,
30
  T_RSEM *pk_rsem
31
)
32
{
33
  ITRON_Semaphore_Control *the_semaphore;
34
  Objects_Locations        location;
35
 
36
  if ( !pk_rsem )
37
    return E_PAR;   /* XXX check this error code */
38
 
39
  the_semaphore = _ITRON_Semaphore_Get( semid, &location );
40
  switch ( location ) {
41
    case OBJECTS_REMOTE:               /* Multiprocessing not supported */
42
    case OBJECTS_ERROR:
43
      return _ITRON_Semaphore_Clarify_get_id_error( semid );
44
 
45
    case OBJECTS_LOCAL:
46
      /*
47
       *  Fill in the current semaphore count
48
       */
49
 
50
      pk_rsem->semcnt = _CORE_semaphore_Get_count( &the_semaphore->semaphore );
51
 
52
      /*
53
       *  Fill in whether or not there is a waiting task
54
       */
55
 
56
      if ( !_Thread_queue_First( &the_semaphore->semaphore.Wait_queue ) )
57
        pk_rsem->wtsk = FALSE;
58
      else
59
        pk_rsem->wtsk = TRUE;
60
 
61
      _Thread_Enable_dispatch();
62
      return E_OK;
63
  }
64
  return E_OK;
65
}
66
 

powered by: WebSVN 2.1.0

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