IN2305-II Embedded Programming Lecture 7: More OS Services.

Slides:



Advertisements
Similar presentations
Resource management and Synchronization Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Advertisements

Real-Time Library: RTX
HW/SW Interface Operating Systems Design and Implementation.
5.6 Semaphores Semaphores –Software construct that can be used to enforce mutual exclusion –Contains a protected variable Can be accessed only via wait.
Concurrency: Deadlock and Starvation Chapter 6. Revision Describe three necessary conditions for deadlock Which condition is the result of the three necessary.
Embedded Systems More Operating System Services C.-Z. Yang Sept.-Dec
IN2305-II Embedded Programming Lecture 4: Interrupts.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
1 When to Switch Processes 3 triggers –System call, Interrupt and Trap System call –when a user program invokes a system call. e.g., a system call that.
IN2305-II Embedded Programming Lecture 6: RTOS Introduction.
P ORTING F REE RTOS TO MCB2140 BOARD Ashwini Athalye Sravya Kusam Shruti Ponkshe.
Process Description and Control A process is sometimes called a task, it is a program in execution.
IN2305-II Embedded Programming Lecture 5: Survey of SW Architectures.
Real-Time Operating Systems Suzanne Rivoire November 20, 2002
ΜC/OS-III Tasks Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Advanced Embedded Systems Design Pre-emptive scheduler BAE 5030 Fall 2004 Roshani Jayasekara Biosystems and Agricultural Engineering Oklahoma State University.
Real Time Operating System
Real-Time Kernel (Part 1)
Advanced Operating Systems CIS 720 Lecture 1. Instructor Dr. Gurdip Singh – 234 Nichols Hall –
CS 153 Design of Operating Systems Spring 2015 Lecture 11: Scheduling & Deadlock.
Real Time Operating Systems Lecture 10 David Andrews
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:
Getting Started with the µC/OS-III Real Time Kernel Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
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.
Today’s Agenda  Quick Review  Finish Java Threads  The CS Problem Advanced Topics in Software Engineering 1.
The Functions of Operating Systems Interrupts. Learning Objectives Explain how interrupts are used to obtain processor time. Explain how processing of.
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Real Time Operating Systems
REVIEW OF COMMONLY USED DATA STRUCTURES IN OS. NEEDS FOR EFFICIENT DATA STRUCTURE Storage complexity & Computation complexity matter Consider the problem.
Overview Task State Diagram Task Priority Idle Hook AND Co-Routines
RTOS task scheduling models
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
Real Time Operating Systems Michael Thomas Date: Rev. 1.00Date.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
MicroC/OS-II S O T R.  MicroC/OS-II (commonly termed as µC/OS- II or uC/OS-II), is the acronym for Micro-Controller Operating Systems Version 2.  It.
Chapter 13 – I/O Systems (Pgs ). Devices  Two conflicting properties A. Growing uniformity in interfaces (both h/w and s/w): e.g., USB, TWAIN.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
CE Operating Systems Lecture 2 Low level hardware support for operating systems.
CSCI1600: Embedded and Real Time Software Lecture 16: Advanced Programming with I/O Steven Reiss, Fall 2015.
Tasks and Task Management : --Time-critical tasks --Contending tasks --Communicating tasks.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS) 6.0 Introduction A more complex software architecture is needed to handle multiple tasks, coordination,
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
1 Run-to-Completion Non-Preemptive Scheduler. 2 In These Notes... What is Scheduling? What is non-preemptive scheduling? Examples Run to completion (cooperative)
1 J.O. KLEIN Institut Universitaire de Technologie de CACHAN Université PARIS SUD - FRANCE An Introduction to Real Time Operating System.
Where Testing Fails …. Problem Areas Stack Overflow Race Conditions Deadlock Timing Reentrancy.
Chapter 7. More Operating System Services
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Chapter 7: Semaphore Management Seulki Lee 1. Semaphore?  A protocol mechanism offered by most multitasking kernels  Control access to a shared resource.
2-1 Chapter 2 Real-Time Systems Concepts. 2-2 Foreground/Background Systems BackgroundForeground ISR Time Code execution application consists of an infinite.
Outlines  Introduction  Kernel Structure  Porting.
Advanced Operating Systems CIS 720
Topics Covered What is Real Time Operating System (RTOS)
Background on the need for Synchronization
6.0 INTRODUCTION TO REAL-TIME OPERATING SYSTEMS (RTOS/RTK)
Lecture Topics: 11/1 Processes Process Management
Interrupt and Time Management in µC/OS-III
Getting Started with the µC/OS-III Real Time Kernel
An Embedded Software Primer
An Embedded Software Primer
Writing and Testing Your First RTOS Project with MQX
An Embedded Software Primer
Computer System Overview
Lecture 2 Part 2 Process Synchronization
CSE 153 Design of Operating Systems Winter 19
Embedded System Development Lecture 10 3/21/2007
Akos Ledeczi EECE 6354, Fall 2017 Vanderbilt University
Presentation transcript:

