67 void*
operator new(
size_t sz,
void* pv) {
return reinterpret_cast<Thread*
>(pv); };
94 uint16_t u16StackSize_,
134 #if KERNEL_NAMED_THREADS 150 #endif // #if KERNEL_NAMED_THREADS 183 #if KERNEL_ROUND_ROBIN 198 #endif // #if KERNEL_ROUND_ROBIN 256 static void Sleep(uint32_t u32TimeMs_);
264 static void Yield(
void);
294 #if KERNEL_STACK_CHECK 307 #endif // #if KERNEL_STACK_CHECK 309 #if KERNEL_EVENT_FLAGS 337 #endif // #if KERNEL_EVENT_FLAGS 359 #if KERNEL_EXTENDED_CONTEXT 381 #endif // #if KERNEL_EXTENDED_CONTEXT 466 #if KERNEL_EXTENDED_CONTEXT 469 #endif // #if KERNEL_EXTENDED_CONTEXT 471 #if KERNEL_NAMED_THREADS 474 #endif // #if KERNEL_NAMED_THREADS 491 #if KERNEL_ROUND_ROBIN 494 #endif // #if KERNEL_ROUND_ROBIN 496 #if KERNEL_EVENT_FLAGS 502 #endif // #if KERNEL_EVENT_FLAGS ThreadState GetState()
GetState Returns the current state of the thread to the caller. Can be used to determine whether or n...
void SetQuantum(uint16_t u16Quantum_)
SetQuantum Set the thread's round-robin execution quantum.
void * GetExtendedContext()
GetExtendedContext Return the Thread object's extended-context data pointer. Used by code implementin...
uint16_t m_u16Quantum
Thread quantum (in milliseconds)
K_WORD * m_pwStack
Pointer to the thread's stack.
#define K_WORD
Size of a data word.
Basic data type primatives used throughout the OS.
Thread porting interface.
void Exit()
Exit. Remove the thread from being scheduled again. The thread is effectively destroyed when this occ...
void(*)(Thread *pclThread_) ThreadExitCallout
ThreadList * GetOwner(void)
GetOwner Return the ThreadList where the thread belongs when it's in the active/ready state in the sc...
void(*)(Thread *pclThread_) ThreadCreateCallout
PORT_PRIO_TYPE m_uXCurPriority
Current priority of the thread (priority inheritence)
The ThreadList Class. This class is used for building thread-management facilities, such as schedulers, and blocking objects.
const char * GetName()
GetName.
void * m_pvExtendedContext
Pointer provided to a Thread to implement thread-local storage.
PORT_PRIO_TYPE m_uXPriority
Default priority of the thread.
void Init(K_WORD *pwStack_, uint16_t u16StackSize_, PORT_PRIO_TYPE uXPriority_, ThreadEntryFunc pfEntryPoint_, void *pvArg_)
Init Initialize a thread prior to its use. Initialized threads are placed in the stopped state...
static void CoopYield(void)
CoopYield Cooperative yield - This forces the system to not only call the scheduler, but also move the currently executing thread to the back of the current thread list, allowing other same-priority threads the opportunity to run. This is used primarily for cooperative scheduling between threads in the same priority level.
void SetState(ThreadState eState_)
SetState Set the thread's state to a new value. This is only to be used by code within the kernel...
ThreadList * m_pclCurrent
Pointer to the thread-list where the thread currently resides.
uint16_t m_u16StackSize
Size of the stack (in bytes)
#define PORT_PRIO_TYPE
Type used for bitmap in the PriorityMap class.
bool m_bExpired
Indicate whether or not a blocking-object timeout has occurred.
K_WORD * m_pwStackTop
Pointer to the top of the thread's stack.
static void ContextSwitchSWI(void)
ContextSwitchSWI This code is used to trigger the context switch interrupt. Called whenever the kerne...
ThreadEntryFunc m_pfEntryPoint
The entry-point function called when the thread starts.
bool IsInitialized()
IsInitialized Used to check whether or not a thread has been initialized prior to use...
void InheritPriority(PORT_PRIO_TYPE uXPriority_)
InheritPriority Allow the thread to run at a different priority level (temporarily) for the purpose o...
Thread scheduler function declarations This scheduler implements a very flexible type of scheduling...
void * m_pvArg
Pointer to the argument passed into the thread's entrypoint.
uint16_t GetStackSlack()
GetStackSlack Performs a (somewhat lengthy) check on the thread stack to check the amount of stack ma...
Mark3 Kernel Configuration This file is used to configure the kernel for your specific application in...
uint16_t GetEventFlagMask()
GetEventFlagMask returns the thread's current event-flag mask, which is used in conjunction with the ...
Timer m_clTimer
Timer used for blocking-object timeouts.
uint16_t GetStackSize()
GetStackSize.
PORT_PRIO_TYPE GetCurPriority(void)
GetCurPriority Return the priority of the current thread.
EventFlagOperation m_eFlagMode
Event-flag mode.
K_WORD * GetStackTop()
GetStackTop.
The Thread Class. This object providing the fundamental thread control data structures and functions ...
const char * m_szName
Thread name.
void SetExpired(bool bExpired_)
SetExpired Set the status of the current blocking call on the thread.
void SetCurrent(ThreadList *pclNewList_)
SetCurrent. Set the thread's current to the specified thread list.
void SetEventFlagMask(uint16_t u16Mask_)
SetEventFlagMask Sets the active event flag bitfield mask.
void Start()
Start Start the thread - remove it from the stopped list, add it to the scheduler's list of threads (...
ThreadState m_eState
Enum indicating the thread's current state.
static void Yield(void)
Yield Yield the thread - this forces the system to call the scheduler and determine what thread shoul...
void SetOwner(ThreadList *pclNewList_)
SetOwner. Set the thread's owner to the specified thread list.
uint16_t m_u16FlagMask
Event-flag mask.
EventFlagOperation GetEventFlagMode()
GetEventFlagMode Returns the thread's event flag's operating mode.
void SetName(const char *szName_)
SetName Set the name of the thread - this is purely optional, but can be useful when identifying issu...
uint16_t GetQuantum(void)
GetQuantum Get the thread's round-robin execution quantum.
Priority map data structure.
void SetID(uint8_t u8ID_)
SetID Set an arbitrary 8-bit ID to uniquely identify this thread.
void Stop()
Stop Stop a thread that's actively scheduled without destroying its stacks. Stopped threads can be re...
void SetEventFlagMode(EventFlagOperation eMode_)
SetEventFlagMode Sets the active event flag operation mode.
void(*)(void *pvArg_) ThreadEntryFunc
K_WORD * GetStack()
GetStack.
static void Sleep(uint32_t u32TimeMs_)
Sleep Put the thread to sleep for the specified time (in milliseconds). Actual time slept may be long...
bool GetExpired()
GetExpired Return the status of the most-recent blocking call on the thread.
uint8_t GetID()
GetID Return the thread's integer ID. Note that this ID is not guaranteed to be unique when dynamic t...
The Timer Class. This class provides kernel-managed timers, used to provide high-precision delays...
void(*)(Thread *pclThread_) ThreadContextCallout
ThreadList * GetCurrent(void)
GetCurrent Return the ThreadList where the thread is currently located.
The TypedLinkListNode class The TypedLinkListNode class provides a linked-list node type for a specif...
The ThreadPort Class defines the target-specific functions required by the kernel for threading...
void SetPriorityBase(PORT_PRIO_TYPE uXPriority_)
SetPriorityBase.
uint8_t m_u8ThreadID
Thread ID.
Automatic memory allocation for kernel objects.
PORT_PRIO_TYPE GetPriority(void)
GetPriority Return the priority of the current thread.
Core linked-list declarations, used by all kernel list types At the heart of RTOS data structures are...
int m_iErrno
Storage used to hold a thread-safe errno value.
Thread Quantum declarations for Round-Robin Scheduling.
ThreadList * m_pclOwner
Pointer to the thread-list where the thread resides when active.
void SetPriority(PORT_PRIO_TYPE uXPriority_)
SetPriority. Set the priority of the Thread (running or otherwise) to a different level...
int * ErrnoStorage()
ErrnoStorage.
void SetExtendedContext(void *pvData_)
SetExtendedContext Assign the Thread object's extended-context data pointer. Used by code implementin...
Thread linked-list declarations.