unl_mtx

Outline

Unlock mutex.

C format

 ER      unl_mtx (ID mtxid);
Parameter(s)

I/O

Parameter

Description

I

 ID      mtxid;
ID number of the mutex.



Explanation

This service call unlocks the locked mutex specified by parameter mtxid.

If a task has been queued to the target mutex wait queue when this service call is issued, mutex lock processing is performed by the task (the first task in the wait queue) immediately after mutex unlock processing.

As a result, the task is unlinked from the wait queue and moves from the WAITING state (mutex wait state) to the READY state, or from the WAITING-SUSPENDED state to the SUSPENDED state. And this service call changes the current priority of the task to the ceiling priority of the target mutex. However, this service call does not change the current priority when the 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 A locked mutex can be unlocked only by the task that locked the mutex.
If this service call is issued for a mutex that was not locked by the invoking task, "E_ILUSE" is returned.


Note 2 When a task terminates, mutexes locked by the task are unlocked.

Return value

Macro

Value

Description

E_OK

0

Normal completion.

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 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 have not locked the target mutex.

E_NOEXS

-42

Non-existent object.

- The mutex specified by mtxid does not exist.