userspace: allow thread IDs to be re-used
It's currently too easy to run out of thread IDs as they are never re-used on thread exit. Now the kernel maintains a bitfield of in-use thread IDs, updated on thread creation and termination. When a thread exits, the permission bitfield for all kernel objects is updated to revoke access for that retired thread ID, so that a new thread re-using that ID will not gain access to objects that it should not have. Because of these runtime updates, setting the permission bitmap for an object to all ones for a "public" object doesn't work properly any more; a flag is now set for this instead. Signed-off-by: Andrew Boie <andrew.p.boie@intel.com>
This commit is contained in:
parent
9bd5e76b47
commit
04caa679c9
7 changed files with 97 additions and 20 deletions
|
@ -118,6 +118,11 @@ struct _kernel {
|
|||
struct k_thread *threads; /* singly linked list of ALL fiber+tasks */
|
||||
#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;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue