CS452 - Real-Time Programming - Fall 2008

Lecture 19 - The Administrator


Questions & Comment

  1. projects

Server Structure

What this amounts to is

Proprietor

Controls a resource

Provides mutual exclusion by owning the code that accesses the resource

Proprietor provides service to clients

Like a subroutine call to the client

Proprietors versus Monitors

Monitor Proprietor Comments
access to resource localized localized Means one at a time.
service model self-service full-service
service structure subroutine of client independent task
priority client probably different Do we want client priority or resource priority?
address space client separate Hardware vs software protection
permissions client different Does client have permission to run certain instructions?
CPU same could be different Do you need threading?

Generic Problem: Local Delay

Proprietor begins processing

Can other requests be processed? Possible strategies

  1. refusal
  2. siblings
  3. nested receive
  4. early reply

Administrator, Worker

Generalization of proprietor

Administrator maintains an array of records

Administrator works as he can on any one of the tasks.

Real administrators manage workers

Worker code

Worker( ) {
  Initialize( );
  Receiver ( serverPid, ... );
  Reply( serverPiD )
    // Avoid critical races
  workResult = null;
  FOREVER {
    Send( administrator, workResult, workOrder );
    doWork( workOrder );
  }
}

Administrator code

Administrator( ) {
  Initialize( );
  for ( i = 0; i < NUM_WORKERS; i++ ) worker[i] = Create( workerCode );
  for ( i = 0; i < NUM_WORKERS; i++ ) Send( worker[i], ... , ... );
    // Initialize orderQueue, workerQueue
    // RegisterAs
  FOREVER {
    error = Receive( requester, request )
    if ( request.type == CLIENT ) {
      workOrder = {client = requester, request};
      if ( worker = dequeue( workerQueue ) ) Reply( worker, workOrder );
      else enqueue( orderQueue, workOrder );
    }
    if ( request.type == WORKER ) {
      Reply( request.client, request.result );
      if ( ( workOrder = deQueue( orderQueue) ) ) {
        workOrder = {workOrder.client, workOrder.request};
        Reply( requester, workOrder );
      } else enqueue( workerQueue, requester );
    }
  }
}


Return to: