// Initialize Hardware
Receive( serverPid )// Find server Pid
Reply( ) // Should be the last thing before FOREVER
FOREVER {
AwaitEvent( eventid ); //Should event ids be hard coded?
// Acquire volatile data
Send( serverPid, .... )
}
notifierPid = Create( notifier ); //Should notifier code name be hard coded?
Send( notifierPid, MyPid( ), ... ); //On return noifier is known to be okay
RegisterAs( ); //On return requests can begin.
FOREVER {
requesterPid = Receive( request );
switch ( request.type ) {
case NOTIFIER:
provideNotifierService( ); // may release queued clients
doReplies( );
case CLIENT:
if ( provideClientService( ) ) Reply( requesterPid );
else enQueue( requesterPid );
}
}
Remember that all the calls provide error returns. You can/should use them for error recovery
Simplest is best
// Initialize Hardware
Receive( )// Find courier Pid
Reply( ) // Should be the last thing before FOREVER
FOREVER {
AwaitEvent( eventid ); //Should event ids be hard coded?
// Acquire volatile data
Receive( courierPid, .... )
}
notifierPid = Create( notifier ); //Should notifier code name be hard coded?
courierPid = Create( courier );
Send( courierPid, { notifierPid } ... ) // On return courier is okay
Send( notifierPid, courierPid( ), ... ); //On return noifier is known to be okay
RegisterAs( ); //On return requests can begin.
FOREVER {
requesterPid = Receive( request );
switch ( request.type ) {
case COURIER:
provideCourierService( ); // may release queued clients
doReplies( );
case CLIENT:
if ( provideClientService( ) ) Reply( requesterPid );
else enQueue( requesterPid );
}
}
Receive( ) // Now knows the the server/notifier Pids
Reply( server ) // Should be the last thing before FOREVER
FOREVER {
Send( notifierPid ... );
Send( serverPid ... );
}
This gets you through a bottleneck where no more than two events come too fast.
Remember that all the calls provide error returns. You can/should use them for error recovery
Add buffer & courier between courier and server.
// Doesn't need Pids
// Needs to give out his Pid
FOREVER {
Receive( requesterPid, request );
switch ( request.type ) {
case COURIER:
enQueue( queue, request.data );
Reply( );
case SERVER:
Reply( queue );
}
}
This structure clears up problems when the notifier runs too fast for the server.
Two issues:
Define `bottleneck'.
Called a guard.
What this amounts to is
Return to: