Messaging System Implementation

Messaging System Implementation


Document formatted by vherva at Fri Apr 24 11:23:44 1998 on the host schemestation. This document is produced by the SchemeStation project during the Tik-76.115 course.

1 Introduction

The implementation of the messaging system is fairly straightforward; the messaging queues can be held in the address entry struct in the addressing system. In addition to this, only few functions have to be implemented.

Despite of the simplicity of the messaging system, it is convenient to make a separate module, mainly to have a clean interface to the messaging functions.

2 Data structures

The message queue is implemented as a linked list. The list is placed in the in the ActorEntry-struct of the agent that is kept in the hash table of the addressing addressing system (see [Addressing module implementation].)

3 Functions

All the the needed functions were described in [Messaging System Specification]. The interface is described below.

4 The functions of module Messaging

File messaging.h

C-functions:

  • void mess_callback(void *context)
    Description: The callback called from the networking module, when a message arrives.

  • void mess_init(void)
    Description: Initialize the messaging system. Needs to be done first!

  • MessStatus mess_readmessage(IN int fd, INOUT Message *message)
    Description: Writes a message to file. Returns MESS_OK on success, MESS_FAILED if otherwise (bad fd etc.)

  • Status mess_register_extagent_callback(IN MessagingSpecialCallback callback, IN void *context)
    Description: Register a callback to be called when an external agent gets a message.

  • Status mess_register_special_agent(IN long identifier, IN MessagingSpecialCallback callback, IN void *context)
    Description: Register a callback to be called when a special agent (for example, a kernel implementing agent) gets a message. The identifier should be currently between range 0..255 (inclusive).

  • MessStatus mess_sendheap(IN ActorSpecifier* address, IN LinearizedHeap heap, void *data_to_free)
    Description: Send a heap heap to actor address. Returns MESS_OK on success, MESS_FAILED if otherwise. Notice, that in the most situations the message is quietly lost rather than notifying the caller with ADDR_FAILED, if it can't be delievered. ADDRESS is not freed by mess_sendheap. free(data_to_free) is called by mess_sendheap when the message has been sent.

  • int mess_unblockmessages(SchedulerID id)
    Description: Re-enables sending messages to an Actor. Returns the number of addresses affected.

  • MessStatus mess_writemessage(IN int fd, IN Message *message)
    Description: Writes a message to file. Returns MESS_OK on success, MESS_FAILED if otherwise (bad fd etc.)


© SchemeStation project 1997-1998 [Back to the document index]