RTS Kernel Design and Cyclic Executives Chapter 4

  • Slides: 16
Download presentation
RTS: Kernel Design and Cyclic Executives Chapter 4 10/2/2020 1

RTS: Kernel Design and Cyclic Executives Chapter 4 10/2/2020 1

Kernel & Device drivers Servers (application ~, web ~, component ~) Shell XWin Thread

Kernel & Device drivers Servers (application ~, web ~, component ~) Shell XWin Thread lib ftp User applications System call interface Process, memory, file system, network managers. Kernel Device drivers Hardware/controller Devices 10/2/2020 2

Task characteristics of real workload n Each task Ti is characterized by the following

Task characteristics of real workload n Each task Ti is characterized by the following temporal n n n n parameters: Precedence constraints: specify any tasks need to precede other tasks. Release or arrival time: ri, j: jth instance of ith task Phase Φi: release time of first instant of ith task Response time: time between activation and completion Absolute deadline: instant by which task must complete Relative deadline: maximum allowable response time Period Pi: maximum length of intervals between the release times of consecutive tasks. Execution time: the maximum amount of time required to complete a instance of the task assuming all the resources are available. 10/2/2020 3

Simple kernels n Polled loop: Say a kernel needs to process packets that are

Simple kernels n Polled loop: Say a kernel needs to process packets that are transferred into the DMA and a flag is set after transfer: for(; ; ) { if (packet_here) { process_data(); packet_here=0; } } Excellent for handling high-speed data channels, a processor is dedicated to handling the data channel. Disadvantage: cannot handle bursts 10/2/2020 4

Simple kernels: cyclic executives n Illusion of simultaneity by taking advantage of relatively short

Simple kernels: cyclic executives n Illusion of simultaneity by taking advantage of relatively short processes in a continuous loop: for(; ; ) { process_1(); process_2(); process_3(); … process_n(); } Different rate structures can be achieved by repeating tasks in the list: for(; ; ) { process_1(); process_2(); process_3(); } 10/2/2020 5

Cyclic Executives: example: Interactive games n Space invaders: for(; ; ) { check_for_keypressed(); move_aliens();

Cyclic Executives: example: Interactive games n Space invaders: for(; ; ) { check_for_keypressed(); move_aliens(); check_for_keypressed(); check_collision(); check_for_keypressed(); update_screen(); } } check_keypressed() checks for three button pressings: move tank left or right and fire missiles. If the schedule is carefully constructed we could achieve a very efficient game program with a simple kernel as shown above. 10/2/2020 6

Finite state automata and Co-routine based kernels void process_a(void){ for(; ; ) { switch

Finite state automata and Co-routine based kernels void process_a(void){ for(; ; ) { switch (state_a) { case 1: phase_a 1(); | case 2: phase_a 2(); | …. case n: phase_an(); }}} state_a and state_b are state counters; n Communication between coroutines thru’ global variables; n Example: the famous CICS from IBM : Customer Information Control System n IBM’s OS/2 uses this in Windows presentation management. n void process_b(void){ for(; ; ) { switch (state_b) { case 1: phase_b 1(); | case 2: phase_b 2(); | …. case n: phase_bn(); }}} 10/2/2020 7

Interrupt driven systems n Main program is a simple loop. n Various tasks in

Interrupt driven systems n Main program is a simple loop. n Various tasks in the system are schedules via software or hardware interrupts; n Dispatching performed by interrupt handling routines. n Hardware and software interrupts. n n Hardware: asynchronous Software: typically synchronous n Executing process is suspended, state and context saved and control is transferred to ISR (interrupt service routine) 10/2/2020 8

Interrupt driven systems: code example void main() { init(); while(TRUE); } n Foreground/background systems

Interrupt driven systems: code example void main() { init(); while(TRUE); } n Foreground/background systems is a variation of this where main does some useful task in the background; void int 1(void){ save (context); task 1(); retore (context); } void int 1(void){ save (context); task 1(); restore (context); } 10/2/2020 9

Process scheduling (last lectures) n Scheduling is a very important function in a real-time

Process scheduling (last lectures) n Scheduling is a very important function in a real-time operating system. n Two types: pre-run-time and run-time n Pre-run-time scheduling: create a feasible schedule offline to meet time constraints, guarantee execution order of processes, and prevents simultaneous accesses to shared resources. n Run-time scheduling: allows events to interrupt processes, on demand allocation of resources , and used complex run-time mechanisms to meet time constraints. 10/2/2020 10

More on Cyclic Executives n Simple loop cyclic executive n Frame/slots n Table-based predetermined

More on Cyclic Executives n Simple loop cyclic executive n Frame/slots n Table-based predetermined schedule cyclic executive n Periodic, aperiodic and interrupt-based task n Lets design a cyclic-executive with multiple periodic tasks. 10/2/2020 11 11

The basic systems n Several functions are called in a prearranged sequence n Some

The basic systems n Several functions are called in a prearranged sequence n Some kind of cooperative scheduling n You a have a set of tasks and a scheduler that schedules these tasks n Types of tasks: base tasks (background), interrupt tasks, clock tasks n Frame of slots, slots of cycles, each task taking a cycle, burn tasks to fill up the left over cycles in a frame. 10/2/2020 12 12

Blind Bingo (Homework 2) 10/2/2020 A c b g k V n m L

Blind Bingo (Homework 2) 10/2/2020 A c b g k V n m L s E t y w f D v z x e Display(); Read input(); Loop: update display(); If all done exit(); Read input(); End Loop; 13 13

Cyclic Executive Design 1 (pages 8387) n Base tasks, clock tasks, interrupt tasks n

Cyclic Executive Design 1 (pages 8387) n Base tasks, clock tasks, interrupt tasks n Base: no strict requirements, background activity n Clock: periodic with fixed runtime n Interrupt: event-driven preemption, rapid response but little processing n Design the slots n Table-driven cyclic executive 10/2/2020 14

Cyclic executive n Each task implemented as a function n All tasks see global

Cyclic executive n Each task implemented as a function n All tasks see global data and share them n Cyclic executive for three priority level n The execution sequence of tasks within a cyclic executive will NOT vary in any unpredictable manner (such as in a regular fully featured Operating Systems) n Clock tasks, clock sched, base tasks, base sched, interrupt tasks n Each clock slot executes, clock tasks, at the end a burn task that is usually the base task n Study the figures in pages 83 -86 of your text 15 10/2/2020

RT Cyclic Executive Program n Lets examine the code: n Identify the tasks n

RT Cyclic Executive Program n Lets examine the code: n Identify the tasks n Identify the cyclic schedule specified in the form of a table n Observe how the functions are specified as table entry n Learn how the function in the table are dispatched 10/2/2020 16