You are on page 1of 6

Principales of RTO

Basic design using a real time system


• telegraph operation
Interrupt routine
Receive network
frame

DDP protocol task


determines if frame
is address to telegraph Interrupt routine receive
telegraph serial data

ADSP protocol task


determines if frame
is print data , status
request , etc. Serial port task determines
if serial data contains new
status
Short interrupt routines
• Reasons for short routines
1. Even the lowest priority interrupt routine is
executed in preference to the highest-priority
task code
2. Interrupt routine tends to de more bug-
prone and harder to debug than task code
s/w for a s/m with the following
characteristics
• The system must respond to command coming
from a serial port
• Command always end with a carriage return
• Command arrive one at a time
• The serial port hardware can only store one
received character at a time
• The system respond to command (quickly)
• Ex: keeping interrupt routines short
#define SIZEOF_CMD_BUFFER 200
Char a_chcommandbuffer[SIZEOF_CMD_BUFFER];
#define MSG_EMPTY((char*)0)
Char *mboxcommand-MSG_EMPTY;
#define MSG_COMMAND_ARRIVED((char*)1)
Void interrupt vgetcommandcharacter9void)
{
Static char *p_chcommandbuffertail – a_chcommandbuffer;
Int ierror;

*p_chcommandduffertail-
!! Read received character from h/w;
If (*p_chcommandbuffertail _ ‘r’)
sc_post (&mboxcommand MSG_COMMAND_ARRIVED, &IERROE);
++p_commandbuffertail;
If(p_chcommandbuffertail _
&a_chcommandbuffer[SIZEOF_CMD_BUFFER])
p_chcommandbuffertail -a_chcommandbuffer
!! Reset the h/w as necessary.
}
Void vinterpretcommandtask (void)
{
Static char *p_chcommandbufferhead – a_chcommandbuffer;
Int ierror;

While (TURE)
{
/*wait for the next command to arrive,*/
Sc_pend (&mboxcommand, WAIT_FOREVER.&ierror);
/*we have a command.*/
!! Interpret the command at p_chcommandbufferhead

!!advance p_post carriage return


}
}

You might also like