Messaging System Specification

Messaging System Specification
SchemeStation documentation

1 Introduction

One of the fundamental tasks of the SCHEMESTATION operating system is to provide the means for the agents to communicate in packet oriented fashion. The messaging module is mainly responsible of this.

Each agent has its own message queue, into which the messages are placed whenever they arrive - either from the network or from the local domain. The messages are then served to the agent whenever the virtual machine permits this (eg. the agent is not in blocking state.)

2 Requirements

The messaging system has to provide a function that the virtual machine calls whenever it needs to send a message (that is, an agent needs to send a message.) The messaging system extracts the local address of the agent (an id that identifies the entry in the scheduler's queue) based on the agent specifier the virtual machine passed to it. For this the messaging system consults the addressing system.

The messaging module has to provide a callback function to be called from the networking module whenever a message from a remote domain arrives to the local domain. The message will be handled just as if it was sent from the local domain.

For local agents, the messaging system maintains a queue (in the agent entry in the address table) to which the messages are first added so that the messages will not be omitted if the receiving agent happens to be blocking.

The virtual machine provides a function that can be used to pass the message to a local agent. The messaging system merely passes the destination address (local address), the data and the data length as arguments to this function, and the virtual machine respond with either ok or fail-return status. When the virtual machine returns fail status, the corresponding agent is set in to blocking state. For this there is a blocking-bit in the agent entry. When an agent is blocking, no messages are passed to it.

When a message is added to the queue, and if the recipient agent is not blocking the messaging system will pass the messages in the queue to the agent until the virtual machine states that the agent is blocking.

If the message in the first place was heading to a remote domain, the messaging system uses a similar function that the networking system provides. In addition to the data, and data length, it takes the complete destination address (domain and agent specifier) as an argument and immediately takes responsibility of delivering the packet. That is, the messaging system needs not to worry about the packet any more, since the networking system has its own spooling queue.

There has to be a way for the virtual machine to state that an agent is no longer blocking, so that the messaging system can carry on passing messages to it.

3 Functionality

The virtual machine can send heaps using the mess_sendheap (IN ActorSpecifier* address, IN LinearizedHeap *heap) -function. The function takes the destination address as the first argument, and the linearized heap to be send as the second argument. The LinearizedHeap-structure includes the length of the data.

The networking module calls void mess_callback (void *context) (the calling is actually delegated to the event loop, which is why the argument is a void pointer). The function expects to find a PacketCallbackInfo-struct at the end of the context-pointer. The struct includes all the relevant data that the messaging module needs to process the message.

The virtual machine calls int mess_unblockmessages (SchedulerID id) when an agent id becomes free to receive messages (does not block). The messaging system then retries to sent the messages the message in the agents queue, and sends all the arriving packets directly to the agent until the virtual machine informs again that the agent blocks.

The messaging system also includes MessStatus mess_readmessage (IN int fd, INOUT Message *message) and MessStatus mess_writemessage (IN int fd, IN Message *message) to save and read the messaging system from disk when the domain is shut down or woken up. These are called from the addressing system, see [Messaging System Implementation] for further details.