void CPU_Context_Initialize(struct reg_context *the_context,void *stack_base, unsigned int stack_size, void *(*entry_point)(void *,void *), void *(*thread_fun)(void *), void *thread_arg);
CPU_Context_Initialize is called to initialize the conext space of a
new thread so that it can be properly loaded onto the processor,
the first time.
A typical implementation
initializes the stack pointer, program counter and the flag register to
proper values. The implementation of this function for the three architectures
(x86, arm and trimedia) is given in Appendix A.
The description of the arguements to CPU_Context_Initialize are as follows.
entry_point is the starting function of the thread.
CPU_Context_Initialize should initialize the context of the new thread,
so that when it is loaded on to the processor for the first time, it
starts executing at entry_point, with thread_fun and
thread_arg as arguements to it.
It's a pointer to the context space of the newly created thread.
This is a pointer to the base (lowest addresse) of the stack. In most architectures, the stack starts from the higest addresse and grows downwards towards zero. In such cases stack pointer in the tcb should be initialized to stack_base + stack_size. On the other hand, for processors where the stack grows away from zero, the stack pointer should be to initialized to stack_base. The two arguements are passed separately for incorporating both the cases when the stack grows from zero and towards zero.