source: rtems/c/src/exec/itron/src/twai_sem.c @ 5e77d129

4.104.114.84.95
Last change on this file since 5e77d129 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.6 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 *  twai_sem - Wait on Semaphore with Timeout
20 *
21 *  This function implements the ITRON 3.0 twai_sem() service.
22 */
23
24ER 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}
Note: See TracBrowser for help on using the repository browser.