Chapter 5: Time Management 1. Time Management OSTimeDly() OSTimeDlyHMSM() OSTimeDlyResume() OSTimeGet() OSTimeSet() 2.

Slides:



Advertisements
Similar presentations
Processing Order: Cooperative vs. Preemptive Process B2 Process A Process C Process B1 Process D Process A (low priority, cyclic) Process C (high priority,
Advertisements

Real-Time Library: RTX
Mike Holenderski, Synchronization 2IN60: Real-time Architectures (for automotive systems)
Real-Time System Project Presented by Che-Wei Chang Advisor: Tei-Wei Kuo 2008/05/28.
Embedded System Presentation Nguyễn Trần Quang Nguyễn Công Vũ 1µC/OS-II.
Lecture 2. Real-time Systems Concept Prof. Taeweon Suh Computer Science Education Korea University COM609 Topics in Embedded Systems.
Department of Mathematics and Computer Science μC/OS-II 2IN60: Real-time Architectures (for automotive systems)
Chapter 5 Processes and Threads Copyright © 2008.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
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 6 Real-Time Embedded Multithreading The Thread – The Essential Component.
MicroC/OS-II Embedded Systems Design and Implementation.
Real-Time Operating Systems Suzanne Rivoire November 20, 2002
ΜC/OS-III Tasks Akos Ledeczi EECE 354, Fall 2010 Vanderbilt University.
Introduction to Embedded Systems
國立台灣大學 資訊工程學系 Introduction to uC/OS-II
Kernel structure & Task management © P.J.Fondse April 2010.
Operating System Concepts and Techniques Lecture 5 Scheduling-1 M. Naghibzadeh Reference M. Naghibzadeh, Operating System Concepts and Techniques, First.
The  C/OS-II Real-Time Operating System.  C/OS-II Real-time kernel –Portable, scalable, preemptive RTOS –Ported to over 90 processors Pronounced “microC.
Implementing Processes and Process Management Brian Bershad.
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.
1 RTOS Design Some of the content of this set of slides is taken from the documentation existing on the FreeRTOS website
Processes & Threads Bahareh Goodarzi. Single & Multiple Thread of control code files data code files data.
Linux Kernel introduction COSC 513 Xiaoping Yang.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Scheduling in µC/OS-III Akos Ledeczi EECE 6354, Fall 2015 Vanderbilt University.
Real Time Operating Systems
1 Concurrency Architecture Types Tasks Synchronization –Semaphores –Monitors –Message Passing Concurrency in Ada Java Threads.
Real-time OS Hao-yuan Chin Feb. 18, Institute of Electronics, National Chiao Tung University Real-time OS 1 Outline Introduction to RTOS Introduction.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
CPS110: Implementing threads Landon Cox. Recap and looking ahead Hardware OS Applications Where we’ve been Where we’re going.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
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.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Operating Systems Processes and Threads.
uC/OS-II Real-Time Systems Concepts Kernel Structure Task Management
Threads A thread is an alternative model of program execution
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Time Management.  Time management is concerned with OS facilities and services which measure real time.  These services include:  Keeping track of.
Lab 3 Department of Computer Science and Information Engineering National Taiwan University Lab3 – μC/OS 2015/10/13/ 13 1.
Embedded Computer - Definition When a microcomputer is part of a larger product, it is said to be an embedded computer. The embedded computer retrieves.
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.
1 Critical Section Problem CIS 450 Winter 2003 Professor Jinhua Guo.
SOC Consortium Course Material SoC Design Laboratory Lab 8 Real-time OS - 1 Speaker: Yung-Chih Chen Advisor: Prof. Chun-Yao Wang November 17, 2003 Department.
1 Round Robin Non-Preemptive Scheduler Lecture 12.
2-1 Chapter 2 Real-Time Systems Concepts. 2-2 Foreground/Background Systems BackgroundForeground ISR Time Code execution application consists of an infinite.
Chapter 3: Kernel Structure 1. Objectives To understand what a task is. To learn how μ C/OS-II manages tasks. To know how an interrupt service routine.
Real Time Operating Systems Johan Dams
Chapter 13: Porting μC/OS-II 1. Outline Requirements Hardware Software Tasks of Porting µC/OS-II OS_CPU_C.H OS_CPU_C.C OS_CPU_A.ASM Testing a port 2.
Chapter 3: Kernel Structure 1. Objectives To understand what a task is. To learn how μ C/OS-II manages tasks. To know how an interrupt service routine.
Chapter 1: Getting Started with μC/OS-II 1. kernel Introduction 2 LinuxμC/OS-II Task (process) kernel Device driver User mode (0-3G) (Kernel mode) 3G-4G.
Outlines  Introduction  Kernel Structure  Porting.
Chapter 5 Time Management use clock tick to provide a periodic interrupt to keep track of time delays and timeouts The frequency of the clock tick depends.
Lab 5 Department of Computer Science and Information Engineering National Taiwan University Lab5 – μC/OS 2016/5/31/ 13 1.
Chapter 2: Operating System Concepts 1. Objectives To know essential topics on the design of (embedded) operating systems 2 1.Task & resources 2.Kernel.
Computer System Structures
Chapter 3: Kernel Structure
REAL-TIME OPERATING SYSTEMS
Process concept.
Chapter 13: Porting μC/OS-II
Chapter 4: Task Management
Chapter 2: Operating System Concepts
Interrupt and Time Management in µC/OS-III
Round Robin Non-Preemptive Scheduler
Multithreading.
Computer System Laboratory
Chapter 6: Event Control Block (ECB)
Chapter 3: Process Management
Presentation transcript:

Chapter 5: Time Management 1

Time Management OSTimeDly() OSTimeDlyHMSM() OSTimeDlyResume() OSTimeGet() OSTimeSet() 2

Properties of μC/OS-IITime Management The system overhead is proportioned to the frequency of ticks – Compared to the uTime package of linux Delay a task until tx t=OSTimeGet(); if (tx-t>0) OSTimeDly(tx-t); – What’s wrong 3 void InterruptServiceRoutine{. } void HeighPriorityTask {. } OSTime= 5 OSTime= 6

Time Management Services OSTimeDly(), OSTimeDlyHMSM() – Allow a task to delay itself for a number of ticks – If your application must delay for at least one tick, you must call OSTimeDly(2) OSTimeDlyResume() Resume a delayed task OSTimeSet(), OSTimeGet() Set/obtain the system timer 4

OSTimeDly() 5 Because the task is no longer ready, the scheduler should be called to active the next highest priority task. Store the number of ticks in the TCB of the current task.

OSTimeDlyHMSM() 6

OSTimeTick() 7 OSTickISR() { OSTimeTick() } OSTimeTick() { foreach(…) }

Timer (1) 8 TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly OSTickISR() { OSTimeTick() } OSTimeTick() { foreach(…) } OSTCBList

Timer (2) 9 TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly TCB OSTCBDly OSTickISR() { OSMBoxPost() } TickTask() { OSMBoxPend() OSTimeTick() OS_Sched() } OSTimeTick() { foreach(…) } OSTCBList

OSTimeDlyResume() 10 See if the task is ready to run. A delayed task might also have been suspended. Make the task ready to run Clear the time delay

OSTimeDlyResume() 11 OSChangePrio() may change this value

OSTimeGet() & OSTimeSet() 12 The tick interrupt may read/write the variable “OSTime” while we call OSTimeGet/Set.

OSTimeDlyUntil() 13 void function1() { OS_ENTER_CRITICAL(); t=OSTimeGet(); if (tx-t>0) OSTimeDly(tx-t); OS_EXIT_CRITICAL(); } void function2() { OSSchedLock(); t=OSTimeGet(); if (tx-t>0) OSTimeDly(tx-t); OSSchedUnlock() }

OSTimeDlyUntil() 14 void function2() { OSTimeLockUntil(tx); } /* OSTimeDlyUntil() is a new system call.*/ void OSTimeDlyUntil(INT16U tx) { int ticks; OS_ENTER_CRITICAL(); ticks = tx- OSTime if (ticks > 0) { if ((OSRdyTbl[OSTCBCur->OSTCBY] &= ~OSTCBCur->OSTCBBitX) == 0) { OSRdyGrp &= ~OSTCBCur->OSTCBBitY; } OSTCBCur->OSTCBDly = ticks; OS_EXIT_CRITICAL(); OS_Sched(); }

A Lightweight Implementation of Time Service (BSD) 15 Idea: using a linked list to describe waiting events – The list is sorted in time order – The time for each event is kept as a difference from the time of the previous event in the linked list 3ticks (3) 2ticks (5) 4ticks (9) 1ticks (10) NIL

Example 16 INT32U TestNewTimer (void) { OSTimeDly(16);/*at time 16*/ } 12 ticks (12) 2 ticks (14) 4 ticks (18) 1 ticks (19) NILbefore 12 ticks (12) 2 ticks (14) 2 ticks (16) 2 ticks (18) 1 ticks (19) NIL after

Enhancement The hardware timer can trigger the software timer until the time of the next time event. 17 3ticks (3) 2ticks (5) 4ticks (9) 1ticks (10) NIL Set H/W timer = 3 Set H/W timer = 2 Set H/W timer = 4 Set H/W timer = 1

Enhancement The relation between time granularity and system overhead can be broken if we modify the tick service. We should maintain the semantics of the time-related services 18