The Pedigree Project
0.1
|
#include <Event.h>
Public Member Functions | |
Event (uintptr_t handlerAddress, bool isDeletable, size_t specificNestingLevel=~0UL) | |
virtual bool | isDeletable () |
virtual size_t | serialize (uint8_t *pBuffer)=0 |
uintptr_t | getHandlerAddress () |
size_t | getSpecificNestingLevel () |
virtual size_t | getNumber ()=0 |
Event (const Event &other) | |
Event & | operator= (const Event &other) |
void | registerThread (Thread *thread) |
void | deregisterThread (Thread *thread) |
size_t | pendingCount () |
virtual void | waitForDeliveries () |
Static Public Member Functions | |
static uintptr_t | getTrampoline () |
static uintptr_t | getSecondaryTrampoline () |
static uintptr_t | getHandlerBuffer () |
static uintptr_t | getLastHandlerBuffer () |
static bool | unserialize (uint8_t *pBuffer, Event &event) |
static size_t | getEventType (uint8_t *pBuffer) |
Protected Attributes | |
uintptr_t | m_HandlerAddress |
bool | m_bIsDeletable |
size_t | m_NestingLevel |
size_t | m_Magic |
List< Thread * > | m_Threads |
Spinlock | m_Lock |
The abstract base class for an asynchronous event. An event can hold any amount of information up to a hard maximum size of EVENT_LIMIT (usually 4096 bytes). An event is serialized using the virtual serialize() function and sent to a recipient thread in either user or kernel mode, where it is unserialized.
Event::Event | ( | uintptr_t | handlerAddress, |
bool | isDeletable, | ||
size_t | specificNestingLevel = ~0UL |
||
) |
Constructs an Event object.
handlerAddress | The address of the handling function. |
isDeletable | Can the object be deleted after map()? This is used for creating objects without worrying about destroying them. |
specificNestingLevel | Is the event pinned to a specific nesting level? If this value is not ~0UL, then the event will only be fired if the current nesting level is specificNestingLevel . |
Definition at line 31 of file Event.cc.
References List< T, nodePoolSize >::count(), ERROR, FATAL, m_Lock, and m_Threads.
Referenced by getEventType(), IoEvent::IoEvent(), and PollEvent::PollEvent().
void Event::deregisterThread | ( | Thread * | thread | ) |
Deregister a thread with this object.
Definition at line 137 of file Event.cc.
References List< T, nodePoolSize >::begin(), List< T, nodePoolSize >::end(), List< T, nodePoolSize >::erase(), m_Lock, and m_Threads.
Referenced by Thread::cullEvent(), and Thread::getNextEvent().
|
static |
Given a serialized event, returns the type of that event (a constant from eventNumbers.h).
Definition at line 99 of file Event.cc.
References List< T, nodePoolSize >::clear(), Event(), m_bIsDeletable, m_HandlerAddress, m_Lock, m_NestingLevel, and m_Threads.
Referenced by PosixTerminalEvent::serialize().
|
inline |
Returns the handler address.
Definition at line 108 of file Event.h.
Referenced by PerProcessorScheduler::checkEventState().
|
static |
Retrieves the event handler buffer memory address.
Definition at line 77 of file Event.cc.
References getTrampoline().
Referenced by PerProcessorScheduler::checkEventState(), and getLastHandlerBuffer().
|
static |
Retrieves the last handler buffer memory address.
Definition at line 82 of file Event.cc.
References getHandlerBuffer().
|
pure virtual |
Returns the event number / ID.
Implemented in Semaphore::SemaphoreEvent, TimeoutGuard::TimeoutGuardEvent, PosixTerminalEvent, PollEvent, IoEvent, SelectEvent, InputEvent, Time::DelayTimerEvent, and SignalEvent.
Referenced by Thread::getNextEvent().
|
static |
Retrieves the secondary trampoline memory address.
Definition at line 72 of file Event.cc.
References getTrampoline().
|
inline |
Returns the specific nesting level, or ~0UL if there is none defined.
Definition at line 114 of file Event.h.
Referenced by Thread::getNextEvent().
|
static |
Retrieves the main trampoline memory address.
Definition at line 66 of file Event.cc.
References VirtualAddressSpace::getKernelAddressSpace(), and VirtualAddressSpace::getKernelEventBlockStart().
Referenced by PerProcessorScheduler::checkEventState(), getHandlerBuffer(), and getSecondaryTrampoline().
|
virtual |
Returns true if the event is on the heap and can be deleted when handled. This is for creating fire-and-forget messages and not worrying about memory leaks.
Definition at line 88 of file Event.cc.
References m_bIsDeletable.
Referenced by PerProcessorScheduler::checkEventState(), and Thread::setStatus().
size_t Event::pendingCount | ( | ) |
Gets the count of threads with this event currently pending delivery.
Definition at line 155 of file Event.cc.
References List< T, nodePoolSize >::count(), m_Lock, and m_Threads.
Referenced by waitForDeliveries().
void Event::registerThread | ( | Thread * | thread | ) |
Register a thread with this object (to detect deletion while Thread still knows about it).
Definition at line 130 of file Event.cc.
References m_Lock, m_Threads, and List< T, nodePoolSize >::pushBack().
Referenced by Thread::sendEvent().
|
pure virtual |
Given a buffer EVENT_LIMIT bytes long, take the variables present in this object and convert them to a binary form.
It can be assumed that this function will only be called when the Event is about to be dispatched, and so the inhibited mask of the current Thread is available to be changed to what the event handler requires. This change will be undone when the handler completes.
pBuffer | The buffer to serialize to. |
Implemented in Semaphore::SemaphoreEvent, TimeoutGuard::TimeoutGuardEvent, PosixTerminalEvent, PollEvent, IoEvent, SelectEvent, Time::DelayTimerEvent, InputEvent, and SignalEvent.
Referenced by PerProcessorScheduler::checkEventState().
|
static |
Given a serialized Event in binary form, attempt to unserialize into the given object. If this is impossible, return false.
Definition at line 93 of file Event.cc.
References ERROR.
|
virtual |
Waits until this event is no longer in any thread queues.
Definition at line 163 of file Event.cc.
References Scheduler::instance(), pendingCount(), and Scheduler::yield().
|
protected |
Can the object be deleted after map?
Definition at line 145 of file Event.h.
Referenced by getEventType(), and isDeletable().
|
protected |
|
protected |
Spinlock for controlling access to the thread list.
Definition at line 158 of file Event.h.
Referenced by deregisterThread(), Event(), getEventType(), pendingCount(), and registerThread().
|
protected |
|
protected |
Specific nesting level, or ~0UL.
Definition at line 148 of file Event.h.
Referenced by getEventType().
Associated threads that have us in their queue.
Definition at line 155 of file Event.h.
Referenced by deregisterThread(), Event(), getEventType(), pendingCount(), and registerThread().