Threads.inc

This file defines structures and cosntants for thread management functions of PwnOS.

See Also

Authors

  • Neil G.  Dickson
Summary
Threads.incThis file defines structures and cosntants for thread management functions of PwnOS.
THREADSTRUCTThis structure defines the state of a thread.
Constants
Thread StatusesThese constants define thread statuses for use in THREADSTRUCT.Status.
Thread PrioritiesThese constants define thread priorities for use in THREADSTRUCT.PriorityLevel.
EXTENDEDTSSThis structure defines the complete saved execution environment of a thread.

THREADSTRUCT

This structure defines the state of a thread.

Members

HandleTypeHANDLE_TYPE_THREAD
hProcesshandle of the thread’s process
Statusstatus code of the thread; see Thread Statuses
StatusDatumdatum with meaning specific to the thread status; see Thread Statuses
Flagsmiscellaneous status flags; only THREAD_FLAG_PRIORITY_BOOST is defined at this time
PriorityLevelset priority of the thread; see Thread Priorities
BasePrioritycalculated total current priority, based on PriorityLevel, Flags(THREAD_FLAG_PRIORITY_BOOST), and hProcess.PriorityClass
SwitchTimelast time that the status of the thread changed (milliseconds since startup time); set by scheduler
hNextSiblinghandle of the next thread in hProcess.pThreadList, or NULL if end
hNextQueuedhandle of the next thread in the current queue that this thread is in, or NULL if end
pMessageQueueaddress of the message queue of this thread
Summary
Constants
Thread StatusesThese constants define thread statuses for use in THREADSTRUCT.Status.
Thread PrioritiesThese constants define thread priorities for use in THREADSTRUCT.PriorityLevel.

Constants

Thread Statuses

These constants define thread statuses for use in THREADSTRUCT.Status.

Members

THREAD_STATUS_EMPTYthread doesn’t exist: empty slot where applicable
THREAD_STATUS_IDLEthread has nothing to do at the moment
THREAD_STATUS_RUNNINGthread is running
THREAD_STATUS_SWITCHEDthread ran out of time: StatusDatum indicates time spent in last time slice (milliseconds)
THREAD_STATUS_SLEEPthread chose to sleep: StatusDatum indicates minimum sleeping time requested in milliseconds, or INFINITE for always
THREAD_STATUS_SLEEP_IORETsame as THREAD_STATUS_SLEEP, except that it will receive I/O callbacks
THREAD_STATUS_IO_WAITINGthread waiting for I/O to complete: StatusDatum indicates DeviceNum (see <I/O>)
THREAD_STATUS_MSG_WAITINGthread waiting for message to be processed by another thread: StatusDatum holds the handle of that thread
THREAD_STATUS_IOAVL_WAITINGthread waiting for a certain I/O device num in StatusDatum to become avaliable; returns with access to the device
THREAD_STATUS_LOCK_GETthread waiting to acquire a lock: StatusDataum is address of the lock; see GetLock
THREAD_STATUS_LOCK_WAITthread waiting to be notified on a lock: StatusDatum is address of the lock; see WaitForNotify

Thread Priorities

These constants define thread priorities for use in THREADSTRUCT.PriorityLevel.

Members

THREAD_PRIORITY_IDLEthread is only run when no other threads are queued to run
THREAD_PRIORITY_LOWESTlowest non-idle priority
THREAD_PRIORITY_BELOW_NORMALbelow-normal, but not lowest, priority
THREAD_PRIORITY_NORMALnormal (and default) priority
THREAD_PRIORITY_ABOVE_NORMALabove-normal, but not highest, priority
THREAD_PRIORITY_HIGHESThighest non-time-critical priority
THREAD_PRIORITY_TIME_CRITICALthread is likely to be always first in the queue to run whenever it is queued
THREAD_PRIORITY_ERROR_RETURNnot a thread priority; indicates error in functions returning a thread priority

EXTENDEDTSS

This structure defines the complete saved execution environment of a thread.

Members

ThreadDatathe thread’s THREADSTRUCT
GeneralStatethe normal 32-bit TSS
ExtendedStatethe state saved by FXSAVE
This structure defines the state of a thread.
This file defines thread management functions of PwnOS.
This file defines structures and cosntants for process management functions of PwnOS.
This file defines process management functions of PwnOS.
The Sync section of Core provides functions for mutual exclusion.
These constants define thread statuses for use in THREADSTRUCT.Status.
These constants define thread priorities for use in THREADSTRUCT.PriorityLevel.
This procedure gets a lock’s access for the current thread.
This procedure makes the current thread wait to be notified on the specified lock.