IN2305-II Embedded Programming Lecture 7: More OS Services

in2305-II: L72 Queues, Mailboxes, Pipes Semaphores: synchronization Queues etc.: synchronization + data communication No shared data problems unless you pass pointer to the original data in other task (cf. Fig. 7.4) Same pitfalls as semaphores (deadlock, etc.)

in2305-II: L73 Time Delay Function X32 delay(dt) : busy waits (loops) until X32 clock has advanced dt ms (“polling”) OS OS_Delay(n) : suspends caller (task) until time has advanced n OS ticks (“interrupt”) OS delay is more efficient: schedules other tasks (does useful work) while waiting for time to pass OS now needs a timer interrupt mechanism to periodically check if time has passed (NOTE: until now the OS services (context switching) were initiated by task calls, no interrupts were needed.. yet) Timer interrupt called tick (e.g., 1 ms) which determines delay resolution (and OS overhead..)

in2305-II: L74 OS Delay Processing Task 2 timer IRQ timer ISR Task 1 OS_Delay(2) RTOS highest priority task starts first context switch delay expired tick

in2305-II: L75 X32: Demo Demo.. (x32_projects.tgz: ucos_delay.c)

in2305-II: L76 RTOS and Interrupts (1) Apart from OS-supported delays (and timers) RTOS and interrupts are separate worlds Nevertheless, any embedded program will use interrupts in order to react/respond to external world (buttons, I/O lines, UART, decoder,..) In order to guarantee proper functioning of the RTOS in the presence of interrupts, a number of programming rules must be obeyed:

in2305-II: L77 RTOS and Interrupts (2) Rule 1: an ISR must not call any RTOS function that might block the caller. So no pend -type calls (this is why semaphores are not allowed to protect shared data in ISRs). Violating this rule may affect response time and may even cause deadlock! Rule 2: An ISR must not call any RTOS function that might cause a context switch unless RTOS knows that it’s an ISR (and not a task) that is calling. So no post - type calls (which is typical use!) unless RTOS knows it’s an ISR. Violating this rule may allow RTOS to switch to other task and the ISR may not complete for a long time, thus greatly affecting response time!

in2305-II: L78 Example Violating Rule 1 void isr_read_temps(void) // (reactor) { OS_Pend(s); iTemp[0] = peripherals[..]; iTemp[1] = peripherals[..]; OS_Post(s); } voidmain(void) {... OS_Pend(s); iTemp[0] = iTemperatures[0]; iTemp[1] = iTemperatures[1]; OS_Post(s);... } interrupt ISR Deadlock!

in2305-II: L79 Example Violating Rule 2 voidisr_buttons(void) // (UTMS) { if (peripherals[BUTTONS] & 0x01) // button 0 OS_Post(event); // signal event } voidvButtonTask(void) { while (TRUE) { OS_Pend(event); // wait for event printf(“current float levels: \n”); !! list them }

in2305-II: L710 Example Violating Rule 2 vLevelsTask button ISR vButtonTask RTOS context switch after ISR finished How ISRs should work: OS_Post vLevelsTask button ISR vButtonTask RTOS context switch before ISR finished! What would really happen: OS_Post

in2305-II: L711 Solution to Satisfy Rule 2 (uC/OS) Let the RTOS know an ISR is in progress by calling OSIntEnter() / OSIntExit() (uC/OS) voidisr_buttons(void) // (UTMS) { OSIntEnter(); // warn uC/OS not to reschedule if (peripherals[BUTTONS] & 0x01) // button 0 OS_Post(event); // signal event OSIntExit(); // uC/OS free to reschedule } vLevelsTask button ISR vButtonTask RTOS OS_Post but NO context switch

in2305-II: L712 Rule 2 and Nested Interrupts (X32) Apart from calling OSIntEnter() / OSIntExit() keep count of interrupt nesting; only allow RTOS rescheduling when all ISRs are finished low prio task low prio ISR high prio task RTOS OS_Post high prio ISR If no ISR nesting counted, RTOS would reschedule instead of allowing low prio ISR to finish!

in2305-II: L713 X32: Demo Demo.. (x32_projects.tgz: ucos_isr.c)