source: rtems/c/src/exec/itron/src/cre_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: 2.1 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 *  cre_sem - Create Semaphore
17 *
18 *  This function implements the ITRON 3.0 cre_sem() service.
19 */
20
21ER cre_sem(
22  ID      semid,
23  T_CSEM *pk_csem
24)
25{
26  CORE_semaphore_Attributes   the_semaphore_attributes;
27  ITRON_Semaphore_Control    *the_semaphore;
28
29  /*
30   *  Bad pointer to the attributes structure
31   */
32
33  if ( !pk_csem )
34    return E_PAR;
35
36  /*
37   *  Bits were set that were note defined.
38   */
39
40  if ( pk_csem->sematr & _ITRON_SEMAPHORE_UNUSED_ATTRIBUTES )
41    return E_RSATR;
42
43  /*
44   *  Initial semaphore count exceeds the maximum.
45   */
46
47  if ( pk_csem->isemcnt > pk_csem->maxsem )
48    return E_PAR;
49
50  /*
51   *  This error is not in the specification but this condition
52   *  does not make sense.
53   */
54
55  if ( pk_csem->maxsem == 0 )
56    return E_PAR;
57
58  _Thread_Disable_dispatch();             /* prevents deletion */
59
60  the_semaphore = _ITRON_Semaphore_Allocate( semid );
61  if ( !the_semaphore ) {
62    _Thread_Enable_dispatch();
63    return _ITRON_Semaphore_Clarify_allocation_id_error( semid );
64  }
65
66  if ( pk_csem->sematr & TA_TPRI )
67    the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_PRIORITY;
68  else
69    the_semaphore_attributes.discipline = CORE_SEMAPHORE_DISCIPLINES_FIFO;
70
71  the_semaphore_attributes.maximum_count = pk_csem->maxsem;
72
73  _CORE_semaphore_Initialize(
74    &the_semaphore->semaphore,
75    OBJECTS_ITRON_SEMAPHORES,
76    &the_semaphore_attributes,
77    pk_csem->isemcnt,
78    NULL                           /* Multiprocessing not supported */
79  );
80
81  _ITRON_Objects_Open( &_ITRON_Semaphore_Information, &the_semaphore->Object );
82
83  /*
84   *  If multiprocessing were supported, this is where we would announce
85   *  the existence of the semaphore to the rest of the system.
86   */
87
88#if defined(RTEMS_MULTIPROCESSING)
89#endif
90
91  _Thread_Enable_dispatch();
92  return E_OK;
93}
Note: See TracBrowser for help on using the repository browser.