Addressing module implementation

Addressing module implementation


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

1 Introduction

The addressing system basically implements a data structure where addressing entries containing (agent specifiers, address) pairs can be stored. The address can be one of

  • Local address, eg. an integer index to scheduler's run queue
  • Remote address, eg. a (domain address, agent specifier) pair
  • Special agent address, eg. an integer that identifies the special agent
  • External agent address, eg. an integer that identifies the external agent.

The entries also contain per agent message queues.

The addressing system uses hash table for storing these entries. To ensure effiencient action, hashing is done both ways.

2 Data Structures


Fig. 1 The data structures used int the addressing system implementation

An ActorSpecifier is defined as a 256-bit or 32 char long char array.

A SchedulerID is the local address. It is defined in Scheduler definition.

A RemoteAddress is a struct that includes DomainAddress and an ActorSpecifier valid in that domain. The DomainAddress is specified in Networking Implementation.

An Address consists of an union that can be one of local address (SchedulerID), RemoteAddress, special agent address or external agent address. The latter two are unsigned long integers indices to data structures holding those agents. For the external agents the data structure is the external agent system.

The Address struct also contains enum type that implies the valid field of the union.

An ActorEntry consists of an ActorSpecifier, which is the (unique) key of the data structure, Address that to specifier maps to, the messaging queue, and a bit that indicates whether the agent is blocking (not able to to receive messages).

The AddressingSystem contains an array of null-terminated linked-lists of ActorEntries. The array index is got by counting a hash value from the agent specifier; the hash value can be calculated by simply taking the last n bits of the identifier, since the identifier is supposed to be random. This means that the size of the hash array has to be a power of two, which is reasonable also for performamce reasons (there is no point in extending or shrinking the array by a constant value.)

The entries are also indexed backwards using the address as the hash key. This makes it possible to perform effiecient queries by the address.

3 Functions

In addition to the interface functions defined in Addressing module specification, the addressing system

4 The functions of module Addressing

File addressing-internal.h

C-functions:

  • void addr_addresstoasc(INOUT char* str, IN Address *address)
    Description: Prints the address address to str in readable - that is in hexadecimal - format.

  • Status addr_deliver_messages(IN ActorEntry *entry)
    Description:

  • AddrStatus addr_dumpentry(IN ActorEntry* entry)
    Description: Prints the contents of the entry to STDIN. Returns ADDR_OK, if the entry is not invalid.

  • addr_entriesbyaddr(IN Address* addr)
    Description:

  • addr_entrybyspec(IN ActorSpecifier* spec)
    Description:

  • void addr_freeentry(IN ActorEntry* entry)
    Description: Frees the memory used by the entry. The entry definetely will be invalid after calling this.

  • unsigned addr_hashvalue(IN void *item, IN long size, IN long maxvalue)
    Description: Counts a hash value from an arbitrary long item. Uses very simple and thereby propably non-optimal algorithm. The hash value is returned as the return value. The size argument specifies the length of the item. The hash value will be moduloed between 0 and maxvalue.

  • void addr_hexdump(INOUT char* dest, IN char* source, IN int len)
    Description: Dumps len characters from source to dest in hexadecimal format.

  • Status addr_push_message(IN ActorEntry *entry, struct Message *message)
    Description:

  • AddrStatus addr_readentry(IN int fd)
    Description: Reads an entry from the disk. Returns ADDR_OK on success, ADDR_INTERNAL or ADDR_INVALIDARG otherwise (eg. fd bad etc.)

  • AddrStatus addr_resizehash(AddrResizeAction resizeaction)
    Description: Either doubles or halves the size of the address hash table. If the enlarge argument is ADDR_ENLARGE, enlargement is done, halving takes place otherwise. The table will be reallocated and all entries rehashed. Return ADDR_OK on success.

  • unsigned addr_spechashvalue(IN ActorSpecifier *addr)
    Description: Counts a hash value from a ActorSpecifier. The value is counted simply by anding the first bytes of the specifier, since the ActorSpecifier should adequetely random. The hash value is returned as the return value. The function uses the addresssystem.hashmask as the mask for anding the hash value.

  • void addr_spectoasc(INOUT char* str, IN ActorSpecifier* spec)
    Description: Prints the actor specifier spec to str in readable - that is in hexadecimal - format.

  • AddrStatus addr_writeentry(IN int fd, IN ActorEntry* entry)
    Description: Writes an entry to disk. Returns ADDR_OK on success, ADDR_INTERNAL or ADDR_INVALIDARG otherwise (eg. fd bad etc.)


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