Zephyr Project Requirements
Thread Scheduling

Thread Scheduling

UID:
VERSION:
CLASSIFICATION:
PREFIX:
ZEP-SRS-2-
Type
Level
UID
STATUS
TYPE
COMPONENT
REFS
Title
Statement
USER_STORY
TEXT

SPDX-License-Identifier: Apache-2.0

SECTION
1
Thread Scheduling
REQUIREMENT
1.1
ZEP-SRS-2-4
Draft
Functional
Thread Scheduling
ZEP-SRS-2-4
Scheduling a thread based on an event

When an event on which a thread is waiting occurs, the Zephyr RTOS shall make the waiting thread ready.

As a Zephyr RTOS user, I want to be able to execute work which reacts on events and interrupts the current executed work.

REQUIREMENT
1.2
ZEP-SRS-2-5
Draft
Functional
Thread Scheduling
ZEP-SRS-2-5
Deadline Scheduling Priorities

Where earliest-deadline-first scheduling is enabled, when two or more ready threads have equal static priority, the Zephyr RTOS shall consider the thread with the earliest deadline to have the higher priority.

As a Zephyr RTOS user, I want to be able to schedule threads by earliest deadline first.

REQUIREMENT
1.3
ZEP-SRS-2-24
Draft
Functional
Thread Scheduling
ZEP-SRS-2-24
Deadline scheduling tie-breaking

Where earliest-deadline-first scheduling is enabled, when two or more ready threads have equal static priority and equal deadlines, the Zephyr RTOS shall treat them as threads of equal priority.

REQUIREMENT
1.4
ZEP-SRS-2-8
Draft
Functional
Thread Scheduling
ZEP-SRS-2-8
Numeric thread priorities

The Zephyr RTOS shall schedule threads according to a numeric thread priority, giving a thread with a numerically lower priority value precedence over a thread with a numerically higher priority value.

As a Zephyr RTOS user, I want the OS to schedule threads by numeric priority so that I can control the relative importance of my threads.

REQUIREMENT
1.5
ZEP-SRS-2-9
Draft
Functional
Thread Scheduling
ZEP-SRS-2-9
Preemption support

While the current thread is preemptible, when a thread of higher priority becomes ready, the Zephyr RTOS shall suspend execution of the current thread and select the higher-priority thread as the current thread.

As a Zephyr RTOS user, I want a higher priority thread to take over the CPU as soon as it becomes ready, so that important work is not delayed by less important work.

REQUIREMENT
1.6
ZEP-SRS-2-10
Draft
Functional
Thread Scheduling
ZEP-SRS-2-10
Thread priority ranges

The Zephyr RTOS shall partition the thread priority space into a cooperative priority range and a preemptible priority range.

As a Zephyr RTOS user, I want thread priorities organized into cooperative and preemptible ranges, so that a thread's priority determines its preemption behavior.

REQUIREMENT
1.7
ZEP-SRS-2-11
Draft
Functional
Thread Scheduling
ZEP-SRS-2-11
Time sharing of CPU resources

Where time slicing is enabled, the Zephyr RTOS shall cause the current preemptible thread to relinquish the CPU after not more than a configurable time slice period whenever one or more other ready threads of the same priority exist.

As a Zephyr RTOS user, I want to be able to configure my RTOS in the way, that the CPU resources are shared evenly among executed threads of the same priority.

REQUIREMENT
1.8
ZEP-SRS-2-12
Draft
Functional
Thread Scheduling
ZEP-SRS-2-12
Selecting the current thread

When a scheduling decision is made on a CPU, the Zephyr RTOS shall select as the current thread the highest-priority ready thread that is eligible to execute on that CPU.

REQUIREMENT
1.9
ZEP-SRS-2-13
Draft
Functional
Thread Scheduling
ZEP-SRS-2-13
Scheduling threads of equal priority

When two or more ready threads share the same priority, the Zephyr RTOS shall select among them the thread that has been ready the longest.

REQUIREMENT
1.10
ZEP-SRS-2-14
Draft
Functional
Thread Scheduling
ZEP-SRS-2-14
Cooperative threads

The Zephyr RTOS shall support cooperative threads that, once running, are not subject to preemption by other threads and remain the current thread until they yield or block.

REQUIREMENT
1.11
ZEP-SRS-2-15
Draft
Functional
Thread Scheduling
ZEP-SRS-2-15
Yielding the CPU

