|
The functions in this section allow a Diamond program to create new threads of execution within a single task. You need to decide on a size for the thread's workspace, which is used to hold the thread's stack. This space is needed for several things:
|
| • | The auto variables of the function you invoke in the new thread, together with all the other functions it calls; |
|
|
| • | A minimum of five words for every level of function calling; |
|
|
| • | The stack requirements of any run-time library functions the thread calls. These vary depending on the functions you call; a good rule-of-thumb would be to allow 4K octets for this, unless you call only trivial run-time library functions. |
|
As we have seen, the microkernel arranges for the available time to be shared between the various threads. When a thread is temporarily stopped, data relating to it are stored in its own workspace. You should allow an extra THREAD_MIN_STACK bytes for this.
|
thread_launch
|
general thread-starting facility
|
|
thread_new
|
simpler shorthand version of thread_launch
|
|
thread_priority
|
return current thread's priority
|
|
thread_deschedule
|
make current thread momentarily unable to execute
|
|
thread_set_priority
|
change the priority of the current thread
|
|
thread_set_urgent
|
make the current thread urgent
|
|
thread_stop
|
stop the current thread
|
|
thread_wait
|
wait for a thread to stop
|
|
THREAD_HANDLE
|
The type of object returned by the thread creation functions. It may be used by another thread to wait for the termination of the new thread (see thread_wait).
|
|
THREAD_NOTURG
|
macro for the priority of urgent threads (priority 0)
|
|
THREAD_URGENT
|
macro for the priority of normal threads (priority 1)
|
|
THREAD_MIN_STACK
|
minimum allowed size, in bytes, of the workspace for a thread
|
|