kernel: Add alternative _arch_switch context switch primitive
The existing __swap() mechanism is too high level for some applications because of its scheduler-awareness. This introduces a new _arch_switch() mechanism, which is a simpler primitive that looks like: void _arch_switch(void *handle, void **old_handle_out); The new thread handle (typically just a stack pointer) is specified explicitly instead of being picked up from the scheduler by per-architecture code, and on return the "old" thread handle that got switched out is returned through the pointer. The new primitive (currently available only on xtensa) is selected when CONFIG_USE_SWITCH is "y". A new C _Swap() implementation based on this primitive is then added which operates compatibly. Signed-off-by: Andy Ross <andrew.j.ross@intel.com>
This commit is contained in:
parent
8ac9c082e6
commit
042d8ecca9
4 changed files with 69 additions and 9 deletions
|
@ -469,6 +469,18 @@ struct k_thread {
|
|||
k_thread_stack_t *stack_obj;
|
||||
#endif /* CONFIG_USERSPACE */
|
||||
|
||||
#if defined(CONFIG_USE_SWITCH)
|
||||
/* When using __switch() a few previously arch-specific items
|
||||
* become part of the core OS
|
||||
*/
|
||||
|
||||
/* _Swap() return value */
|
||||
int swap_retval;
|
||||
|
||||
/* Context handle returned via _arch_switch() */
|
||||
void *switch_handle;
|
||||
#endif
|
||||
|
||||
/* arch-specifics: must always be at the end */
|
||||
struct _thread_arch arch;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue