Go to index, previous page, next page

message.cc, messagefreelist.cc, messagequeue.cc

In these modules there is the code for the classes used by AMIKE OS to handle messages. They are pretty simple and the code should be straightforward, thus you can find only some quick notes here.

Message class

Public members

Message( Thread *t_ptr, int msg_val ) Object constructor. You can specify the initial thread pointer and message value.
Message *getNext( void )
void setNext( Message *m_ptr )
get or set the next message pointer
Thread *getThread( void )
void setThread( Thread *t_ptr )
get or set the thread pointer
int getMsgCode( void )
void setMsgCode( void )
get or set the message value

Private members

Message *m_next; points to the successive message in a list or queue
Thread *t_ptr; points to the thread which sent the message
int m_message; value of the message

MessageFreeList class

Public members

MessageFreeList( int list_size ) list constructor. It will create a list with list_size messages
~MessageFreeList( void ) destructor. All the messages in the list will be freed.
Message *getMessage( void )
void putMessage( Message *m_ptr )
remove a node from the list or place it back in.

Private members

Message *m_first; points to the first item in the list

MessageQueue class

Public members

MessageQueue( void ) constructor. It prepares the queue for use.
~MessageQueue( void ) destructor. It will free all the messages left in the queue.
void insertMessage( Message *m_ptr ) appends the given message to the queue
void ins1Message( Message *m_ptr ) inserts the given message at the head of the queue
Message *removeMessage( void ) removes the first message in the queue. It returns a pointer to it or NULL if the queue was empty
Message *keyMessage( Thread *t_ptr ) Removes and return the first message in the queue sent by thread t_ptr. Returns NULL if none is found.
Message *headMessage( void ) Returns a pointer to the first message in the queue, or NULL if the queue is empty.

Private members

Message *m_first; pointer to the first message in the queue
Message *m_last; pointer to the last message in the queue


Look at the header file: msgq.e

Look at the code: message.cc, messagefreelist.cc, messagequeue.cc


Go to index, previous page, next page