cre_sem

acre_sem

Outline

Create semaphore.

C format

 ER      cre_sem (ID semid, T_CSEM *pk_csem );
 ER_ID   acre_sem ( T_CSEM *pk_csem );
Parameter(s)

I/O

Parameter

Description

I

 ID      semid;
ID number of the semaphore.

I

 T_CSEM  *pk_csem;
Pointer to the packet containing the semaphore creation information.



[Semaphore creation information packet : T_CSEM]

 typedef struct  t_csem {
     ATR     sematr;         /*Semaphore attribute*/
     UINT    isemcnt;        /*Initial semaphore count*/
     UINT    maxsem;         /*Maximum semaphore count*/
 } T_CSEM;


Explanation

This service call can be called from tasks that belong to Trusted Domain.

The cre_sem creates a semaphore with semaphore ID indicated by semid according to the content of pk_csem. The acre_sem creates a semaphore according to the content of pk_csem, and returns the created semaphore ID.

1 ) Semaphore attribute (sematr)
The following are specified for sematr.


   sematr := ( TA_TFIFO | TA_TPRI )
- TA_TFIFO ( = 0x0000)
Task wait queue is managed in FIFO order.


- TA_TPRI ( = 0x0001)
Task wait queue is managed in task current priority order. Among tasks with the same priority, they are queued in FIFO order.


2 ) Initial semaphore count (isemcnt)
Specify initial semaphore count within the range from 0 to maxsem.


3 ) Maximum semaphore count (maxsem)
Specify maximum semaphore count within the range from 1 to TMAX_MAXSEM ( = 65535).


Return value

Macro

Value

Description

-

Positive value

Normal completion of acre_sem. (Created semaphore ID)

E_OK

0

Normal completion of cre_sem.

E_RSATR

-11

Reserved attribute

- Either of bits in sematr except bit0 is 1.

E_PAR

-17

Parameter error.

- pk_csem == NULL

- maxsem == 0

- maxsem > TMAX_MAXSEM

- maxsem < isemcnt

E_ID

-18

Invalid ID number. (only for cre_sem)

- semid < 0

- semid > VTMAX_SEM

E_CTX

-25

Context error.

- This service call was issued in the CPU locked state.

- This service call was issued from non-task.

- This service call was issued in the status "PSW.IPL > kernel interrupt mask level".

E_MACV

-26

Memory access violation.

- Stack pointer points out of user stack for invoking task.

- The operand-read access to the area indicated by pk_csem has not been permitted to the invoking task.

E_OACV

-27

Object access violation.

- The invoking task does not belong to trusted domain.

E_NOID

-34

No ID number available.(only for acre_sem)

E_OBJ

-41

Object state error. (only for cre_sem)

- The semaphore specified by semid exists.