k_thread_create(): allow K_FOREVER delay

It's now possible to instantiate a thread object, but delay its
execution indefinitely. This was already supported with K_THREAD_DEFINE.

A new API, k_thread_start(), now exists to start threads that are in
this state.

The intended use-case is to initialize a thread with K_USER, then grant
it various access permissions, and only then start it.

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-08-30 11:01:56 -07:00 committed by Andrew Boie
commit 7d627c5971
4 changed files with 46 additions and 5 deletions

View file

@ -496,7 +496,8 @@ typedef struct _k_thread_stack_element *k_thread_stack_t;
* @param p3 3rd entry point parameter.
* @param prio Thread priority.
* @param options Thread options.
* @param delay Scheduling delay (in milliseconds), or K_NO_WAIT (for no delay).
* @param delay Scheduling delay (in milliseconds), or K_NO_WAIT (for no delay),
* or K_FOREVER (to not run until k_thread_start() is called)
*
* @return ID of new thread.
*/
@ -626,6 +627,18 @@ extern int k_thread_cancel(k_tid_t thread);
*/
extern void k_thread_abort(k_tid_t thread);
/**
* @brief Start an inactive thread
*
* If a thread was created with K_FOREVER in the delay parameter, it will
* not be added to the scheduling queue until this function is called
* on it.
*
* @param thread thread to start
*/
extern void k_thread_start(k_tid_t thread);
/**
* @cond INTERNAL_HIDDEN
*/