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

Subversion Repositories openrisc

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

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: twai_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
 *  twai_sem - Wait on Semaphore with Timeout
20
 *
21
 *  This function implements the ITRON 3.0 twai_sem() service.
22
 */
23
 
24
ER twai_sem(
25
  ID semid,
26
  TMO tmout
27
)
28
{
29
  ITRON_Semaphore_Control *the_semaphore;
30
  Objects_Locations        location;
31
  Watchdog_Interval        interval;
32
  boolean                  wait;
33
  CORE_semaphore_Status    status;
34
 
35
  interval = 0;
36
  if ( tmout == TMO_POL ) {
37
    wait = FALSE;
38
  } else {
39
    wait = TRUE;
40
    if ( tmout != TMO_FEVR )
41
      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
42
  }
43
 
44
  if ( wait && _ITRON_Is_in_non_task_state() )
45
    return E_CTX;
46
 
47
  the_semaphore = _ITRON_Semaphore_Get( semid, &location );
48
  switch ( location ) {
49
    case OBJECTS_REMOTE:               /* Multiprocessing not supported */
50
    case OBJECTS_ERROR:
51
      return _ITRON_Semaphore_Clarify_get_id_error( semid );
52
 
53
    case OBJECTS_LOCAL:
54
      _CORE_semaphore_Seize(
55
        &the_semaphore->semaphore,
56
        the_semaphore->Object.id,
57
        wait,                           /* wait for a timeout */
58
        interval                        /* timeout value */
59
      );
60
      _Thread_Enable_dispatch();
61
      status = (CORE_semaphore_Status) _Thread_Executing->Wait.return_code;
62
      return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );
63
  }
64
  return E_OK;
65
}

powered by: WebSVN 2.1.0

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