Zephyr Project Requirements
Mutex

Mutex

STATEMENT:

SPDX-License-Identifier: Apache-2.0

ZEP-SRS-6-1
1. Mutex Kernel Object
UID: ZEP-SRS-6-1
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

The Zephyr RTOS shall provide a mutex that allows threads to obtain mutually exclusive access to a shared resource.

USER_STORY:

As a Zephyr RTOS user I want to be able to synchronize threads when accessing common resources, where the thread shall have the option to: - wait indefinitely until the resource becomes available. - immediately return with an error if the resource is not available and continue. - wait for a given time for the resource to become available or return with an error.

ZEP-SRS-6-2
2. Mutex definition at compile time
UID: ZEP-SRS-6-2
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

The Zephyr RTOS shall provide a mechanism to define and initialize a mutex at compile time.

ZEP-SRS-6-3
3. Mutex definition at run time
UID: ZEP-SRS-6-3
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

The Zephyr RTOS shall provide a mechanism to initialize a mutex at run time.

ZEP-SRS-6-4
4. Locking a mutex
UID: ZEP-SRS-6-4
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

The Zephyr RTOS shall provide a mechanism for a thread to lock a mutex and become its owner.

ZEP-SRS-6-5
5. Locking an unowned mutex
UID: ZEP-SRS-6-5
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

While a mutex is not owned by any thread, a thread that locks it shall acquire ownership of the mutex.

ZEP-SRS-6-6
6. Locking a mutex owned by another thread
UID: ZEP-SRS-6-6
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

While a mutex is owned by another thread, a thread that attempts to lock it shall be blocked until the mutex becomes available or the specified timeout elapses.

ZEP-SRS-6-7
7. Mutex lock timeout
UID: ZEP-SRS-6-7
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

When locking a mutex, the Zephyr RTOS shall accept a timeout that specifies the maximum time to wait for the mutex to become available.

ZEP-SRS-6-8
8. Mutex lock timeout expiry
UID: ZEP-SRS-6-8
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

When a mutex does not become available within the specified time, the Zephyr RTOS shall return an error indicating that the mutex was not locked.

ZEP-SRS-6-9
9. Recursive mutex locking
UID: ZEP-SRS-6-9
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

While a thread owns a mutex, the Zephyr RTOS shall allow that thread to lock the same mutex again, and shall require the thread to unlock it the same number of times before it is released.

ZEP-SRS-6-10
10. Unlocking a mutex
UID: ZEP-SRS-6-10
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

The Zephyr RTOS shall provide a mechanism for the owning thread to unlock a mutex.

ZEP-SRS-6-11
11. Unlocking by a non-owner
UID: ZEP-SRS-6-11
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

If a thread that does not own a mutex attempts to unlock it, then the Zephyr RTOS shall return an error and shall not release the mutex.

ZEP-SRS-6-12
12. Priority inheritance
UID: ZEP-SRS-6-12
STATUS: Draft
TYPE: Functional
COMPONENT: Mutex
RELATIONS (Parent):
STATEMENT:

While a higher-priority thread is blocked waiting on a mutex, the Zephyr RTOS shall raise the priority of the owning thread to that of the highest-priority waiting thread until the mutex is released.