CS452 - Real-Time Programming - Winter 2016

Lecture 10 - Name Server

Public Service Annoucements

  1. Due date for kernel 2: 1 February, 2016.
  2. Updated k2.pdf

Inter-task Communication

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

    initialize;
    FOREVER
       Receive( *tid, request );
       switch( request.type ) {
       case PRODUCER:
	  if ( consumer-queued )
	     Reply ( dequeue( consumer ), request.content );
	     Reply ( producer );
	     break;
	  if ( space-available ) 
	     store( request.content );
	     Reply( producer );
	     break;
	  queue( producer );
	  break;
       case CONSUMER:
	  if ( producer-queued )
	     Reply ( consumer, content );
	     Reply ( dequeue( producer) )
	     break;
	  if ( content-available )
	     Reply( consumer, content );
	     break;
	  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: