POSIX. POSIX Support POSIX.4. POSIX.4 = POSIX b. POSIX.4a = POSIX c. POSIX.4b = POSIX d

Similar documents
POSIX. RTOSes Part I. POSIX Versions. POSIX Versions (2)

Threads Scheduling on Linux Operating Systems

Scheduling 0 : Levels. High level scheduling: Medium level scheduling: Low level scheduling

Real-Time Systems Prof. Dr. Rajib Mall Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

Programming real-time systems with C/C++ and POSIX

Exercises : Real-time Scheduling analysis

Objectives. Chapter 5: CPU Scheduling. CPU Scheduler. Non-preemptive and preemptive. Dispatcher. Alternating Sequence of CPU And I/O Bursts

Performance Comparison of RTOS

OPERATING SYSTEMS SCHEDULING

CPU Scheduling Outline

CPU SCHEDULING (CONT D) NESTED SCHEDULING FUNCTIONS

Linux scheduler history. We will be talking about the O(1) scheduler

Linux 2.4. Linux. Windows

Comparison between scheduling algorithms in RTLinux and VxWorks

LynxOS RTOS (Real-Time Operating System)

Deciding which process to run. (Deciding which thread to run) Deciding how long the chosen process can run

Overview of the Linux Scheduler Framework

Embedded Systems. 6. Real-Time Operating Systems

Linux process scheduling

Operating Systems Concepts: Chapter 7: Scheduling Strategies

Konzepte von Betriebssystem-Komponenten. Linux Scheduler. Valderine Kom Kenmegne Proseminar KVBK Linux Scheduler Valderine Kom

Improvement of Scheduling Granularity for Deadline Scheduler

Implementing and Using Execution Time Clocks in Ada Hard Real-Time Applications

Lecture 3 Theoretical Foundations of RTOS

REAL TIME OPERATING SYSTEMS. Lesson-10:

Real-time Operating Systems. VO Embedded Systems Engineering Armin Wasicek

Real Time Programming: Concepts

Operating Systems. III. Scheduling.

Chapter 19: Real-Time Systems. Overview of Real-Time Systems. Objectives. System Characteristics. Features of Real-Time Systems

Linux O(1) CPU Scheduler. Amit Gud amit (dot) gud (at) veritas (dot) com

What is an RTOS? Introduction to Real-Time Operating Systems. So what is an RTOS?(contd)

W4118 Operating Systems. Instructor: Junfeng Yang

Process Scheduling in Linux

Linux Process Scheduling Policy

Module 8. Industrial Embedded and Communication Systems. Version 2 EE IIT, Kharagpur 1

Real-Time Scheduling 1 / 39

Process Scheduling in Linux

QNX V6.5 ON ARM. 1: Dedicated Systems Experts, 2: VUB-Brussels, 3: RMA-Brussels

LAB 5: Scheduling Algorithms for Embedded Systems

Tasks Schedule Analysis in RTAI/Linux-GPL

Linux Scheduler. Linux Scheduler

W4118 Operating Systems. Instructor: Junfeng Yang

Design and Implementation of a POSIX Compliant Sporadic Server for the Linux Kernel

Real-Time Operating Systems.

CS 377: Operating Systems. Outline. A review of what you ve learned, and how it applies to a real operating system. Lecture 25 - Linux Case Study

Chapter 10 Case Study 1: LINUX

The Real-Time Operating System ucos-ii

Project No. 2: Process Scheduling in Linux Submission due: April 28, 2014, 11:59pm

Operating Systems. 05. Threads. Paul Krzyzanowski. Rutgers University. Spring 2015

Operating System: Scheduling

Processor Scheduling. Queues Recall OS maintains various queues

Chapter 5: CPU Scheduling. Operating System Concepts 8 th Edition

2. is the number of processes that are completed per time unit. A) CPU utilization B) Response time C) Turnaround time D) Throughput

Readings for this topic: Silberschatz/Galvin/Gagne Chapter 5

Operating Systems and Networks

Hard Real-Time Linux

Linux Process Scheduling. sched.c. schedule() scheduler_tick() hooks. try_to_wake_up() ... CFS CPU 0 CPU 1 CPU 2 CPU 3

