Difference between revisions of "Unit Threads"

From Ultibo.org
Jump to: navigation, search
Line 1,052: Line 1,052:
 
----
 
----
  
''To be documented''
+
 
 +
'''Spin entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSpinEntry = ^TSpinEntry;</code>
 +
 
 +
<code>TSpinEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Spin Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the lock (Locked/Unlocked)
 +
|-
 +
| <code>Mask:LongWord;</code>
 +
| IRQ/FIQ Mask for Save/Restore
 +
|-
 +
| <code>Owner:TThreadHandle;</code>
 +
| Currently owning thread (or INVALID_HANDLE_VALUE if not locked)
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PSpinEntry;</code>
 +
| Previous entry in Spin table
 +
|-
 +
| <code>Next:PSpinEntry;</code>
 +
| Next entry in Spin table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Mutex entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMutexEntry = ^TMutexEntry;</code>
 +
 
 +
<code>TMutexEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Mutex Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the lock (Locked/Unlocked)
 +
|-
 +
| <code>Owner:TThreadHandle;</code>
 +
| Currently owning thread (or INVALID_HANDLE_VALUE if not locked)
 +
|-
 +
| <code>Yield:TThreadYield;</code>
 +
| Yield function to call while waiting
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of lock recursions (only if Flags includes MUTEX_FLAG_RECURSIVE)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Mutex Flags (eg MUTEX_FLAG_RECURSIVE)
 +
|-
 +
| <code>SpinCount:LongWord;</code>
 +
| Number of times to spin wait for lock before Yield is called (Always 0 if SCHEDULER_CPU_COUNT = 1)
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PMutexEntry;</code>
 +
| Previous entry in Mutex table
 +
|-
 +
| <code>Next:PMutexEntry;</code>
 +
| Next entry in Mutex table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Critical section entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PCriticalSectionEntry = ^TCriticalSectionEntry;</code>
 +
 
 +
<code>TCriticalSectionEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Critical Section Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the lock (Locked/Unlocked)
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of lock recursions
 +
|-
 +
| <code>Owner:TThreadHandle;</code>
 +
| Currently owning thread (or INVALID_HANDLE_VALUE if not locked)
 +
|-
 +
| <code>SpinCount:LongWord;</code>
 +
| Number of times to spin wait for lock before Wait is called (Always 0 if SCHEDULER_CPU_COUNT = 1)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Critical Section Lock
 +
|-
 +
| <code>List:TListHandle;</code>
 +
| List of threads waiting on this CriticalSection (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>Wait:TThreadWait;</code>
 +
| Wait function to call to wait on the CriticalSection if it is already locked
 +
|-
 +
| <code>WaitEx:TThreadWaitEx;</code>
 +
| Wait function to call to wait with timeout on the CriticalSection if it is already locked
 +
|-
 +
| <code>Release:TThreadRelease;</code>
 +
| Release function to call if any threads are waiting when CriticalSection is unlocked
 +
|-
 +
| <code>Abandon:TThreadAbandon;</code>
 +
| Abandon function to call if any threads are waiting when CriticalSection is destroyed
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PCriticalSectionEntry;</code>
 +
| Previous entry in CriticalSection table
 +
|-
 +
| <code>Next:PCriticalSectionEntry;</code>
 +
| Next entry in CriticalSection table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Semaphore entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSemaphoreEntry = ^TSemaphoreEntry;</code>
 +
 
 +
<code>TSemaphoreEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Semaphore Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count for this Semaphore (Can be negative when Threads are waiting)
 +
|-
 +
| <code>Maximum:LongWord;</code>
 +
| Maximum count for this Semaphore
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Semaphore Flags (eg SEMAPHORE_FLAG_IRQ)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Semaphore Lock
 +
|-
 +
| <code>List:TListHandle;</code>
 +
| List of threads waiting on this Semaphore (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>Wait:TThreadWait;</code>
 +
| Wait function to call to wait on the Semaphore if the count is equal to zero on SemaphoreWait
 +
|-
 +
| <code>WaitEx:TThreadWaitEx;</code>
 +
| Wait function to call to wait with timeout on the Semaphore if the count is equal to zero on SemaphoreWait
 +
|-
 +
| <code>Release:TThreadRelease;</code>
 +
| Release function to call if any threads are waiting on SemaphoreSignal
 +
|-
 +
| <code>Abandon:TThreadAbandon;</code>
 +
| Abandon function to call if any threads are waiting when SemaphoreSignal is destroyed
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PSemaphoreEntry;</code>
 +
| Previous entry in Semaphore table
 +
|-
 +
| <code>Next:PSemaphoreEntry;</code>
 +
| Next entry in Semaphore table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Synchronizer entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PSynchronizerEntry = ^TSynchronizerEntry;</code>
 +
 
 +
<code>TSynchronizerEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Synchronizer Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the lock (Locked/Unlocked)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Synchronizer Lock
 +
|-
 +
| <code>ReaderCount:LongWord;</code>
 +
| Count of current reader locks
 +
|-
 +
| <code>WriterCount:LongWord;</code>
 +
| Count of current writer lock recursions
 +
|-
 +
| <code>ReaderLast:TThreadHandle;</code>
 +
| Last thread to acquire reader lock (or INVALID_HANDLE_VALUE if no reader)
 +
|-
 +
| <code>WriterOwner:TThreadHandle;</code>
 +
| Currently owning writer thread (or INVALID_HANDLE_VALUE if no writer)
 +
|-
 +
| <code>ReaderList:TListHandle;</code>
 +
| List of reader threads waiting on this Synchronizer (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>WriterList:TListHandle;</code>
 +
| List of writer threads waiting on this Synchronizer (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>Wait:TThreadWait;</code>
 +
| Wait function to call to wait on the Synchronizer if it is already locked
 +
|-
 +
| <code>WaitEx:TThreadWaitEx;</code>
 +
| Wait function to call to wait with timeout on the Synchronizer if it is already locked
 +
|-
 +
| <code>Release:TThreadRelease;</code>
 +
| Release function to call if any threads are waiting when Synchronizer is unlocked
 +
|-
 +
| <code>Abandon:TThreadAbandon;</code>
 +
| Abandon function to call if any threads are waiting when Synchronizer is destroyed
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PSynchronizerEntry;</code>
 +
| Previous entry in Synchronizer table
 +
|-
 +
| <code>Next:PSynchronizerEntry;</code>
 +
| Next entry in Synchronizer table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''List entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PListEntry = ^TListEntry;</code>
 +
 
 +
<code>TListEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''List Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>ListType:LongWord;</code>
 +
| Type of this List (eg LIST_TYPE_WAIT_SECTION)
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of items currently in this List
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| List Flags (eg LIST_FLAG_IRQ)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| List Lock
 +
|-
 +
| <code>First:PListElement;</code>
 +
| First element in List
 +
|-
 +
| <code>Last:PListElement;</code>
 +
| Last element in List
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PListEntry;</code>
 +
| Previous entry in List table
 +
|-
 +
| <code>Next:PListEntry;</code>
 +
| Next entry in List table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''List element'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PListElement = ^TListElement;</code>
 +
 
 +
<code>TListElement = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Thread:TThreadHandle;</code>
 +
| The thread referenced by this List element
 +
|-
 +
| <code>Prev:PListElement;</code>
 +
| Previous element in List
 +
|-
 +
| <code>Next:PListElement;</code>
 +
| Next element in List
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''List handles'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PListHandles = ^TListHandles;</code>
 +
 
 +
<code>TListHandles = array[0..THREAD_LISTS_MAXIMUM - 1] of TListHandle;</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Queue entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PQueueEntry = ^TQueueEntry;</code>
 +
 
 +
<code>TQueueEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Queue Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>QueueType:LongWord;</code>
 +
| Type of this Queue (eg QUEUE_TYPE_SCHEDULE_IDLE)
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of items currently in this Queue
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Queue Flags (eg QUEUE_FLAG_IRQ)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Queue Lock
 +
|-
 +
| <code>First:PQueueElement;</code>
 +
| First element in Queue
 +
|-
 +
| <code>Last:PQueueElement;</code>
 +
| Last element in Queue
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PQueueEntry;</code>
 +
| Previous entry in Queue table
 +
|-
 +
| <code>Next:PQueueEntry;</code>
 +
| Next entry in Queue table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Queue element'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PQueueElement = ^TQueueElement;</code>
 +
 
 +
<code>TQueueElement = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Key:Integer;</code>
 +
| Ordering key for Queue
 +
|-
 +
| <code>Thread:TThreadHandle;</code>
 +
| The thread referenced by this Queue element
 +
|-
 +
| <code>Prev:PQueueElement;</code>
 +
| Previous element in Queue
 +
|-
 +
| <code>Next:PQueueElement;</code>
 +
| Next element in Queue
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''Message list'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMessageList = ^TMessageList;</code>
 +
 
 +
<code>TMessageList = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Header Properties''
 +
|-
 +
| <code>Maximum:LongWord;</code>
 +
| Maximum number of messages in list
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Current number of messages in list
 +
|-
 +
| <code>Start:LongWord;</code>
 +
| First message available in list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>List:PMessage;</code>
 +
| Message list
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''Message'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMessage = ^TMessage;</code>
 +
 
 +
<code>TMessage = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Msg:LongWord;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>wParam:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>lParam:LongInt;</code>
 +
| &nbsp;
 +
|-
 +
| <code>Time:LongWord;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Thread entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PThreadEntry = ^TThreadEntry;</code>
 +
 
 +
<code>TThreadEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Thread Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the Thread (eg THREAD_STATE_RUNNING)
 +
|-
 +
| <code>Priority:LongWord;</code>
 +
| Priority of the Thread (eg THREAD_PRIORITY_NORMAL)
 +
|-
 +
| <code>Affinity:LongWord;</code>
 +
| CPU Affinity mask of the Thread
 +
|-
 +
| <code>StackBase:Pointer;</code>
 +
| Base (Top) of the thread stack
 +
|-
 +
| <code>StackSize:LongWord;</code>
 +
| Stack length in bytes
 +
|-
 +
| <code>Name:array[0..THREAD_NAME_LENGTH - 1] of Char;</code>
 +
|  The name of the Thread
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Thread Lock
 +
|-
 +
| <code>Parent:TThreadHandle;</code>
 +
| Handle of the parent thread
 +
|-
 +
| <code>Messages:TMessageList;</code>
 +
| Messages sent to this thread
 +
|-
 +
| <code>TlsPointer:Pointer;</code>
 +
| Thread Local Storage Memory (RTL ThreadVars)
 +
|-
 +
| <code>TlsTable:array[0..THREAD_TLS_MAXIMUM - 1] of Pointer;</code>
 +
| Thread Local Storage Index Pointers (for ThreadGetTlsValue/ThreadSetTlsValue)
 +
|-
 +
| <code>TlsFlags:array[0..THREAD_TLS_MAXIMUM - 1] of LongWord;</code>
 +
| Thread Local Storage Index Flags (eg THREAD_TLS_FLAG_FREE)
 +
|-
 +
| <code>ExitCode:LongWord;</code>
 +
| Thread Exit Code
 +
|-
 +
| <code>LastError:LongWord;</code>
 +
| Thread Last Error
 +
|-
 +
| <code>Locale:LCID;</code>
 +
| Thread Locale
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>CurrentCPU:LongWord;</code>
 +
| Saved current CPU from last ContextSwitch
 +
|-
 +
| <code>StackPointer:Pointer;</code>
 +
| Saved current stack pointer from last ContextSwitch
 +
|-
 +
| <code>TargetCPU:LongWord;</code>
 +
| Target CPU of the Thread for next ContextSwitch
 +
|-
 +
| <code>TargetPriority:LongWord;</code>
 +
| Target Priority of the Thread for next ContextSwitch (eg THREAD_PRIORITY_NORMAL)
 +
|-
 +
| <code>List:TListHandle;</code>
 +
| List of threads waiting on this thread (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>WaitList:TListHandle;</code>
 +
| The wait list this thread is currently in (or INVALID_HANDLE_VALUE)
 +
|-
 +
| <code>WaitLists:PListHandles;</code>
 +
| The wait lists this thread is currently in if doing a multiple wait (or nil)
 +
|-
 +
| <code>WaitResult:LongWord;</code>
 +
| The result code for the last wait with timeout (eg WAIT_TIMEOUT)
 +
|-
 +
| <code>ReceiveResult:LongWord;</code>
 +
| The result code for the last receive with timeout (eg WAIT_TIMEOUT)
 +
|-
 +
|colspan="2"|&nbsp;
 +
|-
 +
| <code>ListElement:TListElement;</code>
 +
| List element for this thread when in a Wait List
 +
|-
 +
| <code>QueueElement:TQueueElement;</code>
 +
| Queue element for this thread when in a Schedule Queue
 +
|-
 +
| <code>Prev:PThreadEntry;</code>
 +
| Previous entry in Thread table
 +
|-
 +
| <code>Next:PThreadEntry;</code>
 +
| Next entry in Thread table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| <code>CreateTime:Int64;</code>
 +
| The time when this thread was created
 +
|-
 +
| <code>ExitTime:Int64;</code>
 +
| The time when this thread exited or was terminated
 +
|-
 +
| <code>KernelTime:Int64;</code>
 +
| The total amount of time this thread has been in the running state (ie CPU time consumed)
 +
|-
 +
| <code>SwitchCount:Int64;</code>
 +
| The number of times this thread has been selected to run by a context switch
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''Thread snapshot'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PThreadSnapshot = ^TThreadSnapshot;</code>
 +
 
 +
<code>TThreadSnapshot = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|Note: Data returned by ThreadSnapshotCreate
 +
|-
 +
|colspan="2"|''Snapshot Properties''
 +
|-
 +
| <code>Handle:TThreadHandle;</code>
 +
| Handle of the thread
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the Thread (eg THREAD_STATE_RUNNING)
 +
|-
 +
| <code>CPU:LongWord;</code>
 +
| CPU from last ContextSwitch
 +
|-
 +
| <code>Priority:LongWord;</code>
 +
| Priority of the Thread (eg THREAD_PRIORITY_NORMAL)
 +
|-
 +
| <code>Affinity:LongWord;</code>
 +
| CPU Affinity mask of the Thread
 +
|-
 +
| <code>StackBase:Pointer;</code>
 +
| Base (Top) of the thread stack
 +
|-
 +
| <code>StackSize:LongWord;</code>
 +
| Stack length in bytes
 +
|-
 +
| <code>StackPointer:Pointer;</code>
 +
| Stack pointer from last ContextSwitch
 +
|-
 +
| <code>Name:array[0..THREAD_NAME_LENGTH - 1] of Char;</code>
 +
| The name of the Thread
 +
|-
 +
| <code>Parent:TThreadHandle;</code>
 +
| Handle of the parent thread
 +
|-
 +
| <code>ExitCode:LongWord;</code>
 +
| Thread Exit Code
 +
|-
 +
| <code>LastError:LongWord;</code>
 +
| Thread Last Error
 +
|-
 +
| <code>Locale:LCID;</code>
 +
| Thread Locale
 +
|-
 +
| <code>TargetCPU:LongWord;</code>
 +
| Target CPU of the Thread for next ContextSwitch
 +
|-
 +
| <code>TargetPriority:LongWord;</code>
 +
| Target Priority of the Thread for next ContextSwitch (eg THREAD_PRIORITY_NORMAL)
 +
|-
 +
| <code>CreateTime:Int64;</code>
 +
| The time when this thread was created
 +
|-
 +
| <code>ExitTime:Int64;</code>
 +
| The time when this thread exited or was terminated
 +
|-
 +
| <code>KernelTime:Int64;</code>
 +
| The total amount of time this thread has been in the running state (ie CPU time consumed)
 +
|-
 +
| <code>SwitchCount:Int64;</code>
 +
| The number of times this thread has been selected to run by a context switch
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Next:PThreadSnapshot;</code>
 +
| Next entry in Thread snapshot
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Messageslot entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMessageslotEntry = ^TMessageslotEntry;</code>
 +
 
 +
<code>TMessageslotEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Messageslot Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Messageslot Flags (eg MESSAGESLOT_FLAG_IRQ)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Messageslot Lock
 +
|-
 +
| <code>List:TListHandle;</code>
 +
| List of threads waiting on this Messageslot (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>Messages:TMessageList;</code>
 +
| Messageslot message queue
 +
|-
 +
| <code>Wait:TThreadWait;</code>
 +
| Wait function to call to wait on the Messageslot if there are no messages
 +
|-
 +
| <code>WaitEx:TThreadWaitEx;</code>
 +
| Wait function to call to wait with timeout on the Messageslot if there are no messages
 +
|-
 +
| <code>Release:TThreadRelease;</code>
 +
| Release function to call if any threads are waiting when a message is sent
 +
|-
 +
| <code>Abandon:TThreadAbandon;</code>
 +
| Abandon function to call if any threads are waiting when Messageslot is destroyed
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PMessageslotEntry;</code>
 +
| Previous entry in Messageslot table
 +
|-
 +
| <code>Next:PMessageslotEntry;</code>
 +
| Next entry in Messageslot table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 +
'''Mailslot entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PMailslotEntry = ^TMailslotEntry;</code>
 +
 
 +
