ThreadScheduler.asm

This file defines the thread scheduler task of PwnOS and associated functions.

See Also

Authors

  • Neil G.  Dickson
Summary
ThreadScheduler.asmThis file defines the thread scheduler task of PwnOS and associated functions.
Variables
pThreadQueueThe main thread queue.
MillisecondCountThis holds the number of milliseconds since boot.
Functions
ThreadSchedulerSaves the state of the previous task and jumps to the next task to run.
GetThreadScoreGets a score of the specified thread based on priority, time waiting, and status (e.g.
QueueThreadPlaces the specified thread into the thread queue (see <pThreadQueue>).
GetMillisecondCountThis procedure returns the number of milliseconds since boot as a qword in edx:eax.

Variables

pThreadQueue

pThreadQueue DWORD NULL

The main thread queue.

Contains the handle of the first thread in the queue.  Accessing it requires the GET_THREAD_SCHEDULER_ACCESS and RELEASE_THREAD_SCHEDULER_ACCESS macros.

MillisecondCount

MillisecondCount QWORD 0

This holds the number of milliseconds since boot.

This is in Threads since it is used most extensively here.

Functions

ThreadScheduler

Saves the state of the previous task and jumps to the next task to run.

Not Implemented

TODO: Cancel pending timeout timer if still active.  TODO: Select threads based on score from GetThreadScoreTODO: Have busy flag cleared and release access when idling, because threads might finish on other processors.

This is not called directly, but accessed by the JMP_THREAD_SCHEDULER macro.  Around the use of this macro, however, must be the GET_THREAD_SCHEDULER_ACCESS macro before, and RELEASE_THREAD_SCHEDULER_ACCESS after, with interrupts disabled.

GetThreadScore

Gets a score of the specified thread based on priority, time waiting, and status (e.g. other threads waiting for a lock to be released).

Not Implemented

Parameters

hThreadhandle of thread for which to get the score

Returns

  • score of the specified thread (larger means should be chosen sooner)

QueueThread

Places the specified thread into the thread queue (see <pThreadQueue>).

Parameters

hThreadhandle of thread to queue

GetMillisecondCount

This procedure returns the number of milliseconds since boot as a qword in edx:eax.

Returns

  • MillisecondCount, the number of milliseconds since boot (high dword in edx, low dword in eax).
pThreadQueue DWORD NULL
The main thread queue.
MillisecondCount QWORD 0
This holds the number of milliseconds since boot.
This file defines constants and macros for the thread scheduler task of PwnOS.
This file defines thread management functions of PwnOS.
This file defines process management functions of PwnOS.
This file defines structures and cosntants for thread management functions of PwnOS.
This file defines structures and cosntants for process management functions of PwnOS.
Acquire access to the thread scheduler task.
Release access to the thread scheduler task so that another processor can access it.
The Threads section of Core provides thread and process management functions, including common scheduling operations.
Gets a score of the specified thread based on priority, time waiting, and status (e.g.
Leave the current thread to allow another to run.