Dr. Hugh Melvin, Dept. of IT, NUI,G1 POSIX POSIX: Portable OS Interface –IEEE standard –Mandatory + Optional parts Mostly based on and adopted by Unix.

Slides:



Advertisements
Similar presentations
Real-Time Library: RTX
Advertisements

Linux Scheduler. Linux is a multitasking OS Deciding what process runs next, given a set of runnable processes, is a fundamental decision a scheduler.
Operating Systems: Introduction n 1. Historical Development n 2. The OS as a Resource Manager n 3. Definitions n 4. The Process.
CS4315A. Berrached:CMS:UHD1 CPU Scheduling Chapter 7.
Sogang University Advanced Operating Systems (Process Scheduling - Linux) Advanced Operating Systems (Process Scheduling - Linux) Sang Gue Oh, Ph.D. .
The Process Control Block From: A Process Control Block (PCB, also called Task Control Block or Task Struct) is.
CHAPTER 5 Organization of Schedulers Scheduling Methods Priority Inversion Multiprocessor and Distributed Scheduling Process and Thread Scheduling.
Priority Inversion Higher priority task is blocked by a lower priority one. May be caused by semaphore usage, device conflicts, bad design of interrupt.
Timers Timer – Keeps track of the passage of time Simple Timer – Measures elapsed time, reporting it when queried Interval Timer – –Generates an interrupt.
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)
Wk 2 – Scheduling 1 CS502 Spring 2006 Scheduling The art and science of allocating the CPU and other resources to processes.
Chapter 19: Real-Time Systems Silberschatz, Galvin and Gagne ©2005 AE4B33OSS Chapter 19: Real-Time Systems System Characteristics Features of Real-Time.
Real-Time Operating Systems Suzanne Rivoire November 20, 2002
Signals & Timers CS241 Discussion Section Spring 2009 Week 6.
ELN5622 Embedded Systems Class 8 Spring, 2003 Aaron Itskovich
Introduction to Embedded Systems A/D & D/A Conversion Lecture 20.
OPERATING SYSTEMS 9 – SCHEDULING PIETER HARTEL 1.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
Tittle:Real Time Linux
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:
1 Threads Chapter 11 from the book: Inter-process Communications in Linux: The Nooks & Crannies by John Shapley Gray Publisher: Prentice Hall Pub Date:
Real-Time Scheduling CS4730 Fall 2010 Dr. José M. Garrido Department of Computer Science and Information Systems Kennesaw State University.
PART II Operating Systems LECTURE 9 PROCESSES MANAGEMENT Ştefan Stăncescu 1.
Linux Kernel introduction COSC 513 Xiaoping Yang.
Real-time Operating Systems. V1.4Real-Time Operating Systems2 OS Requirements Mechanisms and services to perform: –real-time scheduling –resource management.
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Reference: Ian Sommerville, Chap 15  Systems which monitor and control their environment.  Sometimes associated with hardware devices ◦ Sensors: Collect.
The Linux Operating System C. Blane Adcock Bryan Knehr Kevin Estep Jason Niesz.
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Timers and Clocks.
RTOS task scheduling models
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Scheduling II: priority scheduling.
Traditional UNIX Scheduling Scheduling algorithm objectives Provide good response time for interactive users Ensure that low-priority background jobs do.
Scis.regis.edu ● CS-434: Object-Oriented Programming Using Java Week 8 Dr. Jesús Borrego Adjunct Faculty Regis University 1.
RTX - 51 Objectives  Resources needed  Architecture  Components of RTX-51 - Task - Memory pools - Mail box - Signals.
CS140 Project 1: Threads Slides by Kiyoshi Shikuma.
Real Time Operating Systems Michael Thomas Date: Rev. 1.00Date.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks II.
Multi-Tasking The Multi-Tasking service is offered by VxWorks with its real- time kernel “WIND”.
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.
OBJECTIVE: To learn about the various system calls. To perform the various CPU scheduling algorithms. To understand the concept of memory management schemes.
Copyright ©: Nahrstedt, Angrave, Abdelzaher, Caccamo1 Timers and Clocks.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
19.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts with Java – 8 th Edition Chapter 19: Real-Time Systems.
Chapter 19: Real-Time Systems Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 19: Real-Time Systems System Characteristics.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Linux Process Management. Linux Implementation of Threads Threads enable concurrent programming / true parallelism Linux implementation of threads.
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.
MIDTERM REVIEW CSCC69 Winter 2016 Kanwar Gill. What is an OS? What are processes and threads? Process states? Diagram showing the state changes What data.
C Threads and Semaphores
REAL-TIME OPERATING SYSTEMS
Chapter 19: Real-Time Systems
Topics Covered What is Real Time Operating System (RTOS)
Time Sources and Timing
Round Robin Non-Preemptive Scheduler
Exploring LynxOS By How-Shen Chang.
Chapter 2 Scheduling.
Real-time Software Design
Chapter 5: CPU Scheduling
CPU Scheduling.
Chapter 6: CPU Scheduling
Process management Information maintained by OS for process management
Chapter 2: The Linux System Part 3
Enforcing Real-Time Behavior I
Chapter 19: Real-Time Systems
CS703 – Advanced Operating Systems
Time Sources and Timing
Scheduling Classes and Real-Time Scheduling in Linux
Linux Process State Scheduling information Identifiers
Presentation transcript:

Dr. Hugh Melvin, Dept. of IT, NUI,G1 POSIX POSIX: Portable OS Interface –IEEE standard –Mandatory + Optional parts Mostly based on and adopted by Unix community POSIX.4 = POSIX b –Added Realtime functionality POSIX.4a = POSIX c –Threads Extensions

