The Pedigree Project  0.1
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
Event Class Referenceabstract

#include <Event.h>

+ Inheritance diagram for Event:
+ Collaboration diagram for Event:

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)
 
Eventoperator= (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
 

Detailed Description

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.

Definition at line 48 of file Event.h.

Constructor & Destructor Documentation

Event::Event ( uintptr_t  handlerAddress,
bool  isDeletable,
size_t  specificNestingLevel = ~0UL 
)

Constructs an Event object.

Parameters
handlerAddressThe address of the handling function.
isDeletableCan the object be deleted after map()? This is used for creating objects without worrying about destroying them.
specificNestingLevelIs 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 .
Note
As can be surmised, handlerAddress is NOT reentrant. If you use this Event in multiple threads concurrently, you CANNOT change the handler address.

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().

+ Here is the caller graph for this function:

Member Function Documentation

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().

+ Here is the caller graph for this function:

size_t Event::getEventType ( uint8_t *  pBuffer)
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().

+ Here is the caller graph for this function:

uintptr_t Event::getHandlerAddress ( )
inline

Returns the handler address.

Definition at line 108 of file Event.h.

Referenced by PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

uintptr_t Event::getHandlerBuffer ( )
static

Retrieves the event handler buffer memory address.

Definition at line 77 of file Event.cc.

References getTrampoline().

Referenced by PerProcessorScheduler::checkEventState(), and getLastHandlerBuffer().

+ Here is the caller graph for this function:

uintptr_t Event::getLastHandlerBuffer ( )
static

Retrieves the last handler buffer memory address.

Definition at line 82 of file Event.cc.

References getHandlerBuffer().

virtual size_t Event::getNumber ( )
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().

+ Here is the caller graph for this function:

uintptr_t Event::getSecondaryTrampoline ( )
static

Retrieves the secondary trampoline memory address.

Definition at line 72 of file Event.cc.

References getTrampoline().

size_t Event::getSpecificNestingLevel ( )
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().

+ Here is the caller graph for this function:

uintptr_t Event::getTrampoline ( )
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().

+ Here is the caller graph for this function:

bool Event::isDeletable ( )
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().

+ Here is the caller graph for this function:

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().

+ Here is the caller graph for this function:

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().

+ Here is the caller graph for this function:

virtual size_t Event::serialize ( uint8_t *  pBuffer)
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.

Parameters
pBufferThe buffer to serialize to.
Returns
The number of bytes serialized.

Implemented in Semaphore::SemaphoreEvent, TimeoutGuard::TimeoutGuardEvent, PosixTerminalEvent, PollEvent, IoEvent, SelectEvent, Time::DelayTimerEvent, InputEvent, and SignalEvent.

Referenced by PerProcessorScheduler::checkEventState().

+ Here is the caller graph for this function:

bool Event::unserialize ( uint8_t *  pBuffer,
Event event 
)
static

Given a serialized Event in binary form, attempt to unserialize into the given object. If this is impossible, return false.

Note
It is impossible to make static functions virtual, but it is required that all subclasses of Event implement this function statically.

Definition at line 93 of file Event.cc.

References ERROR.

void Event::waitForDeliveries ( )
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().

Member Data Documentation

bool Event::m_bIsDeletable
protected

Can the object be deleted after map?

Definition at line 145 of file Event.h.

Referenced by getEventType(), and isDeletable().

uintptr_t Event::m_HandlerAddress
protected

Handler address.

Definition at line 142 of file Event.h.

Referenced by getEventType().

Spinlock Event::m_Lock
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().

size_t Event::m_Magic
protected

Magic number for verification.

Definition at line 151 of file Event.h.

size_t Event::m_NestingLevel
protected

Specific nesting level, or ~0UL.

Definition at line 148 of file Event.h.

Referenced by getEventType().

List<Thread *> Event::m_Threads
protected

Associated threads that have us in their queue.

Definition at line 155 of file Event.h.

Referenced by deregisterThread(), Event(), getEventType(), pendingCount(), and registerThread().


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