OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [exec/] [itron/] [src/] [ref_sem.c] - Blame information for rev 410

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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: ref_sem.c,v 1.2 2001-09-27 11:59:13 chris Exp $
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
 
24
ER 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
 

powered by: WebSVN 2.1.0

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