Initialization and Mainrouchine
General flowchart

OS Initialization

void init_os( void )
{
que_type *que;
que = &TimerQ;
TimerQ.link = (tcb_type *)que;
TimerQ.back_link = (tcb_type *)que;
que = &ReadyQ;
ReadyQ.link = (tcb_type *)que;
ReadyQ.back_link = (tcb_type *)que;
}
Mainrouchine flowchart

void task_main( void )
{
que_type *que;
tcb_type *tcb;
uint8 state;
que = &ReadyQ;
while( TRUE ) {
tcb = que->link;
if( tcb != (tcb_type *)que ) {
DI;
tcb_unlink( tcb );
EI;
state = tcb->next_state;
tcb->next_state = (uint8)( state + 1 );
(*tcb->entry)( state );
}
}
}