The Pedigree Project 0.1
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | Friends | List of all members
ThreadedIrqDispatcher Class Reference

#include <ThreadedIrqDispatcher.h>

+ Collaboration diagram for ThreadedIrqDispatcher:

Classes

class  Line
 

Public Types

using DispatchCallback = void(*)(void *, uint8_t, size_t)
 
using RemoteWakeCallback = bool(*)(void *, uint8_t, size_t)
 

Public Member Functions

 ThreadedIrqDispatcher (const String &name, size_t lineCount, DispatchCallback callback, void *callbackContext)
 
bool initialise ()
 
bool shutdown ()
 
bool canShutdown () const
 
bool isInitialised () const
 
bool isCurrentWorker () const
 
bool publishFromInterrupt (uint8_t line, size_t cookie)
 
bool hasPending (uint8_t line) const
 
size_t pendingCookie (uint8_t line) const
 
size_t activeCookie (uint8_t line) const
 
size_t completedBatches (uint8_t line) const
 
size_t completedCookie (uint8_t line) const
 
uintptr_t workerIdentity (uint8_t line) const
 
bool callbackActive (uint8_t line) const
 
bool publicationClosed (uint8_t line) const
 
void snapshotDiagnostics (uint8_t line, IrqLineDiagnosticSnapshot &snapshot) const
 

Static Public Attributes

static constexpr size_t MaxLines = 17
 

Private Member Functions

MUST_USE_RESULT bool setRemoteWakeCallback (RemoteWakeCallback callback, void *callbackContext)
 
 ThreadedIrqDispatcher (const ThreadedIrqDispatcher &)=delete
 
ThreadedIrqDispatcheroperator= (const ThreadedIrqDispatcher &)=delete
 

Private Attributes

Line m_Lines [MaxLines]
 
NormalStaticString m_Name
 
size_t m_LineCount
 
DispatchCallback m_Callback
 
void * m_CallbackContext
 
Spinlock m_ConfigurationLock
 
RemoteWakeCallback m_RemoteWakeCallback
 
void * m_RemoteWakeCallbackContext
 
size_t m_ConfigurationClosed
 
size_t m_Initialised
 
size_t m_ShutdownClaimed
 

Friends

class Pic
 

Detailed Description

Owns one coalescing worker for each configured IRQ or controller work lane.

The controller performs the trigger-specific hard-stage work before publishing a monotonically increasing, nonzero cookie. The worker invokes the callback in ordinary thread context. Interrupted machine state is never retained or exposed to the callback. Publication records atomics, rings the worker scheduler's doorbell, and may issue a bounded directed prompt; it never wakes a sleeping thread from hard context.

Definition at line 35 of file ThreadedIrqDispatcher.h.

Member Typedef Documentation

◆ DispatchCallback

using ThreadedIrqDispatcher::DispatchCallback = void (*)(void*, uint8_t, size_t)

Definition at line 38 of file ThreadedIrqDispatcher.h.

◆ RemoteWakeCallback

using ThreadedIrqDispatcher::RemoteWakeCallback = bool (*)(void*, uint8_t, size_t)

Prompts the worker processor after a remote producer has made a batch visible. The callback must be bounded, hard-IRQ safe, and must not attempt to roll back the already-published cookie on failure.

Definition at line 44 of file ThreadedIrqDispatcher.h.

Constructor & Destructor Documentation

◆ ThreadedIrqDispatcher()

ThreadedIrqDispatcher::ThreadedIrqDispatcher ( const String name,
size_t  lineCount,
DispatchCallback  callback,
void *  callbackContext 
)

Definition at line 521 of file ThreadedIrqDispatcher.cc.

◆ ~ThreadedIrqDispatcher()

ThreadedIrqDispatcher::~ThreadedIrqDispatcher ( )

Definition at line 604 of file ThreadedIrqDispatcher.cc.

Member Function Documentation

◆ activeCookie()

size_t ThreadedIrqDispatcher::activeCookie ( uint8_t  line) const

Definition at line 741 of file ThreadedIrqDispatcher.cc.

◆ callbackActive()

bool ThreadedIrqDispatcher::callbackActive ( uint8_t  line) const

Definition at line 757 of file ThreadedIrqDispatcher.cc.

◆ canShutdown()

bool ThreadedIrqDispatcher::canShutdown ( ) const

Whether the current context can synchronously join worker threads.

Definition at line 694 of file ThreadedIrqDispatcher.cc.

References ProcessorBase::executionContext(), ProcessorBase::information(), and isCurrentWorker().

Referenced by shutdown(), and Pic::shutdownThreaded().

+ Here is the caller graph for this function:

◆ completedBatches()

size_t ThreadedIrqDispatcher::completedBatches ( uint8_t  line) const

Definition at line 745 of file ThreadedIrqDispatcher.cc.

◆ completedCookie()

size_t ThreadedIrqDispatcher::completedCookie ( uint8_t  line) const

Definition at line 749 of file ThreadedIrqDispatcher.cc.

◆ hasPending()

bool ThreadedIrqDispatcher::hasPending ( uint8_t  line) const

Whether an occurrence arrived after the worker claimed its batch.

Definition at line 733 of file ThreadedIrqDispatcher.cc.

◆ initialise()

bool ThreadedIrqDispatcher::initialise ( )

Starts every stable per-line worker after scheduler initialisation.

Definition at line 610 of file ThreadedIrqDispatcher.cc.

References Spinlock::acquire(), ProcessorBase::information(), m_ConfigurationClosed, m_ConfigurationLock, m_ShutdownClaimed, and Spinlock::release().

Referenced by SplitIrqHandler::initialiseSplitIrq(), and Pic::initialiseThreaded().

+ Here is the caller graph for this function:

◆ isCurrentWorker()

bool ThreadedIrqDispatcher::isCurrentWorker ( ) const

True when called by one of this dispatcher's callback workers.

Definition at line 708 of file ThreadedIrqDispatcher.cc.

References ProcessorBase::information().

Referenced by canShutdown(), and SplitIrqHandler::shutdownSplitIrq().

+ Here is the caller graph for this function:

◆ isInitialised()

bool ThreadedIrqDispatcher::isInitialised ( ) const

Definition at line 704 of file ThreadedIrqDispatcher.cc.

◆ pendingCookie()

size_t ThreadedIrqDispatcher::pendingCookie ( uint8_t  line) const

Lock-free diagnostic state; invalid lines return zero/false.

Definition at line 737 of file ThreadedIrqDispatcher.cc.

Referenced by Pic::snapshotIrqLines().

+ Here is the caller graph for this function:

◆ publicationClosed()

bool ThreadedIrqDispatcher::publicationClosed ( uint8_t  line) const

Definition at line 761 of file ThreadedIrqDispatcher.cc.

◆ publishFromInterrupt()

bool ThreadedIrqDispatcher::publishFromInterrupt ( uint8_t  line,
size_t  cookie 
)

Marks a line and rings its owning scheduler in one bounded operation. Concurrent or nested producers are coalesced by cookie generation. A constant cookie is safe for multi-producer work-bit users. Callers must enter through a hard/atomic source which serialises same-CPU execution; a nested publication can only occur after the outer cookie is stored.

Definition at line 720 of file ThreadedIrqDispatcher.cc.

◆ setRemoteWakeCallback()

bool ThreadedIrqDispatcher::setRemoteWakeCallback ( RemoteWakeCallback  callback,
void *  callbackContext 
)
private

PIC is the sole production client allowed to request a directed worker prompt. Generic dispatchers deliberately remain local-only so an opaque callback cannot smuggle a blocking operation into hard IRQ context.

Definition at line 549 of file ThreadedIrqDispatcher.cc.

References Spinlock::acquire(), m_ConfigurationClosed, m_ConfigurationLock, m_RemoteWakeCallback, and Spinlock::release().

Referenced by Pic::initialiseThreaded().