Timer Value IRQ IACK

Process Scheduling II

Scheduling. Yücel Saygın. These slides are based on your text book and on the slides prepared by Andrew S. Tanenbaum

THE REQUIREMENTS FOR A COTS SOFTWARE COMPONENT: A CASE STUDY

Using EDF in Linux: SCHED DEADLINE. Luca Abeni

Modular Real-Time Linux

CPU Scheduling. CSC 256/456 - Operating Systems Fall TA: Mohammad Hedayati

Multiprocessor Scheduling and Scheduling in Linux Kernel 2.6

REAL TIME OPERATING SYSTEM PROGRAMMING-II: II: Windows CE, OSEK and Real time Linux. Lesson-12: Real Time Linux

Enhancing the Monitoring of Real-Time Performance in Linux

Embedded & Real-time Operating Systems

Red Hat Linux Internals

Thomas Fahrig Senior Developer Hypervisor Team. Hypervisor Architecture Terminology Goals Basics Details

SYSTEM ecos Embedded Configurable Operating System

How To Compare Real Time Scheduling To A Scheduled Scheduler On Linux On A Computer System With A Visualization System

Application of Android OS as Real-time Control Platform**

POSIX : Certified by IEEE and The Open Group a briefing.

Chapter 13 Embedded Operating Systems

White Paper. Real-time Capabilities for Linux SGI REACT Real-Time for Linux

Linux Scheduler Analysis and Tuning for Parallel Processing on the Raspberry PI Platform. Ed Spetka Mike Kohler

Predictable response times in event-driven real-time systems

Real Time Operating Systems. Tajana Simunic Rosing Department of Computer Science and Engineering University of California, San Diego.

ELEC 377. Operating Systems. Week 1 Class 3

Notes and terms of conditions. Vendor shall note the following terms and conditions/ information before they submit their quote.

Realtime Java. Christoph Neijenhuis

Process Scheduling CS 241. February 24, Copyright University of Illinois CS 241 Staff

Real-Time Operating Systems With Example PICOS18. What is an Operating System?

Linux Kernel Networking. Raoul Rivas

Win32 API Emulation on UNIX for Software DSM

Chapter 12. Development Tools for Microcontroller Applications

ICS Principles of Operating Systems

Safe Kernel Scheduler Development with Bossa

Operatin g Systems: Internals and Design Principle s. Chapter 10 Multiprocessor and Real-Time Scheduling Seventh Edition By William Stallings

THREADS WINDOWS XP SCHEDULING

Chapter 5 Process Scheduling

Introduction à la programmation temps-réel pour la robotique

Control period can have high frequency (short control frame) ex: 0.1kHz - 1kHz in robot controllers

Linux Plumbers API for Real-Time Scheduling with Temporal Isolation on Linux

Scheduling of Real- Time processes, strategies and analysis

CGL Architecture Specification

Real-time scheduling algorithms, task visualization

RTAI. Antonio Barbalace (modified by M.Moro 2011) RTAI

Introduction. General Course Information. Perspectives of the Computer. General Course Information (cont.)

Transcription:

POSIX POSIX: Portable OS Interface Set of IEEE standards Mandatory + Optional parts Objective: Source code portability of applications across multiple OS Standard way for applications to interface to OS Mostly but not exclusively Unix type OS Total portability is not achievable POSIX.1 Set of standard OS system calls File operations, process management, signals, and devices Mostly mandatory Widely supported Unix, Linux, VxWorks, QNX, Solaris, OSX, LynxOS Dr. Hugh Melvin, Dept. of IT, NUI,Galway 1 POSIX Support Compiler Support Options to include/invoke POSIX support Eg. GNU C Compiler gcc lrt o name name.c Headers Set of header files that define POSIX interface supported on particular system #include<unistd.h> Libraries Implement POSIX functionality Dr. Hugh Melvin, Dept. of IT, NUI,Galway 2 POSIX.4 POSIX.4 = POSIX 1003.1b Added Realtime functionality Built on top of POSIX.1 POSIX.4a = POSIX 1003.1c Threads extensions POSIX.4b = POSIX 1003.1d More realtime extensions Dr. Hugh Melvin, Dept. of IT, NUI,Galway 3 1

