CSE466 Autumn ‘00- 1 Task Diagram music serial music_isr serial_isr OS music time slice…signal music task music time slice os time slice os time slice.

Slides:



Advertisements
Similar presentations
Chapter 7 - Resource Access Protocols (Critical Sections) Protocols: No Preemptions During Critical Sections Once a job enters a critical section, it cannot.
Advertisements

Part IV: Memory Management
Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
CSE 522 Real-Time Scheduling (3)
Previously… Processes –Process States –Context Switching –Process Queues Threads –Thread Mappings Scheduling –FCFS –SJF –Priority scheduling –Round Robin.
Engineering Open House Need students to demo their players on –Friday 3-4 –Saturday 10-2.
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
Avishai Wool lecture Introduction to Systems Programming Lecture 4 Inter-Process / Inter-Thread Communication.
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
CSE Fall Introduction - 1 What is an Embedded Systems  Its not a desktop system  Fixed or semi-fixed functionality (not user programmable)
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
By Group: Ghassan Abdo Rayyashi Anas to’meh Supervised by Dr. Lo’ai Tawalbeh.
Intro to OS CUCS Mossé Processes and Threads What is a process? What is a thread? What types? A program has one or more locus of execution. Each execution.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-3 CPU Scheduling Department of Computer Science and Software Engineering.
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
Chapter 6 Scheduling. Basic concepts Goal is maximum utilization –what does this mean? –cpu pegged at 100% ?? Most programs are I/O bound Thus some other.
Scheduling Basic scheduling policies, for OS schedulers (threads, tasks, processes) or thread library schedulers Review of Context Switching overheads.
Real-Time Systems Design1 Priority Inversion When a low-priority task blocks a higher-priority one, a priority inversion is said to occur Assume that priorities:
2-1 The critical section –A piece of code which cannot be interrupted during execution Cases of critical sections –Modifying a block of memory shared by.
Scheduling policies for real- time embedded systems.
Real-Time Operating Systems for Embedded Computing 李姿宜 R ,06,10.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
CPU Scheduling CSCI 444/544 Operating Systems Fall 2008.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Mutual Exclusion.
Cpr E 308 Spring 2004 Real-time Scheduling Provide time guarantees Upper bound on response times –Programmer’s job! –Every level of the system Soft versus.
1 Announcements The fixing the bug part of Lab 4’s assignment 2 is now considered extra credit. Comments for the code should be on the parts you wrote.
Fall 2013 SILICON VALLEY UNIVERSITY CONFIDENTIAL 1 Introduction to Embedded Systems Dr. Jerry Shiao, Silicon Valley University.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
1 Real-Time Scheduling. 2Today Operating System task scheduling –Traditional (non-real-time) scheduling –Real-time scheduling.
CSCI1600: Embedded and Real Time Software Lecture 24: Real Time Scheduling II Steven Reiss, Fall 2015.
CSE 153 Design of Operating Systems Winter 2015 Midterm Review.
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS) 6.0 Introduction A more complex software architecture is needed to handle multiple tasks, coordination,
Silberschatz, Galvin and Gagne ©2011 Operating System Concepts Essentials – 8 th Edition Chapter 2: The Linux System Part 3.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
1.  System Characteristics  Features of Real-Time Systems  Implementing Real-Time Operating Systems  Real-Time CPU Scheduling  An Example: VxWorks5.x.
Undergraduate course on Real-time Systems Linköping University TDDD07 Real-time Systems Lecture 2: Scheduling II Simin Nadjm-Tehrani Real-time Systems.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Operating Systems Scheduling. Scheduling Short term scheduler (CPU Scheduler) –Whenever the CPU becomes idle, a process must be selected for execution.
Process Scheduling. Scheduling Strategies Scheduling strategies can broadly fall into two categories  Co-operative scheduling is where the currently.
Big Picture Lab 4 Operating Systems C Andras Moritz
Outlines  Introduction  Kernel Structure  Porting.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Real-Time Operating Systems RTOS For Embedded systems.
REAL-TIME OPERATING SYSTEMS
Chapter 19: Real-Time Systems
EMERALDS Landon Cox March 22, 2017.
EEE Embedded Systems Design Process in Operating Systems 서강대학교 전자공학과
Topics Covered What is Real Time Operating System (RTOS)
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK)
Applied Operating System Concepts -
Safe Queue? … while (next(head) == tail); // block if full
Networks and Operating Systems: Exercise Session 2
EEE 6494 Embedded Systems Design
Process Synchronization and Communication
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall2014 9/20/2018.
Process management Information maintained by OS for process management
Realtime System Fundamentals : Scheduling and Priority-based scheduling B. Ramamurthy cse321-fall /27/2018.
Operating System Concepts
Chapter 2: The Linux System Part 3
TDC 311 Process Scheduling.
CPU SCHEDULING.
Lecture Topics: 11/1 General Operating System Concepts Processes
CPU scheduling decisions may take place when a process:
Chapter 19: Real-Time Systems
Processes and operating systems
February 5, 2004 Adrienne Noble
CSE 153 Design of Operating Systems Winter 2019
Presentation transcript:

