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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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