kernel/sched: Eliminate PRESTART thread state

Traditionally threads have been initialized with a PRESTART flag set,
which gets cleared when the thread runs for the first time via either
its timeout or the k_thread_start() API.

But if you think about it, this is no different, semantically, than
SUSPENDED: the thread is prevented from running until the flag is
cleared.

So unify the two.  Start threads in the SUSPENDED state, point
everyone looking at the PRESTART bit to the SUSPENDED flag, and make
k_thread_start() be a synonym for k_thread_resume().

There is some mild code size savings from the eliminated duplication,
but the real win here is that we make space in the thread flags byte,
which had run out.

Signed-off-by: Andy Ross <andyross@google.com>
This commit is contained in:
Andy Ross 2024-11-25 07:06:58 -08:00 committed by Anas Nashif
commit 7cdf40541b
13 changed files with 29 additions and 86 deletions

View file

@ -78,11 +78,7 @@ int tm_thread_create(int thread_id, int priority, void (*entry_function)(void *,
*/
int tm_thread_resume(int thread_id)
{
if (test_thread[thread_id].base.thread_state & _THREAD_PRESTART) {
k_thread_start(&test_thread[thread_id]);
} else {
k_thread_resume(&test_thread[thread_id]);
}
k_thread_resume(&test_thread[thread_id]);
return TM_SUCCESS;
}