CS452 - Real-Time Programming - Spring 2017

Lecture 10 - Name Server

Public Service Annoucements

  1. Due date for kernel 2: 29 May, 2017.
  2. Reminder about performance measurements.

Send/Receive/Reply: Sequence of States

Sender

  1. When Send is called
  2. When Receiver calls Receive.
  3. Reply_Blocked -> Ready (both sender and replier)

Receiver

  1. Active -> Send_Blocked
  2. Send_Blocked -> Ready
  3. Ready -> Active
  4. ...
  5. Reply

There are two cases

Send before Receive

Sender

Action

Sender

State

Receiver

Action

Receiver

State

Comments
active n/a
Send RCV_BL !SND_BL sender added to receiver's sendQ
RCV_BL active
RPL_BL Receive ready request copied
sender deleted from receiver's sendQ
RPL_BL active service performed
ready Reply ready reply copied
sender/receiver synchronized

Receive before Send

Sender

Action

Sender

State

Receiver

Action

Receiver

State

Comments
n/a active
n/a Receive SND_BL receiver's sendQ empty
active SND_BL
Send [RCV_BL]
RPL_BL
ready request copied
RPL_BL active service perfomed
ready Reply ready reply copied
sender/receiver synchronized


Practical Details


Servers

What is a server?

Servers provide data and/or synchronization to clients. A server is

How are servers implemented?

We usually try to make each service simple, so the code of the server that provides it is simple.

A typical server has a lot in common with a warehouse. (The result below assumes that production and consumption may occur in any order. Here the warehouse is stripped down to a place where producers and consumers wait for their counterparts in order.)

    initialize;
    FOREVER
       Receive( *tid, request );
       switch( request.type ) {
       case PRODUCER:
	  if ( consumer-queued )
	     Reply ( producer );
	     Reply ( dequeue( consumer ), request.content );
	  else
	     queue( producer );
	  break;
       case CONSUMER:
	  if ( producer-queued )
	     Reply ( consumer, producer.content );
	     Reply ( dequeue( producer ) );
	  else
	     queue( consumer );
	  break;
       }
  


Name Server

What is a name server?

Why Do We Need a Name Server

Names constant across applications
& executions
interface Associated with a set of services,
an API.
Task Ids vary across applications
& executions
implementation Associated with particular code
and data (an execution)

How do You Get the Task Id of the Name Server?

Remember what you did when you were installing Linux?

  1. You typed in the IP-address of the name server.
  2. Make it a constant across executions.
  3. Is there any other way that's not disgusting.

Name Server API

    int RegisterAs( char *name );
  
    int WhoIs( char *name );
  

Name Server Semantics

RegisterAs

WhoIs

Comments

Analogy to Name Service on the Internet

Name Server Implementation

What does the client need to know in order to use the name server?

  1. its taskid
  2. the requests it services
  3. its API: function signatures and type definitions

User Pseudo-Code

First we need a struct for requests and reponses.

    struct NSreq {
		  int type;
		  char name[MAXNAMESIZE];
		  int tid;
		 }
  
Using this struct send to the name server looks something like
    Send( NSTid, (NSmsg *) msg, sizeof( NSmsg ), (NSmsg *) msg, sizeof ( NSmsg ) );
  

Name Server

  1. One service associates a taskid with a name
  2. The second service looks up the taskid and replys it to the requestor

Questions

  1. How much will this code run?
  2. What should happen when a WhoIs request is made for an unregistered name?
  3. How would you implement insert & lookup?
  4. What should be allowable as a name?

Return to: