Development of Real Time Kernel Master of Technology In EMBEDDED SYSTEM SCHOOL OF ELECTRONICS DEVI AHILYA VISWAVIDYALAYA INDORE. April 2010 Guided by - Dr. RajKamal Head of Dept. Soex. Presented by - Barakha Raghuwanshi M.Tech. E.S.IV Sem
Real Time Operating System Real Time Operating Systems are used to control user programs and system resources in multitasking environment at real time systems. Kernel is the core program of operating system. Characteristics: RTOS kernel should be – Multitasking, pre-emptible. Task Priority, Prevent Starvation Real Time Operation, Fast response time Low Interrupt and Task switching latency. Resource allocation Other Operating systems function as Memory management,
Characteristics of Proposed kernel Multitasking, Priority based scheduler, Which also support Round Robin scheduling if priority of tasks are same. Solve starvation problem. Preemptive scheduler. Support Real time operation Provide Interrupt handlers with low latency Low task switching latency. Memory Management. Inter Task communication.
Task Management Creation of Task Scheduling of Task Finishing of Task Wait Task Resume Task
Os_Create_Task Macro Task_id, Priority Task_id, Priority Memory allocation for (TIB) Task_id, Priority, Context Register etc. Start Stop
Task Management Task Information Block Each task when created have a 16 byte (TIB) task information block in scratchpad RAM. Byte Description Task ID (Starting Location of Task) 2Task priority (“0” highest/”0FFh” lowest) 3Task status Task can execute 0001nnnn-Send message to task‘ nnnn’ Wait for a message ii – Waiting for interrupt ii No task loaded for TIB 4Task stack pointer 5 to 10Task context registers in the stack 11 to 15For saving data and calling subroutine
Memory Allocation : 128 byte RAM are allocated statically as : Task 4 TIB Task 3 TIB Task 2 TIB Task 1 TIB Kernel Semaphore, Flag and Shared variable Bank Registers 70 to 7F 60 to 6F 50 to 5F 40 to 4F 30 to 3F 20 to 2F 00 to 1F
Priority based Pre-emptive Scheduler Start Check State if ready Status of tasks from TIB Take Priorities and Task_id from TIB’s Sort priorities, Make list of Task_id accordingly Yes Compare Sorted priority (rem. task) Context switch flag set Start first task Call next Task Task are called in time slice mode (context switching) Check Flag by RTC Wait task or End Task update State &/or Priority and switch After Each Second Scheduler is started again by RTC it also check starvation of task Same No Set
Context Switching Start Cont. SW flag, Cur_task Set SP, Save Cont reg. Check flag, set next task. End
End Task Start State = Finish Priority = 0FF Switch to Scheduler End
Real Time Clock & Environment Timer Real Time Clock After 5 mille Sec. Context Switching After each Second Scheduler is restarted
Real Time Clock & Environment Tick, Sec., Min., Hour, Flag, Timer Interrupt Set & start Watch Timer Flag If set Yes No Main Prg. Push Context Reg., INC Tick If Tick ==200 Yes No If Sec ==60 INC Sec,Tick=0, Save context Start Scheduler, check starvat. INC Hour INC Min, Sec=0If Min ==60 No Exit RTC If Context Switching Require Yes No Call Context Switch Pop Context Reg Set & start Timer Interrupt Start
Starvation Solution Start Current time – start time =>10 Sec End Call Wait task
Wait Task Start End Delay_Time in hh,mm,ss State = Wait, Resu_Time = Curr_Time + delay_Time, Switch to Scheduler
Resume Task Start State = ready End If Cur_time=>Resu_Time
Inter Task Communication Inter task communication is performed through Messages. Message pointer are sent to mailbox. Task read message from mailbox and make null to mailbox. Os_Create_Mbox, Os_Send_Msg, and Os_Read_msg macro are used for this purpose.
Interrupt Handler Start at ISR Push Context Reg. acall os_int_X Pop Context Reg. Reti
THANK YOU