Zephyr API Documentation  2.7.0-rc2
A Scalable Open Source RTOS
Scheduling Tests

Test scheduling. More...

Functions

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

Detailed Description

Test scheduling.

Function Documentation

◆ test_bad_priorities()

void test_bad_priorities ( void  )

#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.

◆ test_k_thread_priority_get_init_null()

void test_k_thread_priority_get_init_null ( void  )

#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()

◆ test_k_thread_priority_set_init_null()

void test_k_thread_priority_set_init_null ( void  )

#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()

◆ test_k_thread_priority_set_overmax()

void test_k_thread_priority_set_overmax ( void  )

#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()

◆ test_k_thread_priority_set_upgrade()

void test_k_thread_priority_set_upgrade ( void  )

#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()

◆ test_k_thread_resume_init_null()

void test_k_thread_resume_init_null ( void  )

#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()

◆ test_k_thread_suspend_init_null()

void test_k_thread_suspend_init_null ( void  )

#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()

◆ test_k_wakeup_init_null()

void test_k_wakeup_init_null ( void  )

#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()

◆ test_lock_preemptible()

void test_lock_preemptible ( void  )

#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.

◆ test_pending_thread_wakeup()

void test_pending_thread_wakeup ( void  )

#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()

◆ test_preempt()

void test_preempt ( void  )

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

Test preemption.

◆ test_priority_cooperative()

void test_priority_cooperative ( void  )

#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.

◆ test_priority_preemptible()

void test_priority_preemptible ( void  )

#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

◆ test_priority_preemptible_wait_prio()

void test_priority_preemptible_wait_prio ( void  )

#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.

◆ test_priority_scheduling()

void test_priority_scheduling ( void  )

#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

◆ test_sched_is_preempt_thread()

void test_sched_is_preempt_thread ( void  )

#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()

◆ test_sleep_cooperative()

void test_sleep_cooperative ( void  )

#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.

◆ test_sleep_wakeup_preemptible()

void test_sleep_wakeup_preemptible ( void  )

#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()

◆ test_time_slicing_disable_preemptible()

void test_time_slicing_disable_preemptible ( void  )

#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()

◆ test_time_slicing_preemptible()

void test_time_slicing_preemptible ( void  )

#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.

◆ test_unlock_nested_sched_lock()

void test_unlock_nested_sched_lock ( void  )

#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()

◆ test_unlock_preemptible()

void test_unlock_preemptible ( void  )

#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()

◆ test_unqueued()

void test_unqueued ( void  )

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

Validate the behavior of dealine_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.

◆ test_wakeup_expired_timer_thread()

void test_wakeup_expired_timer_thread ( void  )

#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()

◆ test_yield_cooperative()

void test_yield_cooperative ( void  )

#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.