Zephyr Project API 3.7.0-rc1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Scheduling Tests

Test scheduling. More...

Functions

 ZTEST (suite_deadline, test_unqueued)
 Validate the behavior of deadline_set when the thread is not queued.
 
 ZTEST (suite_preempt, test_preempt)
 Test preemption.
 
 ZTEST (threads_scheduling, test_priority_scheduling)
 Check the behavior of preemptive threads with different priorities.
 
 ZTEST (threads_scheduling, test_sched_is_preempt_thread)
 Validate the correctness of k_is_preempt_thread()
 
 ZTEST (threads_scheduling, test_priority_cooperative)
 Validate that the cooperative thread will not be preempted.
 
 ZTEST (threads_scheduling, test_priority_preemptible)
 Validate preemptiveness of preemptive thread.
 
 ZTEST (threads_scheduling_1cpu, test_priority_preemptible_wait_prio)
 Validate scheduling sequence of preemptive threads with start delay.
 
 ZTEST (threads_scheduling, test_bad_priorities)
 Validate checking priority values.
 
 ZTEST (threads_scheduling, test_yield_cooperative)
 Validate the behavior of cooperative thread when it yields.
 
 ZTEST (threads_scheduling, test_sleep_cooperative)
 Validate the behavior of cooperative thread when it sleeps.
 
 ZTEST (threads_scheduling, test_sleep_wakeup_preemptible)
 Validate k_wakeup()
 
 ZTEST (threads_scheduling, test_pending_thread_wakeup)
 Verify k_wakeup() behavior on pending thread.
 
 ZTEST (threads_scheduling, test_time_slicing_preemptible)
 Validate preemptive thread behavior with time slice.
 
 ZTEST (threads_scheduling, test_time_slicing_disable_preemptible)
 Check the behavior of preemptive thread with k_busy_wait()
 
 ZTEST (threads_scheduling, test_lock_preemptible)
 Lock the scheduler when preemptive threads are running.
 
 ZTEST (threads_scheduling, test_unlock_preemptible)
 Validate k_sched_lock() and k_sched_unlock()
 
 ZTEST (threads_scheduling, test_unlock_nested_sched_lock)
 Validate nested k_sched_lock() and k_sched_unlock()
 
 ZTEST (threads_scheduling, test_wakeup_expired_timer_thread)
 validate k_wakeup() in some corner scenario
 
 ZTEST_USER (threads_scheduling, test_k_thread_suspend_init_null)
 Test k_thread_suspend() API.
 
 ZTEST_USER (threads_scheduling, test_k_thread_resume_init_null)
 Test k_thread_resume() API.
 
 ZTEST_USER (threads_scheduling, test_k_thread_priority_get_init_null)
 Test k_thread_priority_get() API.
 
 ZTEST_USER (threads_scheduling, test_k_thread_priority_set_init_null)
 Test k_thread_priority_set() API.
 
 ZTEST_USER (threads_scheduling, test_k_thread_priority_set_overmax)
 Test k_thread_priority_set() API.
 
 ZTEST_USER (threads_scheduling, test_k_thread_priority_set_upgrade)
 Test k_thread_priority_set() API.
 
 ZTEST_USER (threads_scheduling, test_k_wakeup_init_null)
 Test k_wakeup() API.
 

Detailed Description

Test scheduling.

Function Documentation

◆ ZTEST() [1/18]

ZTEST ( suite_deadline  ,
test_unqueued   
)

#include <tests/kernel/sched/deadline/src/main.c>

Validate the behavior of deadline_set when the thread is not queued.

Create a bunch of threads with scheduling delay which make the thread in unqueued state. The k_thread_deadline_set() call should not make these threads run before there delay time pass.

◆ ZTEST() [2/18]

ZTEST ( suite_preempt  ,
test_preempt   
)

#include <tests/kernel/sched/preempt/src/main.c>

Test preemption.

◆ ZTEST() [3/18]