<code>TMailslotEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Mailslot Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Maximum:LongWord;</code>
 +
| Maximum number of messages in Mailslot
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Current number of messages in Mailslot
 +
|-
 +
| <code>Start:LongWord;</code>
 +
| First message available in Mailslot
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Mailslot Lock
 +
|-
 +
| <code>Sender:TSemaphoreHandle;</code>
 +
| Mailslot send Semaphore
 +
|-
 +
| <code>Receiver:TSemaphoreHandle;</code>
 +
| Mailslot receive Semaphore
 +
|-
 +
| <code>Messages:PInteger;</code>
 +
| Mailslot message queue
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PMailslotEntry;</code>
 +
| Previous entry in Mailslot table
 +
|-
 +
| <code>Next:PMailslotEntry;</code>
 +
| Next entry in Mailslot table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Buffer entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PBufferEntry = ^TBufferEntry;</code>
 +
 
 +
<code>TBufferEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Buffer Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Size:LongWord;</code>
 +
| Size of each buffer
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Number of buffers
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Buffer Flags (eg BUFFER_FLAG_SHARED)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Buffer Lock
 +
|-
 +
| <code>Available:TSemaphoreHandle;</code>
 +
| Buffer available Semaphore
 +
|-
 +
| <code>Buffers:PBufferItem;</code>
 +
| Buffer list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PBufferEntry;</code>
 +
| Previous entry in Buffer table
 +
|-
 +
| <code>Next:PBufferEntry;</code>
 +
| Next entry in Buffer table
 +
|-
 +
| <code>First:PBufferItem;</code>
 +
| First available buffer item
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Buffer item'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PBufferItem = ^TBufferItem;</code>
 +
 
 +
<code>TBufferItem = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Parent:TBufferHandle;</code>
 +
| Handle of Buffer owning this item
 +
|-
 +
| <code>Next:PBufferItem;</code>
 +
| Next item in list
 +
|-
 +
| <code>Buffer:Pointer;</code>
 +
| Pointer to item data
 +
|-
 +
| <code>Reserved:LongWord;</code>
 +
| Align to 16 bytes
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Event entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PEventEntry = ^TEventEntry;</code>
 +
 
 +
<code>TEventEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Event Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the event (Signaled/Unsignaled)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Event Flags (eg EVENT_FLAG_MANUAL)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Event Lock
 +
|-
 +
| <code>List:TListHandle;</code>
 +
| List of threads waiting on this Event (or INVALID_HANDLE_VALUE if never used)
 +
|-
 +
| <code>Wait:TThreadWait;</code>
 +
| Wait function to call to wait on the Event if it is not Signaled
 +
|-
 +
| <code>WaitEx:TThreadWaitEx;</code>
 +
| Wait function to call to wait with timeout on the Event if it is not Signaled
 +
|-
 +
| <code>Release:TThreadRelease;</code>
 +
| Release function to call if any threads are waiting when Event is Signaled
 +
|-
 +
| <code>Abandon:TThreadAbandon;</code>
 +
| Abandon function to call if any threads are waiting when Event is destroyed
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Prev:PEventEntry;</code>
 +
| Previous entry in Event table
 +
|-
 +
| <code>Next:PEventEntry;</code>
 +
| Next entry in Event table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Timer list'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTimerList = ^TTimerList;</code>
 +
 
 +
<code>TTimerList = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''List Properties''
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of items currently in the Timer list
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Timer list Flags (eg LOCK_FLAG_IRQ)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Timer list Lock
 +
|-
 +
| <code>First:PTimerItem;</code>
 +
| First item in Timer list
 +
|-
 +
| <code>Last:PTimerItem;</code>
 +
| Last item in Timer list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Timer item'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTimerItem = ^TTimerItem;</code>
 +
 
 +
<code>TTimerItem = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Key:Integer;</code>
 +
| Ordering key for Timer list
 +
|-
 +
| <code>Timer:TTimerHandle;</code>
 +
| The timer referenced by this Timer list item
 +
|-
 +
| <code>Prev:PTimerItem;</code>
 +
| Previous item in Timer list
 +
|-
 +
| <code>Next:PTimerItem;</code>
 +
| Next item in Timer list
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Timer entry'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTimerEntry = ^TTimerEntry;</code>
 +
 
 +
<code>TTimerEntry = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Timer Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Interval:LongWord;</code>
 +
| Interval for timer (Milliseconds)
 +
|-
 +
| <code>State:LongWord;</code>
 +
| State of the timer (Enabled/Disabled)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Timer Flags (eg TIMER_FLAG_RESCHEDULE)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Timer Lock
 +
|-
 +
| <code>Event:TTimerEvent;</code>
 +
| Function to call when timer triggers
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| Data to pass to function when timer triggers
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>TimerList:PTimerList;</code>
 +
| The timer list this timer is currently in (or nil)
 +
|-
 +
| <code>TimerItem:TTimerItem;</code>
 +
| Timer list item for this timer when in a Timer list
 +
|-
 +
| <code>Prev:PTimerEntry;</code>
 +
| Previous entry in Timer table
 +
|-
 +
| <code>Next:PTimerEntry;</code>
 +
| Next entry in Timer table
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Worker request'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PWorkerRequest = ^TWorkerRequest;</code>
 +
 
 +
<code>TWorkerRequest = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''Worker Properties''
 +
|-
 +
| <code>Signature:LongWord;</code>
 +
| Signature for entry validation
 +
|-
 +
| <code>Interval:LongWord;</code>
 +
| Interval for worker (Milliseconds)
 +
|-
 +
| <code>Flags:LongWord;</code>
 +
