tloc_mtx

Outline

Lock mutex (with time-out).

C format

 ER      tloc_mtx (ID mtxid, TMO tmout);
Parameter(s)

I/O

Parameter

Description

I

 ID      mtxid;
ID number of the mutex.

I

 TMO     tmout;
Specified time-out (in millisecond).

TMO_FEVR: Waiting forever.

TMO_POL: Polling.

Value: Specified time-out.



Explanation

This service call locks the mutex specified by parameter mtxid.

If the target mutex could not be locked (another task has been locked) when this service call is issued, this service call queues the invoking task to the target mutex wait queue and moves it from the RUNNING state to the WAITING state with time-out (mutex wait state).

The WAITING state for a mutex is cancelled in the following cases.

WAITING State for a Mutex Cancel Operation

Return Value

The locked state of the target mutex was cancelled as a result of issuing unl_mtx.

E_OK

The locked state of the target mutex was cancelled as a result of issuing ext_tsk.

E_OK

The locked state of the target mutex was cancelled as a result of issuing exd_tsk.

E_OK

The locked state of the target mutex was cancelled as a result of issuing ter_tsk.

E_OK

Forced release from waiting (accept rel_wai while waiting).

E_RLWAI

Forced release from waiting (accept irel_wai while waiting).

E_RLWAI

The time specified by tmout has elapsed.

E_TMOUT

Forced release from waiting (accept del_mtx while waiting).

E_DLT



When the mutex is locked, this service call changes the current priority of the invoking task to the ceiling priority of the target mutex. However, this service call does not change the current priority when the invoking task has locked other mutexes and the ceiling priority of the target mutex is lower than or equal to the ceiling priority of the locked mutexes.

Note 1 Invoking tasks are queued to the target mutex wait queue in task current priority order. Among tasks with the same priority, they are queued in FIFO order.

Note 2 This service call returns "E_ILUSE" if this service call is re-issued for the mutex that has been locked by the invoking task (multiple-locking of mutex).

Note 3 TMO_FEVR is specified for wait time tmout, processing equivalent to loc_mtx will be executed. When TMO_POL is specified, processing equivalent to ploc_mtx will be executed.

Return value

Macro

Value

Description

E_OK

0

Normal completion.

E_PAR

-17

Parameter error.

- tmout < -1

- tmout > (0x7FFFFFFF - TIC_NUME) / TIC_DENO

E_ID

-18

Invalid ID number.

- mtxid < 0

- mtxid > VTMAX_MTX

E_CTX

-25

Context error.

- This service call was issued from a non-task.

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

- This service call was issued in the dispatching disabled state.

- 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.

E_ILUSE

-28

Illegal use of service call.

- The invoking task has already locked the target mutex.

- Ceiling priority violation (the base priority of the invoking task < the ceiling priority of the target mutex)

E_NOEXS

-42

Non-existent object.

- The mutex specified by mtxid does not exist.

E_RLWAI

-49

Forced release from the WAITING state.

- Accept rel_wai/irel_wai while waiting.

E_TMOUT

-50

Polling failure or specified time has elapsed.

E_DLT

-51

Waiting object deleted.

- Accept del_mtx while waiting.