Dr. Hugh Melvin, Dept. of IT, NUI,G2 POSIX.4 = POSIX b –Range of RT Features Shared Memory / Memory Locking / Priority Scheduling / Signals / Semaphores / Clocks & Timers Will examine many of these issues Adopted by many RTOS : QNX, LynxOS, VxWorks –POSIX.4b = POSIX d –More realtime extensions

Dr. Hugh Melvin, Dept. of IT, NUI,G3 POSIX.4 RT Scheduling Defines two main scheduling policies –SCHED_FIFO and SCHED_RR Each have attributes –Also have SCHED_OTHER –Currently a single attribute = priority struct sched_param{ int sched_priority; } –Eg. Could implement EDF by extending structure to include struct timespec sched_deadline; struct timespec sched_timerequired;

Dr. Hugh Melvin, Dept. of IT, NUI,G4 POSIX.4 RT Scheduling SCHED_FIFO –Simple priority based preemptive scheduler –Most common in RTS –FIFO used to schedule processes within each priority level –If no other process exists at higher priority, process runs until complete Next process at that priority (if present) then allocated CPU Highest priority process guaranteed processor time

Dr. Hugh Melvin, Dept. of IT, NUI,G5 POSIX.4 RT Scheduling SCHED_RR –Round robin used to timeslice among processes at same priority level –System provided timeslice –Use for lower priority tasks

Dr. Hugh Melvin, Dept. of IT, NUI,G6 POSIX.4 RT Scheduling Setting scheduling policy and attribute #include struct sched_param scheduling_parameters; int scheduling_policy; int i; scheduling_parameters.sched_priority=17; i=sched_setscheduler(getpid( ),SCHED_FIFO, &scheduling_parameters); getpid( ) used to determine process ID –Process set to FIFO, priority 17

Dr. Hugh Melvin, Dept. of IT, NUI,G7 POSIX.4 RT Scheduling Process priority ranges differ among OS –Need this info before setting priority level int sched_rr_min, sched_rr_max; int sched_fifo_min, sched_fifo_max; sched_rr_min=sched_get_priority_min(SCHED_RR); sched_rr_max=sched_get_priority_max(SCHED_RR); sched_fifo_min=sched_get_priority_min(SCHED_FIFO); sched_fifo_max=sched_get_priority_max(SCHED_FIFO); –Eg. 256 priority levels FIFO range RR range 0-127

Dr. Hugh Melvin, Dept. of IT, NUI,G8 POSIX.4 RT Scheduling Eg. #include int i; struct sched_param my_sched_params; // determine max FIFO priority level my_sched_params.sched_priority= sched_get_priority_max(SCHED_FIFO); // Set priority i=sched_setparam(getpid (),&my_sched_params);

Dr. Hugh Melvin, Dept. of IT, NUI,G9 POSIX.4 Clocks & Timers Must be at least one clock –CLOCK_REALTIME clock_gettime( ), clock_settime( ) –Replaces gettimeofday( ),settimeofday() –timespec structure (sec + nsec) struct timespec{ time_t tv_sec; time_t tv_nsec; } clock_getres(CLOCK_REALTIME,&realtime_res) –Returns clock resolution : must be at least 50 Hz –realtime_res is timespec structure Realtime libraries reqd

Dr. Hugh Melvin, Dept. of IT, NUI,G10 POSIX #include int main(){ struct timespec clock_res; int stat; stat=clock_getres(CLOCK_REALTIME, &clock_res); printf("Clock resol is %d sec, %ld nseconds\n",clock_res.tv_sec,clock_res.tv_nsec); return 0; }

Dr. Hugh Melvin, Dept. of IT, NUI,G11 POSIX.4 Clocks & Timers nanosleep(&nap,&time_left) –Can delay process (both nap & time_left are timespec ) Interval Timers –Useful to specify precise intervals struct itimerspec{ struct timespec it_value; struct timespec it_interval; } it_value = 1 st occasion of timer event it_interval = interval between subsequent events System calls –timer_create( ) and timer_delete( ) –Can have multiple timers within any process

Dr. Hugh Melvin, Dept. of IT, NUI,G12 POSIX.4 Clocks & Timers Interval Timer example timer_t created_timer; i = timer_create( _, _, &created_timer); struct itimerspec new,old; new.it_value.tv_sec=1; new.it_value.tv_nsec=0; new.it_interval.tv_sec=0; new.it_interval.tv_nsec=100000; i=timer_settime(created_timer, 0,&new, &old).. i=timer_delete(created_timer)

Dr. Hugh Melvin, Dept. of IT, NUI,G13 POSIX.4 Clocks & Timers Absolute Timer Events –Eg. Timer event reqd at time t abs Determine interval and use interval timer clock_gettime(CLOCK_REALTIME, &now); Calculate interval –Interval = t abs - now Create and set Interval timer as above But –Process may be preempted between step 1 and 2  Use absolute times timer_settime(created_timer,TIMER_ABSTIME,&t abs,NULL)

Dr. Hugh Melvin, Dept. of IT, NUI,G14 This function reads the hardware clock using the "intel" RDTSC assembly instruction. void get_timestamp(unsigned long* upper32bits, unsigned long* lower32bits) { unsigned long lower32, upper32, first_upper32; do { __asm RDTSC __asm mov upper32, EDX __asm mov lower32, EAX first_upper32 = upper32; __asm RDTSC __asm mov upper32, EDX } while (first_upper32 != upper32); // protect against wraparound *lower32bits = lower32; *upper32bits = upper32; }