Table of Contents
This chapter documents commonly used functions in the GeekOS kernel. Note that this chapter is likely to be incomplete. You can always refer directly to the GeekOS source code if you need more information on a particular function.
struct Kernel_Thread *Start_Kernel_Thread( | startFunc, | |
| arg, | ||
| priority, | ||
detached); |
| Thread_Start_Func | startFunc; |
| ulong_t | arg; |
| int | priority; |
| bool | detached; |
Starts a new kernel thread. startFunc is a function which will be called as the body of the new thread. The start function will execute with interrupts enabled. It should return void and take an unsigned long parameter. arg is an arbitrary value passed to the thread's start function. It can be used to convey extra information, or a pointer to a data structure to be used by the thread. priority is the priority of the new thread. PRIORITY_NORMAL should be used for ordinary kernel threads. PRIORITY_USER should be used for user processes. detached indicates whether the parent thread will wait for the child thread to exit. If true, then the parent must call the Join() function to wait for the child. If false, then the parent must not call Join().
void Exit(exitCode);
int exitCode;
Causes the current thread to exit with the exit code given by exitCode. If the current thread has a parent and is not a detached thread, the exit code will be returned by the Join() call made by the parent. Interrupts must be enabled.
int Join(kthread);
struct Kernel_Thread *kthread;
Wait for a child thread kthread to exit. The child must have been created with its detached parameter set to true. Once the child has exited, returns the exit code of the child thread. Interrupts must be enabled.
void Wait(waitQueue);
struct Thread_Queue *waitQueue;
Puts the current thread on given wait queue. The thread will resume executing at a later point when another thread or interrupt handler calls Wake_Up() or Wake_Up_One() on the same wait queue. Interrupts must be disabled.
void Wake_Up( | waitQueue); |
| struct Thread_Queue * | waitQueue; |
Wakes up all threads on given wait queue by moving them to the run queue. Interrupts must be disabled.