THREAD_CREATE

Purpose

thread_create creates a new thread.  

Synopsis

#include <types.h>  
#include <stub.h>  

int thread_create(Capability *task, int (*entry)(), Word state, Capability *thread);  

Parameters

Description

thread_create creates a new thread over the task specified by task. The created thread is associated to a new owner capability that is returned through thread. 

Thread creation in Aboelha is very flexible. A new thread can be created to execute any function on the task's code, i. e., the programmer, differently from Unix, does not need to dispatch the thread. This is done by supplying the thread entry point through entry. The first thread over a task is usually created by the loader and has its entry point set to the beginning of the task's code, i.e. ., 0 (not main as one could expect). 

It is not always desirable to create a new thread that starts up running immediately. Some times it is necessary, for instance, to set up a thread mash before starting the threads.  In order to support these cases, it is allowed to the user to specify the thread's creation state. The following states are allowed:  The priority information (minimum, maximum and current priority) for the new thread is inherited from the creator thread and can be altered by calling thread_priority 

Each new thread has its own stack. At present, the stack is created empty and there are no means by which one could pass parameters through it. Note that this is a stub limitation. If you need to pass parameters to the created thread at creation time you should refrain from using this stub and invoke the respective kernel methods. 

Return Values

On success, thread_create returns 0 and thread contains a valid owner capability for the created thread.  

On fail, thread_create returns a negative value indicating one of the following errors:  

See Also

thread_destroy, thread_status, thread_self, thread_exit, thread_wait, thread_priority, thread_sleep, thread_yield, thread_suspend, thread_resume,