kernel: Decouple sleep from suspend

Sleeping and suspended are now orthogonal states. That is, a thread
may be both sleeping and suspended and the two do not interact. One
repercussion of this is that suspending a thread will no longer
abort its timeout.

Threads are now created in the 'sleeping' state instead of a
'suspended' state. This dovetails nicely with the start delay that
can be given to a newly created thread--it is as though the very
first operation that a thread with a start delay is a sleep.

Signed-off-by: Peter Mitsis <peter.mitsis@intel.com>
This commit is contained in:
Peter Mitsis 2024-11-18 09:46:24 -08:00 committed by Benjamin Cabé
commit 35435928c2
6 changed files with 35 additions and 43 deletions

View file

@ -69,6 +69,11 @@ int tm_thread_create(int thread_id, int priority, void (*entry_function)(void *,
TM_TEST_STACK_SIZE, entry_function,
NULL, NULL, NULL, priority, 0, K_FOREVER);
/* Thread started in sleeping state. Switch to suspended state */
k_thread_suspend(&test_thread[thread_id]);
k_wakeup(&test_thread[thread_id]);
return (tid == &test_thread[thread_id]) ? TM_SUCCESS : TM_ERROR;
}