userspace: assign thread IDs at build time

Kernel object metadata had an extra data field added recently to
store bounds for stack objects. Use this data field to assign
IDs to thread objects at build time. This has numerous advantages:

* Threads can be granted permissions on kernel objects before the
  thread is initialized. Previously, it was necessary to call
  k_thread_create() with a K_FOREVER delay, assign permissions, then
  start the thread. Permissions are still completely cleared when
  a thread exits.

* No need for runtime logic to manage thread IDs

* Build error if CONFIG_MAX_THREAD_BYTES is set too low

Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
Andrew Boie 2017-11-03 09:00:35 -07:00 committed by Andrew Boie
commit 818a96d3af
7 changed files with 59 additions and 109 deletions

View file

@ -118,11 +118,6 @@ struct _kernel {
struct k_thread *threads; /* singly linked list of ALL threads */
#endif
#if defined(CONFIG_USERSPACE)
/* 0 bits for ids currently in use, 1 for free ids */
u8_t free_thread_ids[CONFIG_MAX_THREAD_BYTES];
#endif
/* arch-specific part of _kernel */
struct _kernel_arch arch;
};