KERNEL OBJECTS - THREADS
Threads can be thought of as virtual CPUs. The module that processes
them is oz_knl_thread.c.
Each thread has the following properties:
- unique id number
- state (initializing, running, waiting for cpu, waiting for event(s), zombie)
- what thread it's parent is, and what threads are its children
- time in each of the states
- amount of run time left before scheduling demotion
- amount of wait time left before scheduling promotion
- base and current execution priority
- process it belongs to
- event flags it is waiting for (if in waiting for event(s) state)
- ast modes for each processor mode (inhibited or enabled)
- ast queue for each processor mode
- exit handlers for each processor mode
- which cpu (if any) it's context is loaded in
- initialize, exit, suspend event flags
- wake status, indicates why the thread was woken from wait state
- exit status, and whether or not it has exited
- reference count (thread gets deleted when this goes zero)
- security keys (what the thread can access)
- security attributes (who can access the thread)
- pending I/O requests (they get aborted when thread exits)
- thread-private smplock
- name
- hardware context (saved registers, stack pointer, etc), only valid when not loaded in a physical cpu
These methods are defined:
- oz_knl_thread_abort - abort a thread (force it to exit)
- oz_knl_thread_changeproc - change current thread's process
- oz_knl_thread_chkpendast - see if current thread has pending ast's at a given processor mode
- oz_knl_thread_count - count number of threads in a process
- oz_knl_thread_cpuinit - used at boot time only to make the cpu into a thread
- oz_knl_thread_create - create a new thread and queue it for execution
- oz_knl_thread_deqast - dequeue an ast (if any) from current thread at given processor mode
- oz_knl_thread_exit - exit (terminate) current thread
- oz_knl_thread_gettis - get a thread's time in a given state
- oz_knl_thread_getbasepri - get a thread's base execution priority
- oz_knl_thread_getbyid - get a thread given its id number
- oz_knl_thread_getcur - get the thread that's executing on current cpu
- oz_knl_thread_getcurprio - get a thread's current execution priority
- oz_knl_thread_getexitevent - get thread's exit event flag (if any)
- oz_knl_thread_getexitsts - get thread's exit status (and whether it has exited or not)
- oz_knl_thread_getid - get thread's id number
- oz_knl_thread_getname - get thread's name string
- oz_knl_thread_getnext - get first/next thread in a process
- oz_knl_thread_getprocess - get a thread's process
- oz_knl_thread_getwevent - get event flag(s) the thread is waiting for (if any)
- oz_knl_thread_getsecattr - get a thread's security attributes
- oz_knl_thread_getseckeys - get a thread's security keys
- oz_knl_thread_getstate - get a thread's current state
- oz_knl_thread_inccurprio - increment/decrement a thread's current execution priority
- oz_knl_thread_increfc - increment/decrement thread reference count
- oz_knl_thread_wait - put current thread into a particular wait state
- oz_knl_thread_orphan - orphan a thread so it doesn't get aborted/suspended when its parent does
- oz_knl_thread_queueast - queue ast to thread
- oz_knl_thread_resume - resume a thread and all its children
- oz_knl_thread_setast - set current thread's ast delivery mode for a particular process mode
- oz_knl_thread_setbasepri - set a thread's base execution priority
- oz_knl_thread_setcurprio - set a thread's current execution priority
- oz_knl_thread_setdefcresecattr - set a thread's default create security attributes (who can access what it creates)
- oz_knl_thread_setsecattr - set a thread's security attributes (who can access it)
- oz_knl_thread_setseckeys - set a thread's security keys (what it can access)
- oz_knl_thread_suspend - suspend a thread and all its children
- oz_knl_thread_wakewev - wake a thread from wait-for-event state
Exit handlers are closely related so are included in oz_knl_thread.c. They are
called when a thread exits. There is an exit handler queue for each processor mode.
- oz_knl_exhand_create - set up an handler to be called when the thread exits
- oz_knl_exhand_delete - delete an exit handler from a thread
- oz_knl_exhand_dequeue - dequeue an exit handler from a thread