CSE466 Autumn ‘00- 1 Task Diagram music serial music_isr serial_isr OS music time slice…signal music task music time slice os time slice os time slice os time slice Char arrives Music task is never more than one OS time slice away deadline serial_isr signals serial task

CSE466 Autumn ‘00- 2 Reentrant functions…sharing code not data  Are there shared functions that we would like to have? deq? enq? next (same for head or tail)? Q declaration and initialization?  Can task switching clobber local variables (parameters and automatics)?  What happens when this function is interrupted by the OS? unsigned char next(unsigned char current, unsigned char size) { if (current+1 == size) return 0; else return (current+1); } it depends on where the parameters, automatics, and spill values are stored… this one is probably okay! 3 places for parameters a. Registers b. fixed locations c. stack…but not the hardware stack!

CSE466 Autumn ‘00- 3 How about these?  Is this reentrant? void disable(void) { ET0 = 0;}  test for reentrancy: no matter how instructions from separate threads are interleaved, the outcome for all threads will be the same as if there were no other thread.  Is this reentrant? … note: we don’t care about order void setPriority(bit sHi) {PS = sHi; PT = ~sHi;}  When do we need reentrancy in non-multithreaded programming?  How is this normally managed? Thread 1 (sHi = 0)Thread 2 (sHi = 1) PS  0 PS  1 PT  0 PT <- 1

CSE466 Autumn ‘00- 4 Examples of Reentrant functions int sum(tree) { if (!tree) return 0; return sum(tree->left) + sum(tree->right) + tree->val; } reason for reentrancy: re-use code The key to reentrancy: relative addressing Other examples of reentrancy: two tasks share a function, ISR and task share a function

CSE466 Autumn ‘00- 5 Reentrancy in Keil C51  In C51, most parameter passing is done through registers (up to three parameters). Then fixed memory locations are used. Register method is reentrant, the other isn’t.  Local (automatic) variables and temporary values in functions are also mapped to fixed memory locations (w/ overlaying)…definitely not reentrant.  How can we solve this: declare functions to be reentrant as in: unsigned char next(unsigned char current, unsigned char size) reentrant { if (current+1 == size) return 0; else return (current+1); }  BUT…the stack used for reentrant functions is NOT the same as the hardware stack used for return address, and ISR/TASK context switching. There is a separate “reentrant” stack used for that, which is not protected by the TINY OS. It’s a different region of memory, and a fixed memory location is used for the reentrant stack pointer. So this works for FULL and for recursion (no OS).  Conclusion…you can have shared functions in TINY if you:  convince yourself that all parameters are passed through registers  convince yourself are no local variables that use fixed memory locations (compiler can allocate those to registers too)  be sure not not change HW settings non-atomically  or… you disable context switching in shared functions by disabling T0 interrupts  Think of shared functions as critical sections. Consider impact on interrupt latency?

