Re: Mach context switch
Vasily Sartakov, le Sun 29 Nov 2009 16:09:53 +0300, a écrit :
> when context_switch from one
> kernel_thread to another (for example, when thread_sleep acquire, and first in
> list idle_thread), anytime will be called swap_function?
I'm not sure to understand what you mean. When thread_sleep blocks,
it calls thread_block, which calls thread_invoke, which calls
switch_context, which does the low-level part.
In the case of continuations (i.e. there is no context to return to, the
thread just needs to call a function again), stack_handoff is called
instead to just switch stacks.
> and i made in boot_script_exec_cmd a kernel_thread for user_bootstrap instead
> of thread_create+thread_start (no doswapin), because i have a kernel_stack=0,
> and cant run user_bootstrap. i think its not corrent (my solution), should i do
> it on active_stack ?
You are supposed to set the value of kernel_stack in stack_attach. That
will get called by thread_invoke when the new thread is scheduled for
the first time (see the "Check that the thread is swapped-in." part
which calls stack_alloc_try(), which calls stack_attach to attached the