CS452 - Real-Time Programming - Spring 2008
Lecture 20 - AwaitEvent
Questions & Comment
- 16550 UART
AwaitEvent
Low-level primitive
int AwaitEvent( int EventType );
Implementation notes
- Event may already have occurred
- Should an event be buffered?
- It depends on the type of event.
- What does AwaitEvent( ) return?
- errors
- no such event type
- time-out?
but not for the timer event
- volatile data
- but what about UART buffers
- specific example of the 'common type' problem.
- AwaitEvent( ) can service the device.
- Then it must return the volatile data
- Need to think of priorities when you partition the work
What do we do when there is no task ready to be scheduled?
- Kernel has interrupts turned off
- Therefore need
IdleTask( )
. Why?
- What does IdleTask( ) do?
void IdleTask( ) {
FOREVER ;
}
But in reality it could do anything
- Search for extra-terrestrial intelligence
- Calculate the digits of pi
- Collect statistics to improve calibrations
Clock Server
Hardware
Intel decided exactly how you should use the timers when they designed the
south bridge.
- Specifically, they cannot be ganged together.
- So the minimum rate at which the clock can tick is (timer clock
frequency) / (2^16)
Interrupt controller we already discussed.
General description of clock and PIC included in 82801 documentation.
Software
What is the structure of the service regime?
- type of requests
- rate of requests
- service time per request
Who should initialize timer?
- We should try to localize everything hardware-specific.
Server
void ClockServer( ) {
Tid requester;
RegisterAs( "ClockServer" );
notifier = Create( ... );
if( notifier < 0 )
// handle error
FOREVER {
length = Receive( *requester, request, requestlen );
if ( length < 0 )
// handle error
else if (!( type = decode( request ) ) )
// handle error
else {
switch( type ) {
case TICK:
time++;
// service queues
break;
case XXX:
// et cetera
}
}
}
Notifier
void TickNotifier( ) {
server = WhoIs( "clockserver" );
if ( server < 0 )
//handle error
FOREVER {
error = AwaitInterrupt( TIMER );
if ( error < 0 )
//handle error
error = Send( server, nullmessage );
if ( error < 0 )
//handle error
}
}
All the error handling code should be telling you something. What?
Serial Server
Policy issues
- One or two servers?
- How should screen echo be handled?
- and DELETE/BS, and line-editting, and ...
- How should the buffers in the UART be handled?
- Who will initialize the hardware?
- What traffic do I expect through the server?
- Should the be I/O units above the single character level?
As a general policy we would like to concentrate the hardware
dependence
Hardware
Stubs
Software
Return to: