source: rtems/c/src/exec/itron/src/twai_sem.c @ fb27af76

4.104.114.84.95
Last change on this file since fb27af76 was fb27af76, checked in by Joel Sherrill <joel.sherrill@…>, on 11/15/99 at 16:39:01

Split ITRON semaphore manager into multiple files.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  The license and distribution terms for this file may be
3 *  found in the file LICENSE in this distribution or at
4 *  http://www.OARcorp.com/rtems/license.html.
5 *
6 *  $Id$
7 */
8
9#include <itron.h>
10
11#include <rtems/itron/semaphore.h>
12#include <rtems/itron/task.h>
13#include <rtems/score/tod.h>
14
15/*
16 *  twai_sem - Wait on Semaphore with Timeout
17 *
18 *  This function implements the ITRON 3.0 twai_sem() service.
19 */
20
21ER twai_sem(
22  ID semid,
23  TMO tmout
24)
25{
26  ITRON_Semaphore_Control *the_semaphore;
27  Objects_Locations        location;
28  Watchdog_Interval        interval;
29  boolean                  wait;
30  CORE_semaphore_Status    status;
31 
32  interval = 0;
33  if ( tmout == TMO_POL ) {
34    wait = FALSE;
35  } else {
36    wait = TRUE;
37    if ( tmout != TMO_FEVR )
38      interval = TOD_MILLISECONDS_TO_TICKS(tmout);
39  }
40
41  if ( wait && _ITRON_Is_in_non_task_state() )
42    return E_CTX;
43 
44  the_semaphore = _ITRON_Semaphore_Get( semid, &location );
45  switch ( location ) {
46    case OBJECTS_REMOTE:               /* Multiprocessing not supported */
47    case OBJECTS_ERROR:
48      return _ITRON_Semaphore_Clarify_get_id_error( semid );
49
50    case OBJECTS_LOCAL:
51      _CORE_semaphore_Seize(
52        &the_semaphore->semaphore,
53        the_semaphore->Object.id,
54        wait,                           /* wait for a timeout */
55        interval                        /* timeout value */
56      );
57      _Thread_Enable_dispatch();
58      status = (CORE_semaphore_Status) _Thread_Executing->Wait.return_code;
59      return _ITRON_Semaphore_Translate_core_semaphore_return_code( status );
60  }
61  return E_OK;
62}
Note: See TracBrowser for help on using the repository browser.