The Zephyr RTOS shall provide an interface for the current thread to voluntarily relinquish the CPU to other ready threads of the same or higher priority. If no ready thread of the same or higher priority exists, the current thread shall continue to execute.

REQUIREMENT
1.12
ZEP-SRS-2-16
Draft
Functional
Thread Scheduling
ZEP-SRS-2-16
Locking the scheduler

The Zephyr RTOS shall provide interfaces for a preemptible thread to disable preemption of itself by other threads and to subsequently restore its preemptible status.

REQUIREMENT
1.13
ZEP-SRS-2-25
Draft
Functional
Thread Scheduling
ZEP-SRS-2-25
Blocking with the scheduler locked

While a thread has disabled preemption, when that thread becomes unready, the Zephyr RTOS shall allow other threads to execute.

REQUIREMENT
1.14
ZEP-SRS-2-26
Draft
Functional
Thread Scheduling
ZEP-SRS-2-26
Preemption status across blocking

When a thread that has disabled preemption resumes execution after having been unready, the Zephyr RTOS shall continue to treat the thread as non-preemptible until it re-enables preemption.

REQUIREMENT
1.15
ZEP-SRS-2-17
Draft
Functional
Thread Scheduling
ZEP-SRS-2-17
Setting a thread deadline

Where earliest-deadline-first scheduling is enabled, the Zephyr RTOS shall provide an interface to set a thread's deadline.

REQUIREMENT
1.16
ZEP-SRS-2-18
Draft
Functional
Thread Scheduling
ZEP-SRS-2-18
Per-thread time slice

Where per-thread time slicing is enabled, the Zephyr RTOS shall provide an interface to set an individual time slice duration and expiry callback for a specific thread.

REQUIREMENT
1.17
ZEP-SRS-2-19
Draft
Functional
Thread Scheduling
ZEP-SRS-2-19
Forcing a scheduling decision

The Zephyr RTOS shall provide an interface to request an immediate re-evaluation of the scheduling decision on the current CPU in accordance with the scheduling rules.

REQUIREMENT
1.18
ZEP-SRS-2-27
Draft
Functional
Thread Scheduling
ZEP-SRS-2-27
Forcing a scheduling decision from an interrupt

When a re-evaluation of the scheduling decision is requested from an interrupt service routine, the Zephyr RTOS shall perform the re-evaluation upon exit from the interrupt.

REQUIREMENT
1.19
ZEP-SRS-2-20
Draft
Functional
Thread Scheduling
ZEP-SRS-2-20
Querying thread preemptibility

The Zephyr RTOS shall provide an interface to determine whether the currently executing context can be preempted by another thread.

REQUIREMENT
1.20
ZEP-SRS-2-21
Draft
Non-Functional
Thread Scheduling
ZEP-SRS-2-21
Selecting the ready queue implementation

The Zephyr RTOS shall support selecting the scheduler's ready queue implementation at build time.

As a Zephyr RTOS user, I want to choose a ready queue implementation that matches my system's memory, code size, and ready-thread-count profile, so that scheduling overhead fits my application.

REQUIREMENT
1.21
ZEP-SRS-2-29
Draft
Functional
Thread Scheduling
ZEP-SRS-2-29
Deferred interrupt processing thread priorities

Where deferred interrupt processing threads are configured, the Zephyr RTOS shall reserve the highest thread priorities for them.

REQUIREMENT
1.22
ZEP-SRS-2-22
Draft
Functional
Thread Scheduling
ZEP-SRS-2-22
Preemption by deferred interrupt processing threads

Where deferred interrupt processing threads are configured, when a deferred interrupt processing thread becomes ready, the Zephyr RTOS shall preempt the current thread, even if it is cooperative or has disabled preemption, and select the ready thread as the current thread, when either of the following conditions is satisfied:

  • the current thread is not a deferred interrupt processing thread
  • the current thread is a deferred interrupt processing thread of lower priority
REQUIREMENT
1.23
ZEP-SRS-2-28
Draft
Functional
Thread Scheduling
ZEP-SRS-2-28
Deferred interrupt processing thread interruptibility

Where deferred interrupt processing threads are configured, a running deferred interrupt processing thread shall remain interruptible by interrupt service routines.

REQUIREMENT
1.24
ZEP-SRS-2-23
Draft
Functional
Thread Scheduling
ZEP-SRS-2-23
Time slice priority threshold

Where time slicing is enabled, the Zephyr RTOS shall exempt threads whose priority is higher than a configurable priority threshold from time slicing.