CSE466 Autumn ‘00- 6 Implementation Example: Reentrant, Encapsulated Queue typedef struct qstruct { unsigned char head; unsigned char tail; unsigned char *array; unsigned char size; } fifo; fifo Q; unsigned char array[QSIZE]; void producer(void) _task_ 0 { unsigned char i; bit fail; initq(&Q, array, QSIZE); os_create_task(1); while (1) { do { disable(); fail = enq(&Q,i); enable(); } while (fail); i++; // simulated data } void consumer(void) _task_ 1 { bit fail; unsigned char i; while (1) { os_wait(); disable(); fail = deq(&Q,&i); enable(); if (fail)…else use(I); } Shared functions are okay if we disallow task switch during calls. why? re-entrant stack not protected by Tiny OS. What about C-libraries (subroutine calls?) is this okay for timing if we don’t use it in Tone Gen ISR (overhead)?

CSE466 Autumn ‘00- 7 Back to RTOS  Scheduling  Deadline  Laxity  Rate Monotonic  Semaphores and Synchronization  Memory Management

CSE466 Autumn ‘00- 8 Dynamic Non-preemptive Scheduling music serial music_isr serial_isr OS music time slice…signal music task music time slice os time slice os time slice os time slice Char arrives Music task is never more than one OS time slice away deadline serial_isr signals serial task

CSE466 Autumn ‘00- 9 Dynamic Preemptive Scheduling OS T1/hi T2/lo ISR Pre-emptive: hi priority tasks preempt low priority task. Advantage: Lower latency, faster response for high priority tasks. Disadvantage: Potential to starve a low priority task Tiny: no priority, round robin only. No starvation. Priority Inversion: when T2 disables interrupts Priority Function: any suggestions? signal T2 signal T1, preempt T2 (time slice not up) T2 Completes

CSE466 Autumn ‘ Scheduling Algorithms (Priority Functions)  Egalatarian: Round Robin  Problem: We my have unused compute resources even though we don’t meet some deadliines … it can be non optimal.  Example: system with music task and n non-critical tasks.  if deadline < time_tick * n + music_task then we have a chance to miss the deadline.  If music is higher priority than worst case is: time_tick + music_task  Theory: for a system with N periodic tasks. The system is schedulable if:   Ci/Pi <= 1where Ci is seconds or computation per event i and Pi is period of event I where Ci/Pi is the fraction of time spent dealing with I  Let Ci =.5 and Pi = 2 Ci/Pi =.25 (1/4 of the time)  Rate monotonic scheduling: Priority  Frequency  At run time: Highest priority task always preempts lowest priority task. Proven to be optimal by Liu and Layland.  Real systems rarely fit this model perfectly

CSE466 Autumn ‘ Other Scheduling Algorithms (Priority Functions)  Earliest Deadline First  Keep list of runnable processes sorted by deadline  Algorithm always runs the first item on the list  Least Laxity  Like earliest deadline first, but considers the expected run time of the task. Priority = Deadline – RunTime. Sort the list according to this criteria  Run the first item on the list  Static Priority  Various combinations  Static priority with least laxity as the tie breaker  Engineering Challenge  worst case analysis to satisfy yourself that your system will always meet your deadline given the scheduling policy

CSE466 Autumn ‘ Sharing Resources  What would be an example of a shared resource in a simple 8051-like application (other than RAM variables)  What if you have 64 control lines to manage, with no memory mapped I/O? 8051 can Tiny OS help with this? can memory mapped I/O help with this?

CSE466 Autumn ‘ Semaphores  Preemptable v. Nonpreemtable Resources  CPU – preemptable  Memory – Preemtable  I/O transaction – non preemtable  Network interface hardware – non preemptable  Deadlock: two threads each have a partial set of non-preemptable resources needed to complete their tasks and are waiting for the resources held by the other. You are stuck.  Preconditions for Deadlock to occur  Mutual exclusion: each resource is either currently assigned to exactly one thread or is available  Hold and wait: A process currently holding resources granted earlier can request a new resource without giving up the other  Non-preemtive: Only the holder a resource can give it up  Circular Wait: see above

CSE466 Autumn ‘00- 14

CSE466 Autumn ‘ Coming Up  A little more on OS  Real Time Scheduling Algorithms  Synchronization: Semaphores and Deadlock avoidance  Interprocess Communication  Concept of shared resources: Devices and Drivers  Future  Linux and the Cerfboards  Networking  Product Safety  Java/Object Oriented Programming for Embedded Systems  Design Meeting (Product Ideas…)