Implementation

The Name Server is implemented as a task that waits for requests (messages) and operates with the Name Server database in its main function. The requests contain a key to the Name Server database and an operation type.

A simple hash table is the data structure used for the database. The chaining technique is used to avoid collisions. In other words, in the chaining approach, the hash table is an array of pointers to the head of linked lists, i.e., each index has its own linked list. The hash table contains 256 indexes, which can speed up the operations up to 256 times compared to a simple linked list’s linear time. Hash table memory organization can be seen in Name Server hash table.

The Name Server task needs the memory space for the hash table and the space for registering entries. This memory has to be provided in the PxNamesrvInit.

Name Server entry consists of three parts — header, stored information, memory class overhead — that can be seen in the Name Server hash table. The header consists of four variables, each having 4 bytes (16B needed for header):

  • link - pointer to next element

  • name - Name Server ID (key to the database)

  • info_length - length of the data stored in the database

  • name_info - data stored in the database

Name Server API

Name Server uses message-based API that consists of these functions:

PxError_t PxNameQuery(PxNameId_t name, PxSize_t buffer_length, void  *buffer, PxSize_t *info_length);
PxError_t PxNameRegister(PxNameId_t name, PxSize_t info_length, void const *info);
PxError_t PxNameReRegister(PxNameId_t name, PxSize_t info_length, void const *info);

Name Server receives requests (messages) from the Name Server API functions, does the hash table lookup to find a place for a new or already existing entry, processes the request and sends the message back (releases it) with the operation results.