| Worker Flags (eg WORKER_FLAG_RESCHEDULE)
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Worker Lock (or INVALID_HANDLE_VALUE if Interval is 0 and Flags is not WORKER_FLAG_RESCHEDULE)
 +
|-
 +
| <code>Timer:TTimerHandle;</code>
 +
| Worker Timer (or INVALID_HANDLE_VALUE if Interval is 0)
 +
|-
 +
| <code>Task:TWorkerTask;</code>
 +
| Task to call by worker
 +
|-
 +
| <code>Data:Pointer;</code>
 +
| Data to pass to task
 +
|-
 +
| <code>Callback:TWorkerCallback;</code>
 +
| Callback when task is completed
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''Tasker list'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTaskerList = ^TTaskerList;</code>
 +
 
 +
<code>TTaskerList = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
|colspan="2"|''List Properties''
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| Count of tasks currently in the Tasker list
 +
|-
 +
| <code>Lock:TSpinHandle;</code>
 +
| Tasker list Lock
 +
|-
 +
| <code>First:PTaskerTask;</code>
 +
| First task in Tasker list
 +
|-
 +
| <code>Last:PTaskerTask;</code>
 +
| Last task in Tasker list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|colspan="2"|''Statistics Properties''
 +
|-
 +
| &nbsp;
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Tasker task'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTaskerTask = ^TTaskerTask;</code>
 +
 
 +
<code>TTaskerTask = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Task:LongWord;</code>
 +
| The task to be performed
 +
|-
 +
| <code>Prev:PTaskerTask;</code>
 +
| Previous task in Tasker list
 +
|-
 +
| <code>Next:PTaskerTask;</code>
 +
| Next task in Tasker list
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Tasker thread send message'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTaskerThreadSendMessage = ^TTaskerThreadSendMessage;</code>
 +
 
 +
<code>TTaskerThreadSendMessage = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Task:LongWord;</code>
 +
| The task to be performed
 +
|-
 +
| <code>Prev:PTaskerTask;</code>
 +
| Previous task in Tasker list
 +
|-
 +
| <code>Next:PTaskerTask;</code>
 +
| Next task in Tasker list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Thread:TThreadHandle;</code>
 +
| Handle of the thread to send a message to
 +
|-
 +
| <code>Message:TMessage;</code>
 +
| Message to send to the thread
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''Tasker message slot send'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTaskerMessageslotSend = ^TTaskerMessageslotSend;</code>
 +
 
 +
<code>TTaskerMessageslotSend = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Task:LongWord;</code>
 +
| The task to be performed
 +
|-
 +
| <code>Prev:PTaskerTask;</code>
 +
| Previous task in Tasker list
 +
|-
 +
| <code>Next:PTaskerTask;</code>
 +
| Next task in Tasker list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Messageslot:TMessageslotHandle;</code>
 +
| Handle of the message slot to send to
 +
|-
 +
| <code>Message:TMessage;</code>
 +
| Message to be sent
 +
|-
 +
|}
 +
</div></div> 
 +
 +
'''Tasker semaphore signal'''
 +
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PTaskerSemaphoreSignal = ^TTaskerSemaphoreSignal;</code>
 +
 
 +
<code>TTaskerSemaphoreSignal = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>Task:LongWord;</code>
 +
| The task to be performed
 +
|-
 +
| <code>Prev:PTaskerTask;</code>
 +
| Previous task in Tasker list
 +
|-
 +
| <code>Next:PTaskerTask;</code>
 +
|  Next task in Tasker list
 +
|-
 +
|colspan="2"|''Internal Properties''
 +
|-
 +
| <code>Semaphore:TSemaphoreHandle;</code>
 +
| Handle of the semaphore to signal
 +
|-
 +
| <code>Count:LongWord;</code>
 +
| The count to be signalled
 +
|-
 +
|}
 +
</div></div>
 +
 
 +
'''Thread info'''
 +
 
 +
<div class="toccolours mw-collapsible mw-collapsed" style="border: 1; font-family: arial;">
 +
<code>PThreadInfo = ^TThreadInfo;</code>
 +
 
 +
<code>TThreadInfo = record</code>
 +
<div class="mw-collapsible-content" style="text-align: left; padding-left: 5px;">
 +
{| class="wikitable" style="font-size: 14px; background: white;"
 +
|-
 +
| <code>ThreadFunction:TThreadFunc;</code>
 +
| style="width: 50%;"|&nbsp;
 +
|-
 +
| <code>ThreadParameter:Pointer;</code>
 +
| &nbsp;
 +
|-
 +
| <code>StackLength:Cardinal;</code>
 +
| &nbsp;
 +
|-
 +
|}
 +
</div></div> 
 +
 
 +