ZTEST ( threads_scheduling  ,
test_bad_priorities   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_priority.c>

Validate checking priority values.

Our test cases don't cover every outcome of whether a priority is valid, do so here.

◆ ZTEST() [4/18]

ZTEST ( threads_scheduling  ,
test_lock_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Lock the scheduler when preemptive threads are running.

Create 3 threads and lock the scheduler. Make sure that the threads are not executed. Call k_sleep() and check if the threads have executed.

◆ ZTEST() [5/18]

ZTEST ( threads_scheduling  ,
test_pending_thread_wakeup   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Verify k_wakeup() behavior on pending thread.

The test creates a cooperative thread and let it wait for semaphore. Then calls k_wakeup(). The k_wakeup() call should return gracefully without waking up the thread

See also
k_wakeup()

◆ ZTEST() [6/18]

ZTEST ( threads_scheduling  ,
test_priority_cooperative   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_priority.c>

Validate that the cooperative thread will not be preempted.

Create a cooperative thread with priority higher than the current cooperative thread. Make sure that the higher priority thread will not preempt the lower priority cooperative thread.

◆ ZTEST() [7/18]

ZTEST ( threads_scheduling  ,
test_priority_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_priority.c>

Validate preemptiveness of preemptive thread.

Create a preemptive thread which is of priority lower than current thread. Current thread is made has preemptive. Make sure newly created thread is not preempted. Now create a preemptive thread which is of priority higher than current thread. Make sure newly created thread is preempted

◆ ZTEST() [8/18]

ZTEST ( threads_scheduling  ,
test_priority_scheduling   
)

#include <tests/kernel/sched/schedule_api/src/test_priority_scheduling.c>

Check the behavior of preemptive threads with different priorities.

Create multiple threads of different priorities - all are preemptive, current thread is also made preemptive. Check how the threads get chance to execute based on their priorities

◆ ZTEST() [9/18]

ZTEST ( threads_scheduling  ,
test_sched_is_preempt_thread   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_is_preempt_thread.c>

Validate the correctness of k_is_preempt_thread()

Create a preemptive thread, lock the scheduler and call k_is_preempt_thread(). Unlock the scheduler and call k_is_preempt_thread() again. Create a cooperative thread and lock the scheduler k_is_preempt_thread() and unlock the scheduler and call k_is_preempt_thread().

See also
k_is_preempt_thread()

◆ ZTEST() [10/18]

ZTEST ( threads_scheduling  ,
test_sleep_cooperative   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate the behavior of cooperative thread when it sleeps.

Create 3 threads of priority -2, -1 and 0. Put the main thread in timeout queue by calling k_sleep() which is cooperative. Check if all the threads gets executed.

◆ ZTEST() [11/18]

ZTEST ( threads_scheduling  ,
test_sleep_wakeup_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate k_wakeup()

Create 3 threads with main thread with priority 0 and other threads with -1, 0 ,+1 priority. Now -1 priority thread gets executed and it is made to sleep for 10 sec. Now, wake up the -1 priority thread and check if it starts executing.

See also
k_wakeup()

◆ ZTEST() [12/18]

ZTEST ( threads_scheduling  ,
test_time_slicing_disable_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Check the behavior of preemptive thread with k_busy_wait()

Create 3 threads with -1, 0, and 1 as priority, setup time slice for threads with priority 0. Make sure the threads with equal priorities are executed in time slice. Also run k_busy_wait() for 5 secs and check if other threads are not executed at that time.

See also
k_busy_wait()

◆ ZTEST() [13/18]

ZTEST ( threads_scheduling  ,
test_time_slicing_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate preemptive thread behavior with time slice.

Create 3 threads with -1, 0, and 1 as priority, setup time slice for threads with priority 0. Make sure the threads with equal priorities are executed in time slice.

◆ ZTEST() [14/18]

ZTEST ( threads_scheduling  ,
test_unlock_nested_sched_lock   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate nested k_sched_lock() and k_sched_unlock()

In a preemptive thread, lock the scheduler twice and create a cooperative thread. Call k_sched_unlock() and check the cooperative thread haven't executed. Unlock it again to see the thread have executed this time.

See also
k_sched_lock(), k_sched_unlock()

◆ ZTEST() [15/18]

ZTEST ( threads_scheduling  ,
test_unlock_preemptible   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate k_sched_lock() and k_sched_unlock()

Lock the scheduler and create 3 threads. Check that the threads are not executed. Call k_sched_unlock() and check if the threads have executed.

See also
k_sched_lock(), k_sched_unlock()

◆ ZTEST() [16/18]

ZTEST ( threads_scheduling  ,
test_wakeup_expired_timer_thread   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

validate k_wakeup() in some corner scenario

trigger a timer and after expiration of timer call k_wakeup(), even the thread is not in sleep state neither in pending state

See also
k_wakeup()

◆ ZTEST() [17/18]

ZTEST ( threads_scheduling  ,
test_yield_cooperative   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_timeslice_and_lock.c>

Validate the behavior of cooperative thread when it yields.

Create 3 threads of priority -2, -1 and 0. Yield the main thread which is cooperative. Check if all the threads gets executed.

◆ ZTEST() [18/18]

ZTEST ( threads_scheduling_1cpu  ,
test_priority_preemptible_wait_prio   
)

#include <tests/kernel/sched/schedule_api/src/test_sched_priority.c>

Validate scheduling sequence of preemptive threads with start delay.

Create four preemptive threads which are of priority higher than current thread. Make sure that the highest priority and longest waiting thread is scheduled first.

◆ ZTEST_USER() [1/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_priority_get_init_null   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_priority_get() API.

Create a thread and set thread_k_thread_priority_get() param input to NULL will trigger a fatal error.

See also
thread_k_thread_priority_get()

◆ ZTEST_USER() [2/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_priority_set_init_null   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_priority_set() API.

Create a thread and set k_thread_priority_set() param input to NULL will trigger a fatal error.

See also
k_thread_priority_set()

◆ ZTEST_USER() [3/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_priority_set_overmax   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_priority_set() API.

Check input param range overmax in userspace test.

See also
k_thread_priority_set()

◆ ZTEST_USER() [4/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_priority_set_upgrade   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_priority_set() API.

Check input param range fail in userspace test.

See also
k_thread_priority_set()

◆ ZTEST_USER() [5/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_resume_init_null   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_resume() API.

Create a thread and set k_thread_resume() input param to NULL will trigger a fatal error.

See also
k_thread_resume()

◆ ZTEST_USER() [6/7]

ZTEST_USER ( threads_scheduling  ,
test_k_thread_suspend_init_null   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_thread_suspend() API.

Create a thread and set k_thread_suspend() input param to NULL will trigger a fatal error.

See also
k_thread_suspend()

◆ ZTEST_USER() [7/7]

ZTEST_USER ( threads_scheduling  ,
test_k_wakeup_init_null   
)

#include <tests/kernel/sched/schedule_api/src/user_api.c>

Test k_wakeup() API.

Create a thread and set k_wakeup() input param to NULL will trigger a fatal error

See also
k_wakeup()