POSIX.4 = POSIX 1003.1b 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, RT Linux, Integrity POSIX Compliant OS Supports mandatory features Specifies which optional features it supports POSIX.4 features are mostly optional so beware Dr. Hugh Melvin, Dept. of IT, NUI,Galway 4 POSIX.4 Found on many Soft RTS Network Switches Multimedia applications DBMS Navigation Systems Increasingly found on Hard RTS See Integrity RTOS Aviation Dr. Hugh Melvin, Dept. of IT, NUI,Galway 5 POSIX.4 Linux & POSIX.4 Many POSIX.4 features supported Convert a conventional time sharing OS to a pseudo RT OS Assignment 3 Implement and test range of POSIX.4 features on Linux OS POSIX References http://www.xtrj.org/collection/posix_rtos.htm POSIX.4 Prog. For the Real World, Bill Gallmeister, O Reilly Advanced UNIX Programming, Rochkind, Add Wesley Dr. Hugh Melvin, Dept. of IT, NUI,Galway 6 2

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,Galway 7 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,Galway 8 SCHED_RR Round robin used to timeslice among processes at same priority level System provided timeslice Use for lower priority tasks SCHED_OTHER Implementation dependent Dr. Hugh Melvin, Dept. of IT, NUI,Galway 9 3

Setting scheduling policy and attribute #include <sched.h> 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,Galway 10 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 128-255 RR range 0-127 Dr. Hugh Melvin, Dept. of IT, NUI,Galway 11 Eg. #include<sched.h> 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,Galway 12 4

Range of features timespec, itimerspec Time structures clock_getres() Determine Clock Resolution clock_gettime(),clock_settime() Get and Set System Clock Time nanosleep( ) timer_create( ),timer_delete( ) Interval timers Dr. Hugh Melvin, Dept. of IT, NUI,Galway 13 Must be at least one clock CLOCK_REALTIME timespec structure (sec + nsec) struct timespec{ time_t tv_sec; time_t tv_nsec; Replaces timeval clock_getres(clock_realtime,&realtime_res) Returns clock resolution : must be at least 50 Hz realtime_res is timespec structure clock_gettime(clock_realtime, &time), clock_settime( ) Replace gettimeofday( ),settimeofday() Realtime libraries reqd Dr. Hugh Melvin, Dept. of IT, NUI,Galway 14 #include<unistd.h> #include<time.h> 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,Galway 15 5

nanosleep(&nap,&time_left) Can delay process (both nap & time_left are timespec structs) for(i=0;i<num_iter;++i) { clock_gettime(clock_realtime, &c_time1); nanosleep(&sleeptime,null); clock_gettime(clock_realtime, &c_time2); now1=c_time1.tv_sec + c_time1.tv_nsec*0.000000001; now2=c_time2.tv_sec + c_time2.tv_nsec*0.000000001; printf("time is %ld : %ld..slept for %lf nsec\n,c_time2.tv_sec, c_time2.tv_nsec,(now2-now1)*1000000000); Dr. Hugh Melvin, Dept. of IT, NUI,Galway 16 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,Galway 17 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,Galway 18 6

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,Galway 19 POSIX.4 Memory Locking Lock all or part of a process in MM Facilitated via memory locking POSIX.4 #include <unistd.h> #ifdef _POSIX_MEMLOCK #include <sys/mman.h> int mlockall(int flags); int munlockall(void); #endif /*_POSIX_MEMLOCK */ Locks complete process in memory Need to ensure that you have enough memory Dr. Hugh Melvin, Dept. of IT, NUI,Galway 20 POSIX.4 Memory Locking /*Main routine */ int main(void ){ /* Lock all process down */ mlockall(mcl_current MCL_FUTURE); process code munlockall(); return 0; Locks currently and future mapped pages belonging to process in memory Locked Memory will vary as process runs Can also lock critical sections of memory or functions within a process More complex Dr. Hugh Melvin, Dept. of IT, NUI,Galway 21 7