+ Here is the caller graph for this function:

◆ shutdown()

bool ThreadedIrqDispatcher::shutdown ( )

Rejects new publications and joins every worker.

Definition at line 654 of file ThreadedIrqDispatcher.cc.

References canShutdown(), ProcessorBase::information(), m_ConfigurationClosed, and m_ShutdownClaimed.

Referenced by SplitIrqHandler::shutdownSplitIrq(), and Pic::shutdownThreaded().

+ Here is the caller graph for this function:

◆ snapshotDiagnostics()

void ThreadedIrqDispatcher::snapshotDiagnostics ( uint8_t  line,
IrqLineDiagnosticSnapshot snapshot 
) const

Copies lock-free timing and detached worker state for the debugger. Live fields are sampled independently; stopped-world use is authoritative.

Definition at line 765 of file ThreadedIrqDispatcher.cc.

Referenced by Pic::snapshotIrqLines().

+ Here is the caller graph for this function:

◆ workerIdentity()

uintptr_t ThreadedIrqDispatcher::workerIdentity ( uint8_t  line) const

Definition at line 753 of file ThreadedIrqDispatcher.cc.

Friends And Related Symbol Documentation

◆ Pic

friend class Pic
friend

Definition at line 134 of file ThreadedIrqDispatcher.h.

Member Data Documentation

◆ m_Callback

DispatchCallback ThreadedIrqDispatcher::m_Callback
private

Definition at line 210 of file ThreadedIrqDispatcher.h.

◆ m_CallbackContext

void* ThreadedIrqDispatcher::m_CallbackContext
private

Definition at line 211 of file ThreadedIrqDispatcher.h.

◆ m_ConfigurationClosed

size_t ThreadedIrqDispatcher::m_ConfigurationClosed
private

Closes callback configuration before the first worker is created.

Definition at line 218 of file ThreadedIrqDispatcher.h.

Referenced by initialise(), setRemoteWakeCallback(), and shutdown().

◆ m_ConfigurationLock

Spinlock ThreadedIrqDispatcher::m_ConfigurationLock
private

Serialises normal-context callback configuration with initialise().

Definition at line 213 of file ThreadedIrqDispatcher.h.

Referenced by initialise(), and setRemoteWakeCallback().

◆ m_Initialised

size_t ThreadedIrqDispatcher::m_Initialised
private

Definition at line 219 of file ThreadedIrqDispatcher.h.

◆ m_LineCount

size_t ThreadedIrqDispatcher::m_LineCount
private

Definition at line 209 of file ThreadedIrqDispatcher.h.

◆ m_Lines

Line ThreadedIrqDispatcher::m_Lines[MaxLines]
private

Definition at line 205 of file ThreadedIrqDispatcher.h.

◆ m_Name

NormalStaticString ThreadedIrqDispatcher::m_Name
private

Inline so global interrupt-controller constructors cannot enter the heap.

Definition at line 208 of file ThreadedIrqDispatcher.h.

◆ m_RemoteWakeCallback

RemoteWakeCallback ThreadedIrqDispatcher::m_RemoteWakeCallback
private

Immutable after initialise(): null intentionally means local-only.

Definition at line 215 of file ThreadedIrqDispatcher.h.

Referenced by setRemoteWakeCallback().

◆ m_RemoteWakeCallbackContext

void* ThreadedIrqDispatcher::m_RemoteWakeCallbackContext
private

Definition at line 216 of file ThreadedIrqDispatcher.h.

◆ m_ShutdownClaimed

size_t ThreadedIrqDispatcher::m_ShutdownClaimed
private

Exactly one normal-context caller may join and release workers.

Definition at line 221 of file ThreadedIrqDispatcher.h.

Referenced by initialise(), and shutdown().

◆ MaxLines

constexpr size_t ThreadedIrqDispatcher::MaxLines = 17
staticconstexpr

Definition at line 37 of file ThreadedIrqDispatcher.h.


The documentation for this class was generated from the following files: