CHAPTER 4 10/29/2015 1 RTS: Kernel Design and Cyclic Executives CE321-fall2013.

Slides:



Advertisements
Similar presentations
What is an Operating System?
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Device Drivers. Linux Device Drivers Linux supports three types of hardware device: character, block and network –character devices: R/W without buffering.
Threads, SMP, and Microkernels
Chapter 3 Process Description and Control
WHAT IS AN OPERATING SYSTEM? An interface between users and hardware - an environment "architecture ” Allows convenient usage; hides the tedious stuff.
Real-Time Kernels and Operating Systems Basic Issue - Purchase commercial “off-the- shelf” system or custom build one Basic Functions –Task scheduling.
© Copyright 2004 Dr. Phillip A. Laplante 1 Kernel Architectures  Polled Loop  Synchronized Polled Loop  State-Based Model  Cyclic Executives  Foreground/Background.
CENG 324 Embedded Computer Systems Lecture 3 General Concepts of RTOS (Real-Time Operating System) Asst. Prof. Tolga Ayav, Ph.D. Department of Computer.
RTOS Concepts and Defn From Pseudokernels to Operating Systems
Computer Systems/Operating Systems - Class 8
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
Realtime Systems Fundamnetals
Chapter 13 Embedded Systems
OS Spring’03 Introduction Operating Systems Spring 2003.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
Chapter 11 Operating Systems
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
© Copyright 2004 Dr. Phillip A. Laplante 1 Real-time operating systems: I  Operating systems taxonomy  Pseudo-kernels  Interrupt driven systems  Preemptive.
1 Chapter 13 Embedded Systems Embedded Systems Characteristics of Embedded Operating Systems.
1 Threads Chapter 4 Reading: 4.1,4.4, Process Characteristics l Unit of resource ownership - process is allocated: n a virtual address space to.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 15 Slide 1 Real-time Systems 1.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Module 2 Clock-Driven Scheduling
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
I/O Computer Organization II 1 Interconnecting Components Need interconnections between – CPU, memory, I/O controllers Bus: shared communication channel.
Threads G.Anuradha (Reference : William Stallings)
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
Overview Task State Diagram Task Priority Idle Hook AND Co-Routines
6/1/ More on Cyclic Executives Simple loop cyclic executive Frame/slots Table-based predetermined schedule cyclic executive Periodic, aperiodic and.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Operating Systems: Internals and Design Principles
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
Threads-Process Interaction. CONTENTS  Threads  Process interaction.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Unit 4: Processes, Threads & Deadlocks June 2012 Kaplan University 1.
CS4315A. Berrached:CMS:UHD1 Introduction to Operating Systems Chapter 1.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
An operating system for a large-scale computer that is used by many people at once is a very complex system. It contains many millions of lines of instructions.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
Real-Time Operating Systems RTOS For Embedded systems.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Processes and threads.
Real time systems RTS Engineering.
RTS: Kernel Design and Cyclic Executives
OPERATING SYSTEMS CS3502 Fall 2017
Hardware Considerations
RTS: Kernel Design and Cyclic Executives
Structure of Processes
Implementation of Cyclic Executive
RTS: Kernel Design 11/30/2018.
RTS: Kernel Design and Cyclic Executives
RTS: Kernel Design 1/2/2019.
Process Description and Control
Threads Chapter 4.
RTS: Kernel Design and Cyclic Executives
RTS: Kernel Design and Cyclic Executives
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Realtime Embedded System Design
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Cyclic executives for Bare Hardware
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 13: I/O Systems “The two main jobs of a computer are I/O and [CPU] processing. In many cases, the main job is I/O, and the [CPU] processing is.
Presentation transcript:

CHAPTER 4 10/29/ RTS: Kernel Design and Cyclic Executives CE321-fall2013

Kernel & Device drivers 10/29/ ShellXWinThread libftp User applications System call interface Devices Process, memory, file system, network managers. Device drivers Kernel Servers (application ~, web ~, component ~) Hardware/controller CE321-fall2013

Operating System Models I. Full-blown operating system like Windows or Linux II. Kernels with core functions (eg. Xinu) III. Small systems with dedicated functions (eg. wii), xbox) IV. Devices with systems optimized for one or more functions (eg. mp3 player) V. Cyclic executive (simple task loops.. Repeating: heart pace maker, handheld games, whole new area called “serious games/gamification”) 10/29/2015 CE321-fall2013 3

Task characteristics of real workload 10/29/ Each task Ti is characterized by the following temporal parameters: Precedence constraints: specify any tasks need to precede other tasks. Release or arrival time: r i,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 P i : 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. CE321-fall2013

Simple kernels 10/29/ 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 CE321-fall2013

Simple kernels: cyclic executives 10/29/ 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(); } CE321-fall2013

Cyclic Executives: Example: Interactive games 10/29/ 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. CE321-fall2013

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

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

Interrupt driven systems: code example 10/29/ void main() { init(); while(TRUE); } void int1(void){ save (context); task1(); retore (context);} void int1(void){ save (context); task1(); restore (context);} Foreground/background systems is a variation of this where main does some useful task in the background; CE321-fall2013

Process scheduling 10/29/ Scheduling is a very important function in a real-time operating system. Two types: pre-run-time and run-time 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. Run-time scheduling: allows events to interrupt processes, on demand allocation of resources, and used complex run- time mechanisms to meet time constraints. CE321-fall2013

10/29/ More on Cyclic Executives Simple loop cyclic executive Frame/slots Table-based predetermined schedule cyclic executive Periodic, aperiodic and interrupt-based task Lets design a cyclic-executive with multiple periodic tasks. 12 CE321-fall2013

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

10/29/ Blind Bingo ( A Simple Example) 14 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; CE321-fall2013

Cyclic Executive Design 1 (pages 81-87) 10/29/ Base tasks, clock tasks, interrupt tasks  Base: no strict requirements, background activity  Clock: periodic with fixed runtime  Interrupt: event-driven preemption, rapid response but little processing Design the slots Table-driven cyclic executive CE321-fall2013

Cyclic executive 10/29/ Each task implemented as a function All tasks see global data and share them Cyclic executive for three priority level 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) Clock tasks, clock sched, base tasks, base sched, interrupt tasks Each clock slot executes, clock tasks, at the end a burn task that is usually the base task Study the figures in pages of your text CE321-fall2013

RT Cyclic Executive Program 10/29/ Lets examine the code: Identify the tasks Identify the cyclic schedule specified in the form of a table Observe how the functions are specified as table entry Understand the scheduler is built-in Learn how the function in the table are dispatched CE321-fall2013

Implementation of a cyclic executive #include #define SLOTX 4 #define CYCLEX 5 #define SLOT_T 5000 int tps,cycle=0,slot=0; clock_t now, then; struct tms n; void one() { printf("Task 1 running\n"); sleep(1); } void two() { printf("Task 2 running\n"); sleep(1); } 10/29/2015 CE321-fall

Implementation (contd.) void three() { printf("Task 3 running\n"); sleep(1); } void four() { printf("Task 4 running\n"); sleep(1); } void five() { printf("Task 5 running\n"); sleep(1); } 10/29/2015 CE321-fall

Implementation (contd.) void burn() { clock_t bstart = times(&n); while ((( now = times(&n)) - then) < SLOT_T * tps / 1000) { } printf (" brn time = %2.2dms\n\n", (times(&n)- bstart)*1000/tps); then = now; cycle = CYCLEX; } 10/29/2015 CE321-fall

Implementation (contd.) void (*ttable[SLOTX][CYCLEX])() = { {one, two, burn, burn, burn}, {one, three, four, burn, burn}, {one, two, burn, burn, burn}, {one, five, four, burn, burn}}; main() { tps = sysconf(_SC_CLK_TCK); printf("clock ticks/sec = %d\n\n", tps); then = times(&n); while (1) { for (slot=0; slot <SLOTX; slot++) for (cycle=0; cycle<CYCLEX; cycle++) (*ttable[slot][cycle])(); }} 10/29/2015 CE321-fall

Summary The cyclic executive discussed the scheduler is built- in. You can also use clock ticks RTC etc to schedule the tasks In order use the cyclic executive discussed here in other applications simply change table configuration, and rewrite the dummy functions we used. 10/29/2015 CE321-fall