Everything

ref_sem

iref_sem

Outline
Reference semaphore state.
C format
 ER      ref_sem (ID semid, T_RSEM *pk_rsem);
 ER      iref_sem (ID semid, T_RSEM *pk_rsem);
Parameter(s)
I/O
Parameter
Description
I
 ID      semid;
ID number of the semaphore.
O
 T_RSEM  *pk_rsem;
Pointer to the packet returning the semaphore state.

[Semaphore state packet: T_RSEM]
 typedef struct  t_rsem {
     ID      wtskid;         /*Existence of waiting task*/
     UINT    semcnt;         /*Current resource count*/
 } T_RSEM;

Explanation
Stores semaphore state packet (ID number of the task at the head of the wait queue, current resource count, etc.) of the semaphore specified by parameter semid in the area specified by parameter pk_rsem.
- wtskid
Stores whether a task is queued to the semaphore wait queue.
TSK_NONE: No applicable task
Value: ID number of the task at the head of the wait queue
- semcnt
Stores the current resource count.
Return value
Macro
Value
Description
E_OK
0
Normal completion.
E_ID
-18
Invalid ID number.
- 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 in the status "PSW.IPL > kernel interrupt mask level".
Note When the iref_sem is issued from task or the ref_sem is issued from non-task, the context error is not detected and normal operation of the system is not guaranteed.