Zephyr Project Requirements
Semaphores

Semaphores

SPDX-License-Identifier: Apache-2.0

1. Counting Semaphore Definition At Compile Time UID: ZEP-SRS-5-1 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

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

2. Counting Semaphore Definition At Run Time UID: ZEP-SRS-5-2 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall provide a mechanism to define and initialize a semaphore at runtime.

3. Maximum limit of a semaphore UID: ZEP-SRS-5-3 STATUS: Draft TYPE: Functional COMPONENT: Semaphore STATEMENT:

The Zephyr RTOS shall define the maximum limit of a semaphore when the semaphore is used for counting purposes and does not have an explicit limit.

4. Initialialization with maximum count value UID: ZEP-SRS-5-4 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When initializing a counting semaphore, the maximum permitted count a semaphore can have shall be set.

5. Initial semaphore value UID: ZEP-SRS-5-5 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When initializing a counting semaphore, the initial semaphore value shall be set.

6. Semaphore acquisition mechanism UID: ZEP-SRS-5-6 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall provide a mechanism allowing threads to acquire a semaphore.

7. Semaphore acquisition with count greater than zero UID: ZEP-SRS-5-7 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

While the semaphore's count is greater than zero, the requesting thread shall acquire the semaphore and decrement its count.

8. Semaphore acquisition with zero count UID: ZEP-SRS-5-8 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

While the semaphore's count is zero, the requesting thread shall be blocked until the semaphore is released by another thread.

9. Semaphore acquisition timeout UID: ZEP-SRS-5-9 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When attempting to acquire a semaphore, the Zephyr RTOS shall accept options that specify timeout periods, allowing threads to set a maximum wait time for semaphore acquisition.

10. Semaphore acquisition timeout error handling UID: ZEP-SRS-5-10 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When attempting to acquire a semaphore, where the semaphore is not acquired within the specified time, the Zephyr RTOS shall return an error indicating a timeout.

11. Semaphore acquisition no wait error handling UID: ZEP-SRS-5-11 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When attempting to acquire a semaphore, where the current count is zero and no timeout time was provided, the Zephyr RTOS shall return an error indicating the semaphore is busy.

12. Semaphore release UID: ZEP-SRS-5-12 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall provide a mechanism allowing threads to release a semaphore.

13. Semaphore release UID: ZEP-SRS-5-13 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall increment the semaphore's count upon release.

14. Semaphore release with priority inheritance UID: ZEP-SRS-5-14 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When there are threads waiting on the semaphore, the highest-priority waiting thread shall be unblocked and acquire the semaphore.

15. Checking semaphore count UID: ZEP-SRS-5-15 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall provide a mechanism for threads to check the current count of a semaphore without acquiring it.

16. Semaphore reset UID: ZEP-SRS-5-16 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

The Zephyr RTOS shall provide a mechanism that resets the semaphore count to zero.

17. Semaphore acquisitions abort after reset UID: ZEP-SRS-5-17 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When a semaphore is reset, the Zephyr RTOS shall abort all existing acquisitions of the semaphore returning a resource contention error code.

18. Semaphore Initialization Option Validation UID: ZEP-SRS-5-18 STATUS: Draft TYPE: Functional COMPONENT: Semaphore parents: STATEMENT:

When initializing a counting semaphore, where the maximum permitted count of a semaphore is invalid, then the Zephyr RTOS shall return an error indicating invalid values.