'''CPU start'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TCPUStart = procedure(CPUID:LongWord);</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Primary initialization'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TPrimaryInit = procedure;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler initialization'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerInit = procedure;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler start'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerStart = procedure(CPUID:LongWord);</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Secondary initialization'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSecondaryInit = procedure;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Secondary boot'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSecondaryBoot = procedure(CPUID:LongWord);</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinLock = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin unlock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinUnlock = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin lock IRQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinLockIRQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin unlock IRQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinUnlockIRQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin lock FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinLockFIQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin unlock FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinUnlockFIQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin lock IRQ/FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinLockIRQFIQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin unlock IRQ/FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinUnlockIRQFIQ = function(Spin:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin check IRQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinCheckIRQ = function(Spin:PSpinEntry):Boolean;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin check FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinCheckFIQ = function(Spin:PSpinEntry):Boolean;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin exchange IRQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinExchangeIRQ = function(Spin1,Spin2:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin exchange FIQ'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinExchangeFIQ = function(Spin1,Spin2:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Spin mask exchange'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSpinMaskExchange = function(Spin1,Spin2:PSpinEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mutex lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMutexLock = function(Mutex:PMutexEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mutex unlock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMutexUnlock = function(Mutex:PMutexEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mutex try lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMutexTryLock = function(Mutex:PMutexEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Critical section lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TCriticalSectionLock = function(CriticalSection:PCriticalSectionEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Critical section lock ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TCriticalSectionLockEx = function(CriticalSection:PCriticalSectionEntry; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Critical section unlock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TCriticalSectionUnlock = function(CriticalSection:PCriticalSectionEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Critical section try lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TCriticalSectionTryLock = function(CriticalSection:PCriticalSectionEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Semaphore wait'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSemaphoreWait = function(Semaphore:PSemaphoreEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Semaphore wait ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSemaphoreWaitEx = function(Semaphore:PSemaphoreEntry; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Semaphore signal'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSemaphoreSignal = function(Semaphore:PSemaphoreEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Synchronizer lock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSynchronizerLock = function(Synchronizer:PSynchronizerEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Synchronizer lock ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSynchronizerLockEx = function(Synchronizer:PSynchronizerEntry; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Synchronizer unlock'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSynchronizerUnlock = function(Synchronizer:PSynchronizerEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Synchronizer convert'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSynchronizerConvert = function(Synchronizer:PSynchronizerEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Synchronizer convert ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSynchronizerConvertEx = function(Synchronizer:PSynchronizerEntry; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Messageslot send'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMessageslotSend = function(Messageslot:PMessageslotEntry; Message:PMessage):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Messageslot receive'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMessageslotReceive = function(Messageslot:PMessageslotEntry; Message:PMessage):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Messageslot receive ex'''
 +
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMessageslotReceiveEx = function(Messageslot:PMessageslotEntry; Message:PMessage; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mailslot send'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMailslotSend = function(Mailslot:PMailslotEntry; Data:Integer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mailslot send ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMailslotSendEx = function(Mailslot:PMailslotEntry; Data:Integer; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mailslot receive'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMailslotReceive = function(Mailslot:PMailslotEntry):Integer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Mailslot receive ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TMailslotReceiveEx = function(Mailslot:PMailslotEntry; Timeout:LongWord):Integer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Buffer get'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TBufferGet = function(Buffer:PBufferEntry):Pointer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Buffer get ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TBufferGetEx = function(Buffer:PBufferEntry; Timeout:LongWord):Pointer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Buffer free'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TBufferFree = function(Buffer:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Buffer iterate'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TBufferIterate = function(Buffer:PBufferEntry; Previous:Pointer):Pointer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Event wait'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TEventWait = function(Event:PEventEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Event wait ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TEventWaitEx = function(Event:PEventEntry; Timeout:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Event set'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TEventSet = function(Event:PEventEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Event reset'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TEventReset = function(Event:PEventEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Event pulse'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TEventPulse = function(Event:PEventEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 +
'''Timer enable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTimerEnable = function(Timer:PTimerEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Timer enable ex'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTimerEnableEx = function(Timer:PTimerEntry; Interval:LongWord; Event:TTimerEvent; Data:Pointer):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Timer disable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTimerDisable = function(Timer:PTimerEntry):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Timer check'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTimerCheck = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''TImer trigger'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTimerTrigger = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Tasker check'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTaskerCheck = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Tasker trigger'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TTaskerTrigger = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Thread get current'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TThreadGetCurrent = function:TThreadHandle;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Thread set current'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TThreadSetCurrent = function(Thread:TThreadHandle):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Thread start'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TThreadStart = function(Parameter:Pointer):PtrInt;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Thread end'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TThreadEnd = procedure(ExitCode:LongWord);</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler check'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerCheck = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler wakeup'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerWakeup = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler expire'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerExpire = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler switch'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerSwitch = function(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler select'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerSelect = function(CPUID:LongWord; Thread:TThreadHandle; Yield:Boolean):TThreadHandle;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler reschedule'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerReschedule = function (Yield:Boolean):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler migration enable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerMigrationEnable = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler migration disable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerMigrationDisable = function:LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler preempt enable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerPreemptEnable = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler preempt disable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerPreemptDisable = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler allocation enable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerAllocationEnable = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Scheduler allocation disable'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TSchedulerAllocationDisable = function(CPUID:LongWord):LongWord;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
 
 +
'''Thread setup stack'''
 +
 
 +
{| class="wikitable" style="font-size: 14px; text-align: left; width: 100%; height: 50px;"
 +
|-
 +
| <code>TThreadSetupStack = function(StackBase:Pointer; StartProc:TThreadStart; ReturnProc:TThreadEnd; Parameter:Pointer):Pointer;</code>
 +
| style="width: 40%;"|
 +
|-
 +
|}
 +
<br />
  
 
=== Public variables ===
 
=== Public variables ===

Revision as of 01:25, 26 January 2017

Return to Unit Reference


Description


Ultibo Threads interface unit

Locking Primitives

Spin -

A simple spin lock for fast mutually exclusive access to data. Threads "spin" while waiting to acquire the lock and do not yield the CPU unless pre-empted.

Non recursive (can only be acquired once by the same thread)

Includes IRQ/FIQ entry and exit routines to Save/Restore the IRQ/FIQ state.

Suitable for use by Interrupt handlers if non interrupt callers use the IRQ/FIQ entry and exit routines to Lock and Unlock.

Suitable for use on multiprocessor systems if the lock is allocated from shared memory (Determined during initialization).

Not recommended for long held operations or holding during I/O operations.

Access is not serialized, the next thread to try obtaining the lock when it is released will succeed even if that thread was not the first waiting.

Usage:

Create/Destroy

Spin locks are created using SpinCreate() and destroyed using SpinDestroy(), these functions should not be called from within an Interrupt handler. Lock/Unlock (Data accessed only by threads)

To synchronize data access between threads each thread should call SpinLock() before accessing the data and SpinUnlock() when finished accessing the data. These calls do not affect the state of IRQs or FIQs and therefore do not impact interrupt latency. Lock/Unlock (Data accessed by threads and interrupt handlers)

To use a Spin lock to synchronise data access between threads and an interrupt handler each thread should call SpinLockIRQ() or SpinLockFIQ(), depending on whether the interrupt handler is servicing IRQ or FIQ requests, before accessing the data and SpinUnlockIRQ() or SpinUnlockFIQ() when finished accessing the data. These calls disable interrupts before acquiring the lock (with deadlock protection) and restore interrupts after releaseing the lock and therefore should only be used to protect very short sections of code accessing shared data to minimize the impact on interrupt latency.

Interrupt handlers should call SpinLock() before accessing the data and SpinUnlock() when finished accessing the data. In a Uniprocessor system it is technically not necessary for interrupt handlers to call lock/unlock as the use of IRQ/FIQ disable/enable will prevent interrupt handlers from executing while a thread has the lock. On a Multiprocessor system however interrupt handlers can execute on one processor while a thread is executing on another (which will not deadlock), to correctly synchronize data access both threads and interrupt handlers should call the appropriate lock/unlock before and after access to the data.

Lock Hierachy -

It is safe to acquire one lock using SpinLock() then another lock using SpinLock() and then release them in reverse order.

It is also safe to acquire one lock using SpinLock() then another lock using SpinLockIRQ(or FIQ)() and then release them in reverse order.

It is NOT safe to acquire one lock using SpinLockIRQ(or FIQ)() then another lock using SpinLock() and then release them in reverse order. This is because the first SpinLockIRQ(or FIQ)() can disable the scheduling and prevent thread preemption. If another thread is already holding the second lock then this sequence will deadlock (except on a multicore system where the other thread is running on a different CPU).

It is also safe to acquire one lock using SpinLockIRQ(or FIQ)() then another lock using SpinLockIRQ(or FIQ)() and then release them in reverse order. In this case you must ensure that any thread aquiring the second lock also calls SpinLockIRQ(or FIQ)() to thereby avoid the deadlock.

It is NOT safe to acquire one lock using SpinLockIRQ(or FIQ)() then another lock using SpinLockIRQ(or FIQ)() and then release them in the SAME order. If the situation absolutely requires this behavious then you must use SpinExchangeIRQ(or FIQ)() when holding both locks in order to reverse the order of the IRQ or FIQ renabling.

Mutex -

A mutually exclusive lock for controlling access to data. Threads yield while waiting to acquire the lock.

Non recursive (can only be acquired once by the same thread) (Recursive if MUTEX_FLAG_RECURSIVE specified)

Not suitable for use by Interrupt handlers.

Suitable for use on multiprocessor systems if the lock is allocated from shared memory (Determined during initialization).

Recommended for long held operations or holding during I/O operations.

Access is not serialized, the next thread to try obtaining the lock when it is released will succeed even if that thread was not the first waiting.

CriticalSection -

A mutually exlusive lock for serializing access to data. Threads are placed on a wait list while waiting to acquire the lock.

Recursive (can be acquired multiple times by the same thread)

Not suitable for use by Interrupt handlers.

Suitable for use on multiprocessor systems.

Recommended for long held operations or holding during I/O operations.

Access is serialized, the next thread to obtain the lock when it is released will be the thread that has been waiting longest.

Semaphore -

Suitable for use by Interrupt handlers for signaling only if created with SEMAPHORE_FLAG_IRQ or FIQ (Interrupt handlers must not call wait).

Suitable for use on multiprocessor systems.

Access is serialized, the next thread to acquire the semaphore when it is signaled will be the thread that has been waiting longest.

Synchronizer -

A reader/writer lock for serializing multiple concurrent reads and single writes to data. Threads are placed on a wait list while waiting to acquire the lock.

Recursive (reader lock can be acquired multiple times by the same thread or by other threads / writer lock can be acquired multiple times by the same thread) Not suitable for use by Interrupt handlers.

Suitable for use on multiprocessor systems.

Recommended for long held operations or holding during I/O operations.

Access is serialized, the next thread to obtain the lock when it is released will be the thread that has been waiting longest.

Constants



[Expand]
Lock constants LOCK_FLAG_*


[Expand]
Spin constants SPIN_*


[Expand]
Spin state constants SPIN_STATE_*


[Expand]
Mutex constants MUTEX_*


[Expand]
Mutex state constants MUTEX_STATE_*


[Expand]
Mutex flags constants MUTEX_FLAG_*


[Expand]
Critical section constants CRITICAL_SECTION_*


[Expand]
Critical section state constants CRITICAL_SECTION_STATE_*


[Expand]
Semaphore constants SEMAPHORE_*


[Expand]
Semaphore flag constants SEMAPHORE_FLAG_*


[Expand]
Synchronizer constants SYNCHRONIZER_*


[Expand]
Synchronizer state constants SYNCHRONIZER_STATE_*


[Expand]
Synchronizer flag constants SYNCHRONIZER_FLAG_*


[Expand]
List constants LIST_*


[Expand]
List type constants LIST_TYPE_*


[Expand]
List flag constants LIST_FLAG_*


[Expand]
Queue constants QUEUE_*


[Expand]
Queue type constants QUEUE_TYPE_*


[Expand]
Queue flag constants QUEUE_FLAG_*


[Expand]
Queue key constants QUEUE_KEY_*


[Expand]
Thread constants THREAD_*


[Expand]
Thread type constants THREAD_TYPE_*


[Expand]
Thread state constants THREAD_STATE_*


[Expand]
Thread priority constants THREAD_PRIORITY_*


[Expand]
Thread name constants THREAD_NAME_*


[Expand]
Thread priority constants *_THREAD_PRIORITY


[Expand]
Thread create constants THREAD_CREATE_*


[Expand]
Thread TLS constants THREAD_TLS_*


[Expand]
Thread TLS flag constants THREAD_TLS_FLAG_*


[Expand]
Thread wait constants THREAD_LISTS_*


[Expand]
Messageslot constants MESSAGESLOT_*


[Expand]
Messageslot flag constants MESSAGESLOT_FLAG_*


[Expand]
Mailslot constants MAILSLOT_*


[Expand]
Buffer constants BUFFER_*


[Expand]
Buffer flag constants BUFFER_FLAG_*


[Expand]
Event constants EVENT_*


[Expand]
Event state constants EVENT_STATE_*


[Expand]
Event flag constants EVENT_FLAG_*


[Expand]
Timer constants TIMER_*


[Expand]
Timer state constants TIMER_STATE_*


[Expand]
Timer flag constants TIMER_FLAG_*


[Expand]
Timer key constants TIMER_KEY_*


[Expand]
Worker constants WORKER_*


[Expand]
Worker flag constants WORKER_FLAG_*


[Expand]
Tasker task constants TASKER_TASK_*


[Expand]
Scheduler migration constants SCHEDULER_MIGRATION_*


[Expand]
Scheduler preempt constants SCHEDULER_PREEMPT_*


[Expand]
Scheduler allocation constants SCHEDULER_ALLOCATION_*


[Expand]
Scheduler mask constants SCHEDULER_MASK_*


[Expand]
Scheduler quantum constants SCHEDULER_QUANTUM_*


[Expand]
Thread logging constants THREAD_LOG_*


Type definitions



Spin entry

[Expand]

PSpinEntry = ^TSpinEntry;

TSpinEntry = record

Mutex entry

[Expand]

PMutexEntry = ^TMutexEntry;

TMutexEntry = record

Critical section entry

[Expand]

PCriticalSectionEntry = ^TCriticalSectionEntry;

TCriticalSectionEntry = record

Semaphore entry

[Expand]

PSemaphoreEntry = ^TSemaphoreEntry;

TSemaphoreEntry = record

Synchronizer entry

[Expand]

PSynchronizerEntry = ^TSynchronizerEntry;

TSynchronizerEntry = record

List entry

[Expand]

PListEntry = ^TListEntry;

TListEntry = record

List element

[Expand]

PListElement = ^TListElement;

TListElement = record

List handles

[Expand]

PListHandles = ^TListHandles;

TListHandles = array[0..THREAD_LISTS_MAXIMUM - 1] of TListHandle;

Queue entry

[Expand]

PQueueEntry = ^TQueueEntry;

TQueueEntry = record

Queue element

[Expand]

PQueueElement = ^TQueueElement;

TQueueElement = record

Message list

[Expand]

PMessageList = ^TMessageList;

TMessageList = record

Message

[Expand]

PMessage = ^TMessage;

TMessage = record

Thread entry

[Expand]

PThreadEntry = ^TThreadEntry;

TThreadEntry = record

Thread snapshot

[Expand]

PThreadSnapshot = ^TThreadSnapshot;

TThreadSnapshot = record

Messageslot entry

[Expand]

PMessageslotEntry = ^TMessageslotEntry;

TMessageslotEntry = record

Mailslot entry

[Expand]

PMailslotEntry = ^TMailslotEntry;

TMailslotEntry = record

Buffer entry

[Expand]

PBufferEntry = ^TBufferEntry;

TBufferEntry = record

Buffer item

[Expand]

PBufferItem = ^TBufferItem;

TBufferItem = record

Event entry

[Expand]

PEventEntry = ^TEventEntry;

TEventEntry = record

Timer list

[Expand]

PTimerList = ^TTimerList;

TTimerList = record

Timer item

[Expand]

PTimerItem = ^TTimerItem;

TTimerItem = record

Timer entry

[Expand]

PTimerEntry = ^TTimerEntry;

TTimerEntry = record

Worker request

[Expand]

PWorkerRequest = ^TWorkerRequest;

TWorkerRequest = record

Tasker list

[Expand]

PTaskerList = ^TTaskerList;

TTaskerList = record

Tasker task

[Expand]

PTaskerTask = ^TTaskerTask;

TTaskerTask = record

Tasker thread send message

[Expand]

PTaskerThreadSendMessage = ^TTaskerThreadSendMessage;

TTaskerThreadSendMessage = record

Tasker message slot send

[Expand]

PTaskerMessageslotSend = ^TTaskerMessageslotSend;

TTaskerMessageslotSend = record

Tasker semaphore signal

[Expand]

PTaskerSemaphoreSignal = ^TTaskerSemaphoreSignal;

TTaskerSemaphoreSignal = record

Thread info

[Expand]

PThreadInfo = ^TThreadInfo;

TThreadInfo = record

CPU start

TCPUStart = procedure(CPUID:LongWord);

Primary initialization

TPrimaryInit = procedure;

Scheduler initialization

TSchedulerInit = procedure;

Scheduler start

TSchedulerStart = procedure(CPUID:LongWord);

Secondary initialization

TSecondaryInit = procedure;

Secondary boot

TSecondaryBoot = procedure(CPUID:LongWord);

Spin lock

TSpinLock = function(Spin:PSpinEntry):LongWord;

Spin unlock

TSpinUnlock = function(Spin:PSpinEntry):LongWord;

Spin lock IRQ

TSpinLockIRQ = function(Spin:PSpinEntry):LongWord;

Spin unlock IRQ

TSpinUnlockIRQ = function(Spin:PSpinEntry):LongWord;

Spin lock FIQ

TSpinLockFIQ = function(Spin:PSpinEntry):LongWord;

Spin unlock FIQ

TSpinUnlockFIQ = function(Spin:PSpinEntry):LongWord;

Spin lock IRQ/FIQ

TSpinLockIRQFIQ = function(Spin:PSpinEntry):LongWord;

Spin unlock IRQ/FIQ

TSpinUnlockIRQFIQ = function(Spin:PSpinEntry):LongWord;

Spin check IRQ

TSpinCheckIRQ = function(Spin:PSpinEntry):Boolean;

Spin check FIQ

TSpinCheckFIQ = function(Spin:PSpinEntry):Boolean;

Spin exchange IRQ

TSpinExchangeIRQ = function(Spin1,Spin2:PSpinEntry):LongWord;

Spin exchange FIQ

TSpinExchangeFIQ = function(Spin1,Spin2:PSpinEntry):LongWord;

Spin mask exchange

TSpinMaskExchange = function(Spin1,Spin2:PSpinEntry):LongWord;

Mutex lock

TMutexLock = function(Mutex:PMutexEntry):LongWord;

Mutex unlock

TMutexUnlock = function(Mutex:PMutexEntry):LongWord;

Mutex try lock

TMutexTryLock = function(Mutex:PMutexEntry):LongWord;

Critical section lock

TCriticalSectionLock = function(CriticalSection:PCriticalSectionEntry):LongWord;

Critical section lock ex

TCriticalSectionLockEx = function(CriticalSection:PCriticalSectionEntry; Timeout:LongWord):LongWord;

Critical section unlock

TCriticalSectionUnlock = function(CriticalSection:PCriticalSectionEntry):LongWord;

Critical section try lock

TCriticalSectionTryLock = function(CriticalSection:PCriticalSectionEntry):LongWord;

Semaphore wait

TSemaphoreWait = function(Semaphore:PSemaphoreEntry):LongWord;

Semaphore wait ex

TSemaphoreWaitEx = function(Semaphore:PSemaphoreEntry; Timeout:LongWord):LongWord;

Semaphore signal

TSemaphoreSignal = function(Semaphore:PSemaphoreEntry):LongWord;

Synchronizer lock

TSynchronizerLock = function(Synchronizer:PSynchronizerEntry):LongWord;

Synchronizer lock ex

TSynchronizerLockEx = function(Synchronizer:PSynchronizerEntry; Timeout:LongWord):LongWord;

Synchronizer unlock

TSynchronizerUnlock = function(Synchronizer:PSynchronizerEntry):LongWord;

Synchronizer convert

TSynchronizerConvert = function(Synchronizer:PSynchronizerEntry):LongWord;

Synchronizer convert ex

TSynchronizerConvertEx = function(Synchronizer:PSynchronizerEntry; Timeout:LongWord):LongWord;

Messageslot send

TMessageslotSend = function(Messageslot:PMessageslotEntry; Message:PMessage):LongWord;

Messageslot receive

TMessageslotReceive = function(Messageslot:PMessageslotEntry; Message:PMessage):LongWord;

Messageslot receive ex

TMessageslotReceiveEx = function(Messageslot:PMessageslotEntry; Message:PMessage; Timeout:LongWord):LongWord;

Mailslot send

TMailslotSend = function(Mailslot:PMailslotEntry; Data:Integer):LongWord;

Mailslot send ex

TMailslotSendEx = function(Mailslot:PMailslotEntry; Data:Integer; Timeout:LongWord):LongWord;

Mailslot receive

TMailslotReceive = function(Mailslot:PMailslotEntry):Integer;

Mailslot receive ex

TMailslotReceiveEx = function(Mailslot:PMailslotEntry; Timeout:LongWord):Integer;

Buffer get

TBufferGet = function(Buffer:PBufferEntry):Pointer;

Buffer get ex

TBufferGetEx = function(Buffer:PBufferEntry; Timeout:LongWord):Pointer;

Buffer free

TBufferFree = function(Buffer:Pointer):LongWord;

Buffer iterate

TBufferIterate = function(Buffer:PBufferEntry; Previous:Pointer):Pointer;

Event wait

TEventWait = function(Event:PEventEntry):LongWord;

Event wait ex

TEventWaitEx = function(Event:PEventEntry; Timeout:LongWord):LongWord;

Event set

TEventSet = function(Event:PEventEntry):LongWord;

Event reset

TEventReset = function(Event:PEventEntry):LongWord;

Event pulse

TEventPulse = function(Event:PEventEntry):LongWord;

Timer enable

TTimerEnable = function(Timer:PTimerEntry):LongWord;

Timer enable ex

TTimerEnableEx = function(Timer:PTimerEntry; Interval:LongWord; Event:TTimerEvent; Data:Pointer):LongWord;

Timer disable

TTimerDisable = function(Timer:PTimerEntry):LongWord;

Timer check

TTimerCheck = function:LongWord;

TImer trigger

TTimerTrigger = function:LongWord;

Tasker check

TTaskerCheck = function:LongWord;

Tasker trigger

TTaskerTrigger = function:LongWord;

Thread get current

TThreadGetCurrent = function:TThreadHandle;

Thread set current

TThreadSetCurrent = function(Thread:TThreadHandle):LongWord;

Thread start

TThreadStart = function(Parameter:Pointer):PtrInt;

Thread end

TThreadEnd = procedure(ExitCode:LongWord);

Scheduler check

TSchedulerCheck = function(CPUID:LongWord):LongWord;

Scheduler wakeup

TSchedulerWakeup = function(CPUID:LongWord):LongWord;

Scheduler expire

TSchedulerExpire = function(CPUID:LongWord):LongWord;

Scheduler switch

TSchedulerSwitch = function(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;

Scheduler select

TSchedulerSelect = function(CPUID:LongWord; Thread:TThreadHandle; Yield:Boolean):TThreadHandle;

Scheduler reschedule

TSchedulerReschedule = function (Yield:Boolean):LongWord;

Scheduler migration enable

TSchedulerMigrationEnable = function:LongWord;

Scheduler migration disable

TSchedulerMigrationDisable = function:LongWord;

Scheduler preempt enable

TSchedulerPreemptEnable = function(CPUID:LongWord):LongWord;

Scheduler preempt disable

TSchedulerPreemptDisable = function(CPUID:LongWord):LongWord;

Scheduler allocation enable

TSchedulerAllocationEnable = function(CPUID:LongWord):LongWord;

Scheduler allocation disable

TSchedulerAllocationDisable = function(CPUID:LongWord):LongWord;

Thread setup stack

TThreadSetupStack = function(StackBase:Pointer; StartProc:TThreadStart; ReturnProc:TThreadEnd; Parameter:Pointer):Pointer;


Public variables



Thread logging

THREAD_DEFAULT_LOG_LEVEL:LongWord = THREAD_LOG_LEVEL_DEBUG; Minimum level for Thread messages. Only messages with level greater than or equal to this will be printed.
THREAD_LOG_ENABLED:Boolean;

Scheduler variables

SchedulerThreadNext:LongWord; The CPU to assign the next created thread to, round robin incremented on each create (Protected by ThreadTableLock)
SchedulerThreadMigration:LongWord; Enable or Disable thread migration (SCHEDULER_MIGRATION_DISABLED or SCHEDULER_MIGRATION_ENABLED
SchedulerMigrationQuantum:LongWord; Quantum for thread migration checks (CPU 0 only)
SchedulerThreadCount:array of LongWord; Current number of ready threads per CPU (One per CPU, allocated by scheduler initialization) (Protected by InterlockedIncrement/Decrement)
SchedulerThreadQuantum:array of LongWord; Quantum of current thread per CPU (One per CPU, allocated by scheduler initialization)
SchedulerThreadPreempt:array of LongWord; Current state of thread preemption per CPU (eg SCHEDULER_PREEMPT_DISABLED) (One per CPU, allocated by scheduler initialization)
SchedulerThreadAllocation:array of LongWord; Current state of thread allocation per CPU (eg SCHEDULER_ALLOCATION_DISABLED) (One per CPU, allocated by scheduler initialization)
SchedulerPriorityMask:array of LongWord; Mask of ready threads at each priority level (One per CPU, allocated by scheduler initialization) (Protected by InterlockedOr/And)
SchedulerYieldCurrent:array of LongBool; Scheduler yield to current priority level status (One per CPU, allocated by scheduler initialization)
SchedulerStarvationNext:array of LongWord; Scheduler starvation priority round robin (One per CPU, allocated by scheduler initialization)
SchedulerStarvationQuantum:array of LongWord; Quantum for thread starvation checks per CPU (One per CPU, allocated by scheduler initialization)
SchedulerNoneQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level none (One per CPU, allocated by scheduler initialization)
SchedulerIdleQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level idle (One per CPU, allocated by scheduler initialization)
SchedulerLowestQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level lowest (One per CPU, allocated by scheduler initialization)
SchedulerLowerQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level lower (One per CPU, allocated by scheduler initialization)
SchedulerNormalQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level normal (One per CPU, allocated by scheduler initialization)
SchedulerHigherQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level higher (One per CPU, allocated by scheduler initialization)
SchedulerHighestQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level highest (One per CPU, allocated by scheduler initialization)
SchedulerCriticalQueue:array of TQueueHandle; Queue of threads that are ready to run at priority level critical (One per CPU, allocated by scheduler initialization)
SchedulerSleepQueue:array of TQueueHandle; Queue of threads that are currently sleeping (One per CPU, allocated by scheduler initialization)
SchedulerTimeoutQueue:array of TQueueHandle; Queue of threads that are currently waiting with a timeout (One per CPU, allocated by scheduler initialization)
SchedulerTerminationQueue:array of TQueueHandle; Queue of threads that have been terminated (One per CPU, allocated by scheduler initialization)
SchedulerLast:array of LongWord; The timer value of the last scheduler interrupt (One per CPU, allocated by scheduler initialization)
SchedulerInterrupts:array of LongWord; Current number of scheduler interrupts per CPU (When this reaches SCHEDULER_INTERRUPTS_PER_SECOND then UtilizationLast is updated and UtilizationCurrent is reset) (One per CPU, allocated by scheduler initialization)

Heap manager variables

HeapLock:THeapLock;

RTL thread manager variables

ThreadVarBlockSize:DWORD;

Inititalization handlers

PrimaryInitHandler:TPrimaryInit;
SchedulerInitHandler:TSchedulerInit;
SchedulerStartHandler:TSchedulerStart;
SecondaryInitHandler:TSecondaryInit;
SecondaryBootHandler:TSecondaryBoot;

SpinLock/Unlock handlers

SpinLockHandler:TSpinLock;
SpinUnlockHandler:TSpinUnlock;
SpinLockIRQHandler:TSpinLockIRQ;
SpinUnlockIRQHandler:TSpinUnlockIRQ;
SpinLockFIQHandler:TSpinLockFIQ;
SpinUnlockFIQHandler:TSpinUnlockFIQ;
SpinLockIRQFIQHandler:TSpinLockIRQFIQ;
SpinUnlockIRQFIQHandler:TSpinUnlockIRQFIQ;
SpinCheckIRQHandler:TSpinCheckIRQ;
SpinCheckFIQHandler:TSpinCheckFIQ;
SpinExchangeIRQHandler:TSpinExchangeIRQ;
SpinExchangeFIQHandler:TSpinExchangeFIQ;
SpinMaskExchangeHandler:TSpinMaskExchange;

MutexLock/Unlock handlers

MutexLockHandler:TMutexLock;
MutexUnlockHandler:TMutexUnlock;
MutexTryLockHandler:TMutexTryLock;

CriticalSection Lock/Unlock/TryLock handlers

CriticalSectionLockHandler:TCriticalSectionLock;
CriticalSectionLockExHandler:TCriticalSectionLockEx;
CriticalSectionUnlockHandler:TCriticalSectionUnlock;
CriticalSectionTryLockHandler:TCriticalSectionTryLock;

Semaphore Wait/Signal handlers

SemaphoreWaitHandler:TSemaphoreWait;
SemaphoreWaitExHandler:TSemaphoreWaitEx;
SemaphoreSignalHandler:TSemaphoreSignal;

Synchronizer Reader/WriterLock/Unlock handlers

SynchronizerReaderLockHandler:TSynchronizerLock;
SynchronizerWriterLockHandler:TSynchronizerLock;
SynchronizerReaderLockExHandler:TSynchronizerLockEx;
SynchronizerWriterLockExHandler:TSynchronizerLockEx;
SynchronizerReaderUnlockHandler:TSynchronizerUnlock;
SynchronizerWriterUnlockHandler:TSynchronizerUnlock;
SynchronizerReaderConvertHandler:TSynchronizerConvert;
SynchronizerWriterConvertHandler:TSynchronizerConvert;
SynchronizerReaderConvertExHandler:TSynchronizerConvertEx;

Messageslot Send/Receive handlers

MessageslotSendHandler:TMessageslotSend;
MessageslotReceiveHandler:TMessageslotReceive;
MessageslotReceiveExHandler:TMessageslotReceiveEx;

Mailslot Send/Receive handlers

MailslotSendHandler:TMailslotSend;
MailslotSendExHandler:TMailslotSendEx;
MailslotReceiveHandler:TMailslotReceive;
MailslotReceiveExHandler:TMailslotReceiveEx;

Buffer Get/GetEx/Free handlers

BufferGetHandler:TBufferGet;
BufferGetExHandler:TBufferGetEx;
BufferFreeHandler:TBufferFree;
BufferIterateHandler:TBufferIterate;

Event Wait/Set/Reset/Pulse handlers

EventWaitHandler:TEventWait;
EventWaitExHandler:TEventWaitEx;
EventSetHandler:TEventSet;
EventResetHandler:TEventReset;
EventPulseHandler:TEventPulse;

Timer Enable/Disable/Check/Trigger handlers

TimerEnableHandler:TTimerEnable;
TimerEnableExHandler:TTimerEnableEx;
TimerDisableHandler:TTimerDisable;
TimerCheckHandler:TTimerCheck;
TimerTriggerHandler:TTimerTrigger;

Tasker Check/Trigger handlers

TaskerCheckHandler:TTaskerCheck;
TaskerTriggerHandler:TTaskerTrigger;

Thread Get/SetCurrent handlers

ThreadGetCurrentHandler:TThreadGetCurrent;
ThreadSetCurrentHandler:TThreadSetCurrent;

Scheduler Check/Wakeup/Expire/Select/Switch handlers

SchedulerCheckHandler:TSchedulerCheck;
SchedulerWakeupHandler:TSchedulerWakeup;
SchedulerExpireHandler:TSchedulerExpire;
SchedulerSwitchHandler:TSchedulerSwitch;
SchedulerSelectHandler:TSchedulerSelect;
SchedulerRescheduleHandler:TSchedulerReschedule;
SchedulerMigrationEnableHandler:TSchedulerMigrationEnable;
SchedulerMigrationDisableHandler:TSchedulerMigrationDisable;
SchedulerPreemptEnableHandler:TSchedulerPreemptEnable;
SchedulerPreemptDisableHandler:TSchedulerPreemptDisable;
SchedulerAllocationEnableHandler:TSchedulerAllocationEnable;
SchedulerAllocationDisableHandler:TSchedulerAllocationDisable;

Thread SetupStack handlers

ThreadSetupStackHandler:TThreadSetupStack;


Function declarations



Initialization functions

[Expand]
procedure LocksInit;
Description: Initialize Locks


[Expand]
procedure ThreadsInit;
Description: Initialize Threading


[Expand]
procedure PrimaryInit;
Description: Initialize the primary CPU


[Expand]
procedure SchedulerInit;
Description: Initialize the thread scheduler


[Expand]
procedure SchedulerStart(CPUID:LongWord);
Description: Initialize the thread scheduler for secondary CPUs (Where Applicable)


[Expand]
procedure SecondaryInit;
Description: Initialize the secondary CPUs (Where Applicable)


[Expand]
procedure SecondaryBoot(CPUID:LongWord);
Description: Boot the specified secondary CPU (Where Applicable)


[Expand]
procedure SecondaryStart(CPUID:LongWord);
Description: Startup procedure for secondary CPUs (Where Applicable)


[Expand]
function IRQExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function FIQExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function SWIExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function IdleExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function MainExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function TimerExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function WorkerExecute(Parameter:Pointer):PtrInt;
Description: To be documented


[Expand]
function IdleCalibrate:LongWord;
Description: Calibrate the idle thread loop by counting the number of loops in 100ms


Spin functions

[Expand]
function SpinCreate:TSpinHandle; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Create and insert a new Spin entry


[Expand]
function SpinCreateEx(InitialOwner:Boolean):TSpinHandle;
Description: Create and insert a new Spin entry


[Expand]
function SpinDestroy(Spin:TSpinHandle):LongWord;
Description: Destroy and remove an existing Spin entry


[Expand]
function SpinOwner(Spin:TSpinHandle):TThreadHandle;
Description: Get the current owner of an existing Spin entry


[Expand]
function SpinLock(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Lock an existing Spin entry


[Expand]
function SpinUnlock(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Unlock an existing Spin entry


[Expand]
function SpinLockIRQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Lock an existing Spin entry, disable IRQ and save the previous IRQ state


[Expand]
function SpinUnlockIRQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Unlock an existing Spin entry and restore the previous IRQ state


[Expand]
function SpinLockFIQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Lock an existing Spin entry, disable FIQ and save the previous FIQ state


[Expand]
function SpinUnlockFIQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Unlock an existing Spin entry and restore the previous FIQ state


[Expand]
function SpinLockIRQFIQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Lock an existing Spin entry, disable IRQ and FIQ and save the previous IRQ and FIQ state


[Expand]
function SpinUnlockIRQFIQ(Spin:TSpinHandle):LongWord; {$IFDEF SPIN_INLINE}inline; {$ENDIF}
Description: Unlock an existing Spin entry and restore the previous IRQ and FIQ state


[Expand]
function SpinCheckIRQ(Spin:TSpinHandle):Boolean;
Description: Check the mask that stores the previous IRQ state to determine if IRQ is enabled


[Expand]
function SpinCheckFIQ(Spin:TSpinHandle):Boolean;
Description: Check the mask that stores the previous FIQ state to determine if FIQ is enabled


[Expand]
function SpinExchangeIRQ(Spin1,Spin2:TSpinHandle):LongWord;
Description: Exchange the previous IRQ state between two Spin entries


[Expand]
function SpinExchangeFIQ(Spin1,Spin2:TSpinHandle):LongWord;
Description: Exchange the previous FIQ state between two Spin entries


[Expand]
function SpinLockDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinLock function used if no handler is registered


[Expand]
function SpinUnlockDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinUnlock function used if no handler is registered


[Expand]
function SpinLockIRQDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinLockIRQ function used if no handler is registered


[Expand]
function SpinUnlockIRQDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinUnlockIRQ function used if no handler is registered


[Expand]
function SpinLockFIQDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinLockFIQ function used if no handler is registered


[Expand]
function SpinUnlockFIQDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinUnlockFIQ function used if no handler is registered


[Expand]
function SpinLockIRQFIQDefault(SpinEntry:PSpinEntry):LongWord;
Description: Default version of SpinLockIRQFIQ function used if no handler is registered


Mutex functions

[Expand]
function MutexCreate:TMutexHandle; {$IFDEF MUTEX_INLINE}inline; {$ENDIF}
Description: Create and insert a new Mutex entry


[Expand]
function MutexCreateEx(InitialOwner:Boolean; SpinCount:LongWord; Flags:LongWord):TMutexHandle;
Description: Create and insert a new Mutex entry


[Expand]
function MutexDestroy(Mutex:TMutexHandle):LongWord;
Description: Destroy and remove an existing Mutex entry


[Expand]
function MutexFlags(Mutex:TMutexHandle):LongWord;
Description: Get the current flags of an existing Mutex entry


[Expand]
function MutexLock(Mutex:TMutexHandle):LongWord; {$IFDEF MUTEX_INLINE}inline; {$ENDIF}
Description: Lock an existing Mutex entry


[Expand]
function MutexUnlock(Mutex:TMutexHandle):LongWord; {$IFDEF MUTEX_INLINE}inline; {$ENDIF}
Description: Unlock an existing Mutex entry


[Expand]
function MutexTryLock(Mutex:TMutexHandle):LongWord; {$IFDEF MUTEX_INLINE}inline; {$ENDIF}
Description: Try to lock an existing Mutex entry. If the Mutex is not locked then lock it and mark the owner as the current thread. If the Mutex is already locked then return immediately with an error and do not wait for it to be unlocked.


[Expand]
function MutexCount(Mutex:TMutexHandle):LongWord;
Description: Get the current lock count of an existing Mutex entry


[Expand]
function MutexOwner(Mutex:TMutexHandle):TThreadHandle;
Description: Get the current owner of an existing Mutex entry


[Expand]
function MutexLockDefault(MutexEntry:PMutexEntry):LongWord;
Description: Default version of MutexLock function used if no handler is registered


[Expand]
function MutexUnlockDefault(MutexEntry:PMutexEntry):LongWord;
Description: Default version of MutexUnlock function used if no handler is registered


[Expand]
function MutexTryLockDefault(MutexEntry:PMutexEntry):LongWord;
Description: Default version of MutexTryLock function used if no handler is registered


Critical section functions

[Expand]
function CriticalSectionCreate:TCriticalSectionHandle;
Description: Create and insert a new CriticalSection entry


[Expand]
function CriticalSectionCreateEx(InitialOwner:Boolean; SpinCount:LongWord):TCriticalSectionHandle;
Description: Create and insert a new CriticalSection entry


[Expand]
function CriticalSectionDestroy(CriticalSection:TCriticalSectionHandle):LongWord;
Description: Destroy and remove an existing CriticalSection entry


[Expand]
function CriticalSectionCount(CriticalSection:TCriticalSectionHandle):LongWord;
Description: Get the current lock count of an existing CriticalSection entry


[Expand]
function CriticalSectionOwner(CriticalSection:TCriticalSectionHandle):TThreadHandle;
Description: Get the current owner of an existing CriticalSection entry


[Expand]
function CriticalSectionSetSpinCount(CriticalSection:TCriticalSectionHandle; SpinCount:LongWord):LongWord;
Description: Set the spin count of an existing CriticalSection entry


[Expand]
function CriticalSectionLock(CriticalSection:TCriticalSectionHandle):LongWord;
Description: Lock an existing CriticalSection entry


[Expand]
function CriticalSectionLockEx(CriticalSection:TCriticalSectionHandle; Timeout:LongWord):LongWord;
Description: Lock an existing CriticalSection entry


[Expand]
function CriticalSectionUnlock(CriticalSection:TCriticalSectionHandle):LongWord;
Description: Unlock an existing CriticalSection entry


[Expand]
function CriticalSectionTryLock(CriticalSection:TCriticalSectionHandle):LongWord;
Description: Try to lock an existing CriticalSection entry


Semaphore functions

[Expand]
function SemaphoreCreate(Count:LongWord):TSemaphoreHandle;
Description: Create and insert a new Semaphore entry


[Expand]
function SemaphoreCreateEx(Count,Maximum:LongWord; Flags:LongWord):TSemaphoreHandle;
Description: Create and insert a new Semaphore entry


[Expand]
function SemaphoreDestroy(Semaphore:TSemaphoreHandle):LongWord;
Description: Destroy and remove an existing Semaphore entry


[Expand]
function SemaphoreCount(Semaphore:TSemaphoreHandle):LongWord;
Description: Get the current count of an existing Semaphore entry


[Expand]
function SemaphoreWait(Semaphore:TSemaphoreHandle):LongWord;
Description: Wait on an existing Semaphore entry


[Expand]
function SemaphoreWaitEx(Semaphore:TSemaphoreHandle; Timeout:LongWord):LongWord;
Description: Wait on an existing Semaphore entry


[Expand]
function SemaphoreSignal(Semaphore:TSemaphoreHandle):LongWord;
Description: Signal an existing Semaphore entry


[Expand]
function SemaphoreSignalEx(Semaphore:TSemaphoreHandle; Count:LongWord; Previous:PLongWord):LongWord;
Description: Signal an existing Semaphore entry one or more times


Synchronizer functions

[Expand]
function SynchronizerCreate:TSynchronizerHandle;
Description: Create and insert a new Synchronizer entry


[Expand]
function SynchronizerCreateEx(InitialReader,InitialWriter:Boolean):TSynchronizerHandle;
Description: Create and insert a new Synchronizer entry


[Expand]
function SynchronizerDestroy(Synchronizer:TSynchronizerHandle):LongWord;
Description: Destroy and remove an existing Synchronizer entry


[Expand]
function SynchronizerReaderCount(Synchronizer:TSynchronizerHandle):LongWord;
Description: Get the current reader count of an existing Synchronizer entry


[Expand]
function SynchronizerReaderLast(Synchronizer:TSynchronizerHandle):TThreadHandle;
Description: Get the last reader thread of an existing Synchronizer entry


[Expand]
function SynchronizerReaderLock(Synchronizer:TSynchronizerHandle):LongWord;
Description: Lock an existing Synchronizer entry for reading


[Expand]
function SynchronizerReaderLockEx(Synchronizer:TSynchronizerHandle; Timeout:LongWord):LongWord;
Description: Lock an existing Synchronizer entry for reading


[Expand]
function SynchronizerReaderUnlock(Synchronizer:TSynchronizerHandle):LongWord;
Description: Unlock an existing Synchronizer entry


[Expand]
function SynchronizerReaderConvert(Synchronizer:TSynchronizerHandle):LongWord;
Description: Convert a reader lock on an existing Synchronizer entry to a writer lock


[Expand]
function SynchronizerReaderConvertEx(Synchronizer:TSynchronizerHandle; Timeout:LongWord):LongWord;
Description: Convert a reader lock on an existing Synchronizer entry to a writer lock


[Expand]
function SynchronizerWriterCount(Synchronizer:TSynchronizerHandle):LongWord;
Description: Get the current writer count of an existing Synchronizer entry


[Expand]
function SynchronizerWriterOwner(Synchronizer:TSynchronizerHandle):TThreadHandle;
Description: Get the current writer owner of an existing Synchronizer entry


[Expand]
function SynchronizerWriterLock(Synchronizer:TSynchronizerHandle):LongWord;
Description: Lock an existing Synchronizer entry for writing


[Expand]
function SynchronizerWriterLockEx(Synchronizer:TSynchronizerHandle; Timeout:LongWord):LongWord;
Description: Lock an existing Synchronizer entry for writing


[Expand]
function SynchronizerWriterUnlock(Synchronizer:TSynchronizerHandle):LongWord;
Description: Unlock an existing Synchronizer entry


[Expand]
function SynchronizerWriterConvert(Synchronizer:TSynchronizerHandle):LongWord;
Description: Convert a writer lock on an existing Synchronizer entry to a reader lock


List functions

[Expand]
function ListCreate:TListHandle; {$IFDEF LIST_INLINE}inline; {$ENDIF}
Description: Create and insert a new List entry


[Expand]
function ListCreateEx(ListType:LongWord; Flags:LongWord):TListHandle;
Description: Create and insert a new List entry


[Expand]
function ListDestroy(List:TListHandle):LongWord;
Description: Destroy and remove an existing List entry


[Expand]
function ListCount(List:TListHandle):LongWord;
Description: Get the current count from the supplied list


[Expand]
function ListAddFirst(List:TListHandle; Element:PListElement):LongWord;
Description: Add the supplied element as the first item in the List


[Expand]
function ListAddLast(List:TListHandle; Element:PListElement):LongWord;
Description: Add the supplied element as the last item in the List


[Expand]
function ListGetThread(List:TListHandle; Thread:TThreadHandle):PListElement;
Description: Find the supplied thread in the List and return its element


[Expand]
function ListGetFirst(List:TListHandle):PListElement;
Description: Get the first element from the List


[Expand]
function ListGetFirstEx(List:TListHandle; Remove:Boolean):PListElement;
Description: Get the first element from the List


[Expand]
function ListGetLast(List:TListHandle):PListElement;
Description: Get the last element from the List


[Expand]
function ListGetLastEx(List:TListHandle; Remove:Boolean):PListElement;
Description: Get the last element from the List


[Expand]
function ListInsert(List:TListHandle; Previous,Element:PListElement):LongWord;
Description: Insert a new element in the List


[Expand]
function ListRemove(List:TListHandle; Element:PListElement):LongWord;
Description: Remove an element from the List


[Expand]
function ListIsEmpty(List:TListHandle):Boolean;
Description: Check if the supplied List is empty


[Expand]
function ListNotEmpty(List:TListHandle):Boolean;
Description: Check if the supplied List is empty


[Expand]
function ListLock(List:TListHandle):LongWord;
Description: Lock the supplied List


[Expand]
function ListUnlock(List:TListHandle):LongWord;
Description: Unlock the supplied List


[Expand]
function ListLock(List:TListHandle):LongWord; {$IFDEF LIST_INLINE}inline; {$ENDIF}
Description: Lock the supplied List


[Expand]
function ListUnlock(List:TListHandle):LongWord; {$IFDEF LIST_INLINE}inline; {$ENDIF}
Description: Unlock the supplied List


Queue functions

[Expand]
function QueueCreate:TQueueHandle; {$IFDEF QUEUE_INLINE}inline; {$ENDIF}
Description: Create and insert a new Queue entry


[Expand]
function QueueCreateEx(QueueType:LongWord; Flags:LongWord):TQueueHandle;
Description: Create and insert a new Queue entry}


[Expand]
function QueueDestroy(Queue:TQueueHandle):LongWord;
Description: Destroy and remove an existing Queue entry


[Expand]
function QueueCount(Queue:TQueueHandle):LongWord;
Description: Get the current count from the supplied queue


[Expand]
function QueueEnqueue(Queue:TQueueHandle; Thread:TThreadHandle):LongWord;
Description: Add the supplied thread as the last item in the Queue


[Expand]
function QueueDequeue(Queue:TQueueHandle):TThreadHandle;
Description: Get and remove the first thread from the Queue


[Expand]
function QueueFirstKey(Queue:TQueueHandle):Integer;
Description: Get the first Key value from the Queue


[Expand]
function QueueLastKey(Queue:TQueueHandle):Integer;
Description: Get the last Key value from the Queue


[Expand]
function QueueInsertKey(Queue:TQueueHandle; Thread:TThreadHandle; Key:Integer):LongWord;
Description: Insert the supplied thread in the Queue ordered based on Key and the flags of the Queue


[Expand]
function QueueDeleteKey(Queue:TQueueHandle; Thread:TThreadHandle):LongWord;
Description: Delete the supplied thread from the Queue based on the flags of the Queue


[Expand]
function QueueIncrementKey(Queue:TQueueHandle):Integer;
Description: Increment the first Key value in the Queue


[Expand]
function QueueDecrementKey(Queue:TQueueHandle):Integer;
Description: Decrement the first Key value in the Queue


[Expand]
function QueueIsEmpty(Queue:TQueueHandle):Boolean;
Description: Check if the supplied Queue is empty


[Expand]
function QueueNotEmpty(Queue:TQueueHandle):Boolean;
Description: Check if the supplied Queue is not empty


[Expand]
function QueueLock(Queue:TQueueHandle):LongWord; {$IFDEF QUEUE_INLINE}inline; {$ENDIF}
Description: Lock the supplied Queue


[Expand]
function QueueUnlock(Queue:TQueueHandle):LongWord; {$IFDEF QUEUE_INLINE}inline; {$ENDIF}
Description: Unlock the supplied Queue


Thread functions

[Expand]
function ThreadCreate(StartProc:TThreadStart; StackSize,Priority:LongWord; Name:PChar; Parameter:Pointer):TThreadHandle;
Description: Create and insert a new Thread entry


[Expand]
function ThreadCreateEx(StartProc:TThreadStart; StackSize,Priority,Affinity,CPU:LongWord; Name:PChar; Parameter:Pointer):TThreadHandle;
Description: Create and insert a new Thread entry


[Expand]
function ThreadDestroy(Thread:TThreadHandle):LongWord;
Description: Destroy and remove an existing Thread entry


[Expand]
function ThreadGetCurrent:TThreadHandle; inline;
Description: Get the Handle of currently executing thread


[Expand]
function ThreadSetCurrent(Thread:TThreadHandle):LongWord; inline;
Description: Set the Handle of currently executing thread


[Expand]
function ThreadGetName(Thread:TThreadHandle):String;
Description: Get the name of a Thread}


[Expand]
function ThreadSetName(Thread:TThreadHandle; const Name:String):LongWord;
Description: Set the name of a Thread


[Expand]
function ThreadGetCPU(Thread:TThreadHandle):LongWord;
Description: Get the current CPU of a thread (eg CPU_ID_0)


[Expand]
function ThreadSetCPU(Thread:TThreadHandle; CPU:LongWord):LongWord;
Description: Set the current CPU of a thread (eg CPU_ID_0)


[Expand]
function ThreadGetState(Thread:TThreadHandle):LongWord;
Description: Get the current state of a thread (eg THREAD_STATE_SUSPENDED)


[Expand]
function ThreadGetLocale(Thread:TThreadHandle):LCID;
Description: Get the current locale of a thread


[Expand]
function ThreadSetLocale(Thread:TThreadHandle; Locale:LCID):LongWord;
Description: Set the locale of a thread


[Expand]
function ThreadGetTimes(Thread:TThreadHandle; var CreateTime,ExitTime,KernelTime:Int64):LongWord;
Description: Get the current times of a thread


[Expand]
function ThreadGetSwitchCount(Thread:TThreadHandle; var SwitchCount:Int64):LongWord;
Description: Get the current context switch count of a thread (How many times the thread has been scheduled)


[Expand]
function ThreadGetStackSize(Thread:TThreadHandle):LongWord;
Description: Get the current stack size of a thread


[Expand]
function ThreadGetStackBase(Thread:TThreadHandle):PtrUInt;
Description: Get the current stack base of a thread


[Expand]
function ThreadSetStackBase(Thread:TThreadHandle; StackBase:PtrUInt):LongWord;
Description: Set the current stack base of a thread


[Expand]
function ThreadGetStackPointer(Thread:TThreadHandle):PtrUInt;
Description: Get the current stack pointer of a thread


[Expand]
function ThreadGetExitCode(Thread:TThreadHandle):LongWord;
Description: Get the exit code of a Thread


[Expand]
function ThreadGetAffinity(Thread:TThreadHandle):LongWord;
Description: Get the scheduling affinity of a Thread


[Expand]
function ThreadSetAffinity(Thread:TThreadHandle; Affinity:LongWord):LongWord;
Description: Set the scheduling affinity of a Thread


[Expand]
function ThreadGetPriority(Thread:TThreadHandle):LongWord;
Description: Get the scheduling priority of a Thread


[Expand]
function ThreadSetPriority(Thread:TThreadHandle; Priority:LongWord):LongWord;
Description: Set the scheduling priority of a Thread


[Expand]
function ThreadGetLastError:LongWord;
Description: Get the last error value for the current Thread


[Expand]
function ThreadSetLastError(LastError:LongWord):LongWord;
Description: Set the last error value for the current Thread


[Expand]
function ThreadGetWaitResult:LongWord;
Description: Get the result of the last wait timeout for the current Thread


[Expand]
function ThreadGetReceiveResult:LongWord;
Description: Get the result of the last receive timeout for the current Thread


[Expand]
function ThreadAllocTlsIndex:LongWord;
Description: Allocate a TLS index in the TLS index table


[Expand]
function ThreadAllocTlsIndexEx(Flags:LongWord):LongWord;
Description: Allocate a TLS index in the TLS index table


[Expand]
function ThreadReleaseTlsIndex(TlsIndex:LongWord):LongWord;
Description: Deallocate a TLS index from the TLS index table


[Expand]
function ThreadGetTlsValue(TlsIndex:LongWord):Pointer;
Description: Get the pointer associated with the TLS index for the current thread


[Expand]
function ThreadSetTlsValue(TlsIndex:LongWord; TlsValue:Pointer):LongWord;
Description: Set the pointer associated with the TLS index for the current thread


[Expand]
function ThreadGetTlsPointer(Thread:TThreadHandle):Pointer;
Description: Get the RTL TLS (Thread Local Storage) pointer of a Thread


[Expand]
function ThreadSetTlsPointer(Thread:TThreadHandle; TlsPointer:Pointer):LongWord;
Description: Set the RTL TLS (Thread Local Storage) pointer of a Thread


[Expand]
function ThreadReady(Thread:TThreadHandle; Reschedule:Boolean):LongWord;
Description: Place the supplied Thread on the ready queue


[Expand]
function ThreadTimeout(Thread:TThreadHandle):LongWord;
Description: Place the supplied Thread on the ready queue after a timeout waiting on a resource


[Expand]
function ThreadWake(Thread:TThreadHandle):LongWord;
Description: Remove a thread prematurely from the sleep or timeout queues


[Expand]
function ThreadMigrate(Thread:TThreadHandle; CPU:LongWord):LongWord;
Description: Migrate a thread to a new CPU


[Expand]
procedure ThreadEnd(ExitCode:LongWord);
Description: Terminate the current Thread


[Expand]
function ThreadHalt(ExitCode:LongWord):LongWord;
Description: Halt the current thread so it will never be rescheduled


[Expand]
function ThreadTerminate(Thread:TThreadHandle; ExitCode:LongWord):LongWord;
Description: Terminate but do not destroy the supplied Thread


[Expand]
function ThreadYield:LongWord;
Description: Make the current thread yield the processor (Same as ThreadSleep(0))


[Expand]
function ThreadSleep(Milliseconds:LongWord):LongWord;
Description: Place the current thread on the sleep queue for a specified number of milliseconds


[Expand]
function ThreadWait(List:TListHandle; Lock:TSpinHandle; Flags:LongWord):LongWord;
Description: Put the current thread into a wait state on the supplied list


[Expand]
function ThreadWaitEx(List:TListHandle; Lock:TSpinHandle; Flags,Timeout:LongWord):LongWord;
Description: Put the current thread into a wait state with timeout on the supplied list


[Expand]
function ThreadRelease(List:TListHandle):LongWord;
Description: Release the first thread waiting on the supplied list


[Expand]
function ThreadAbandon(List:TListHandle):LongWord;
Description: Release the first thread waiting on the supplied list and return with WAIT_ABANDONED


[Expand]
function ThreadWaitTerminate(Thread:TThreadHandle; Timeout:LongWord):LongWord;
Description: Make the current thread wait until the specified thread has terminated


[Expand]
function ThreadSuspend(Thread:TThreadHandle):LongWord;
Description: Suspend a thread, placing it in hibernation


[Expand]
function ThreadResume(Thread:TThreadHandle):LongWord;
Description: Resume a suspended thread, making it ready


[Expand]
function ThreadWaitMessage:LongWord;
Description: Make the current thread wait until a message is received (indefinately)


[Expand]
function ThreadSendMessage(Thread:TThreadHandle; const Message:TMessage):LongWord;
Description: Send a message to another thread


[Expand]
function ThreadReceiveMessage(var Message:TMessage):LongWord;
Description: Make the current thread wait to receive a message (indefinately)


[Expand]
function ThreadReceiveMessageEx(var Message:TMessage; Timeout:LongWord; Remove:Boolean):LongWord;
Description: Make the current thread wait to receive a message


[Expand]
function ThreadAbandonMessage(Thread:TThreadHandle):LongWord;
Description: Tell another thread to abandon waiting for a message


[Expand]
function ThreadLock(Thread:TThreadHandle):LongWord;
Description: Lock a thread allowing access to internal structures such as the thread stack


[Expand]
function ThreadUnlock(Thread:TThreadHandle):LongWord;
Description: Unlock a thread that was locked by ThreadLock


Scheduler functions

[Expand]
function SchedulerCheck(CPUID:LongWord):LongWord;
Description: Check if the sleep queue is empty, if not then decrement the first key. Note: Then check if the timeout queue is empty, if not then decrement the first key. If either key reaches zero, return success to indicate there are threads to be woken or threads whose timeout has expired. Finally check if the termination queue is empty, if not then decrement the first key. Items will be removed from the termination queue by SchedulerReschedule.


[Expand]
function SchedulerWakeup(CPUID:LongWord):LongWord;
Description: Remove all threads from the sleep queue that have no more time to sleep. Note: Threads will be placed back on the ready queue for rescheduling.


[Expand]
function SchedulerExpire(CPUID:LongWord):LongWord;
Description: Remove all threads from the timeout queue that have no more time to wait. Note: Threads will be placed back on the ready queue for rescheduling but will return with an error indicating the timeout expired.


[Expand]
function SchedulerSwitch(CPUID:LongWord; Thread:TThreadHandle):TThreadHandle;
Description: Perform a preemptive thread switch operation under an interrupt handler. Note: The next thread to run will be selected based on remaining quantum of the current thread, ready threads at higher priority levels and scheduler priority quantum for fair scheduling of lower priority threads.


[Expand]
function SchedulerSelect(CPUID:LongWord; Thread:TThreadHandle; Yield:Boolean):TThreadHandle;
Description: Select the next thread to be run based on state, yield, quantum and priority


[Expand]
function SchedulerReschedule(Yield:Boolean):LongWord;
Description: Perform a thread switch operation when a thread yields, sleeps or waits. Note: The next thread to run will be selected based on whether the current thread is yielding or no longer ready, remaining quantum of the current thread, ready threads at higher priority levels and scheduler priority quantum for fair scheduling of lower priority threads.


[Expand]
function SchedulerMigrationEnable:LongWord;
Description: Enable scheduler thread migration


[Expand]
function SchedulerMigrationDisable:LongWord;
Description: Disable scheduler thread migration


[Expand]
function SchedulerPreemptEnable(CPUID:LongWord):LongWord;
Description: Enable thread preemption for the specified CPU


[Expand]
function SchedulerPreemptDisable(CPUID:LongWord):LongWord;
Description: Disable thread preemption for the specified CPU


[Expand]
function SchedulerAllocationEnable(CPUID:LongWord):LongWord;
Description: Enable thread allocation for the specified CPU


[Expand]
function SchedulerAllocationDisable(CPUID:LongWord):LongWord;
Description: Disable thread allocation for the specified CPU


Messageslot functions

[Expand]
function MessageslotCreate:TMessageslotHandle;
Description: Create and insert a new Messageslot entry


[Expand]
function MessageslotCreateEx(Maximum:LongWord; Flags:LongWord):TMessageslotHandle;
Description: Create and insert a new Messageslot entry


[Expand]
function MessageslotDestroy(Messageslot:TMessageslotHandle):LongWord;
Description: Destroy and remove an existing Messageslot entry


[Expand]
function MessageslotCount(Messageslot:TMessageslotHandle):LongWord;
Description: Get the number of available messages in a Messageslot entry


[Expand]
function MessageslotSend(Messageslot:TMessageslotHandle; const Message:TMessage):LongWord;
Description: Send a message to a Messageslot


[Expand]
function MessageslotReceive(Messageslot:TMessageslotHandle; var Message:TMessage):LongWord;
Description: Receive a message from a Messageslot


[Expand]
function MessageslotReceiveEx(Messageslot:TMessageslotHandle; var Message:TMessage; Timeout:LongWord):LongWord;
Description: Receive a message from a Messageslot


Mailslot functions

[Expand]
function MailslotCreate(Maximum:LongWord):TMailslotHandle;
Description: Create and insert a new Mailslot entry


[Expand]
function MailslotDestroy(Mailslot:TMailslotHandle):LongWord;
Description: Destroy and remove an existing Mailslot entry


[Expand]
function MailslotCount(Mailslot:TMailslotHandle):LongWord;
Description: Get the number of available messages in a Mailslot entry


[Expand]
function MailslotSend(Mailslot:TMailslotHandle; Data:Integer):LongWord;
Description: Send a message to a Mailslot


[Expand]
function MailslotSendEx(Mailslot:TMailslotHandle; Data:Integer; Timeout:LongWord):LongWord;
Description: Send a message to a Mailslot


[Expand]
function MailslotReceive(Mailslot:TMailslotHandle):Integer;
Description: Receive a message from a Mailslot


Tasker functions

[Expand]
function TaskerThreadSendMessage(Thread:TThreadHandle; const Message:TMessage):LongWord;
Description: Perform a ThreadSendMessage() function call using the tasker list


[Expand]
function TaskerMessageslotSend(Messageslot:TMessageslotHandle; const Message:TMessage):LongWord;
Description: Perform a MessageslotSend() function call using the tasker list


[Expand]
function TaskerSemaphoreSignal(Semaphore:TSemaphoreHandle; Count:LongWord):LongWord;
Description: Perform a SemaphoreSignal() function call using the tasker list


[Expand]
function TaskerEnqueue(Task:PTaskerTask):LongWord;
Description: Add the supplied task to the end of the Tasker list


[Expand]
function TaskerDequeue:PTaskerTask;
Description: Get and remove the first task from the Tasker list


[Expand]
function TaskerCheck:LongWord;
Description: Check if the tasker list is empty or contains tasks


[Expand]
function TaskerTrigger:LongWord;
Description: Dequeue all tasks in the tasker list and perform the requested task for each


[Expand]
function TaskerGetCount:LongWord; inline;
Description: Get the current tasker count


Return to Unit Reference