CSCI1600: Embedded and Real Time Software Lecture 26: Real Time Operating Systems Steven Reiss, Fall 2015.

Slides:



Advertisements
Similar presentations
More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.
Advertisements

Chorus and other Microkernels Presented by: Jonathan Tanner and Brian Doyle Articles By: Jon Udell Peter D. Varhol Dick Pountain.
Processes CSCI 444/544 Operating Systems Fall 2008.
Operating Systems (OS) Threads, SMP, and Microkernel, Unix Kernel
Introduction to Operating Systems – Windows process and thread management In this lecture we will cover Threads and processes in Windows Thread priority.
I/O Hardware n Incredible variety of I/O devices n Common concepts: – Port – connection point to the computer – Bus (daisy chain or shared direct access)
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
MicroC/OS-II Embedded Systems Design and Implementation.
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Protection and the Kernel: Mode, Space, and Context.
1 Lecture 4: Threads Operating System Fall Contents Overview: Processes & Threads Benefits of Threads Thread State and Operations User Thread.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Hardware Definitions –Port: Point of connection –Bus: Interface Daisy Chain (A=>B=>…=>X) Shared Direct Device Access –Controller: Device Electronics –Registers:
I/O Systems I/O Hardware Application I/O Interface
Implementing Processes and Process Management Brian Bershad.
Architecture Support for OS CSCI 444/544 Operating Systems Fall 2008.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 11 Windows – Object manager and process management.
Operating Systems Lecture 7 OS Potpourri Adapted from Operating Systems Lecture Notes, Copyright 1997 Martin C. Rinard. Zhiqing Liu School of Software.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Scheduling Lecture 6. What is Scheduling? An O/S often has many pending tasks. –Threads, async callbacks, device input. The order may matter. –Policy,
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
Chapter 2 Processes and Threads Introduction 2.2 Processes A Process is the execution of a Program More specifically… – A process is a program.
1 Review of Process Mechanisms. 2 Scheduling: Policy and Mechanism Scheduling policy answers the question: Which process/thread, among all those ready.
ECGR-6185 µC/OS II Nayana Rao University of North Carolina at Charlotte.
We will focus on operating system concepts What does it do? How is it implemented? Apply to Windows, Linux, Unix, Solaris, Mac OS X. Will discuss differences.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
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.
CSCI1600: Embedded and Real Time Software Lecture 27: Real Time Linux Steven Reiss, Fall 2015.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Managing Processors Jeff Chase Duke University. The story so far: protected CPU mode user mode kernel mode kernel “top half” kernel “bottom half” (interrupt.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Embedded Real-Time Systems Processing interrupts Lecturer Department University.
Threads, SMP, and Microkernels Chapter 4. Processes and Threads Operating systems use processes for two purposes - Resource allocation and resource ownership.
1 Chapter 2: Operating-System Structures Services Interface provided to users & programmers –System calls (programmer access) –User level access to system.
Advanced Operating Systems CS6025 Spring 2016 Processes and Threads (Chapter 2)
WORKING OF SCHEDULER IN OS
Introduction to Operating Systems Concepts
Computer System Structures
REAL-TIME OPERATING SYSTEMS
Module 12: I/O Systems I/O hardware Application I/O Interface
Chapter 13: I/O Systems Modified by Dr. Neerja Mhaskar for CS 3SH3.
CS 6560: Operating Systems Design
OPERATING SYSTEMS CS3502 Fall 2017
Anton Burtsev February, 2017
Process Management Presented By Aditya Gupta Assistant Professor
CSCI1600: Embedded and Real Time Software
Structure of Processes
CSCI 315 Operating Systems Design
Threads, SMP, and Microkernels
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Mid Term review CSC345.
Operating Systems.
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Description and Control
Lecture 4- Threads, SMP, and Microkernels
Threads Chapter 4.
Process Description and Control
February 5, 2004 Adrienne Noble
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CSE 153 Design of Operating Systems Winter 2019
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

CSCI1600: Embedded and Real Time Software Lecture 26: Real Time Operating Systems Steven Reiss, Fall 2015

What is a RTOS  It’s an operating system  Similar to UNIX, Windows, Linux, Mac OS, Solaris  Provides all the low level services one expects  So they don’t have to be rewritten for each application  Shares the CPU and other hardware resources  Except it’s different in some ways

RTOS Differences  More control over scheduling  Real time tasks  Real priorities (not hints)  Simpler scheduling techniques  Easier to reason about  Provable properties  More “embeddability”  Application might remain in control  RTOS is a library  Footprint/size is a concern  Compile time configurations, only basis services

RTOS Basic Functions  Kernel (scheduler, resource management)  Error handling  System clock functions  Device drivers, network stack send/receive  IPC  Initiate and start  Task state switching  ISR  Memory management

Device Drivers  Goal  Provide a standard interface to any I/O device  Motivation  Lets OS control the device and its resources  Lets programs be easily written for new devices  Lets new devices be attached to the system

OS & Device Drivers  User/kernel boundary  Supported as part of the CPU  Privileged vs non-privileged instructions  I/O instructions are privileged  Interrupts are privileged  Memory mapping instructions are privileged  Kernel takes care of  Memory management  Process scheduling  All I/O

I/O Devices  Can be broken down by category (flavor)  CHAR : device accessed like a stream  Serial I/O, tty, mouse, sound  Also simple devices (parallel I/O)  BLOCK : device accessed in bulk  Often DMA access  NETWORK : device is a network device  Devices of the same flavor have much in common

Device Numbers  Devices Identified by a device number  Number: (major,minor)  Major number: driver ID  Minor number: used by the driver  Allocated dynamically in modern OS  /dev/xxx -> identifies major and minor numbers

Kernel Modules  Modern kernels allow you to add/remove drivers  Dynamically  Without rebuild, reboot, recompile  Kernel code is restricted programming  No general libraries available  Kernel functions are callable  Some (limited) memory allocation, delay, synch, logging

User Access to Devices  Uses the file interface (device = file)  open() : provides access to the device  Can be exclusive (write) or nonexclusive (read)  close() : releases the device  Standard access calls  read, write  seek  ioctl, fcntl  What do these operations mean?  Whatever the driver says they mean

Device Driver Interface  module_init, module_exit  Routines called on installation and removal  Init  Registers the device  Sets the device to a known state  Gets the IRQ, addresses of I/O  Exit  Releases the memory addresses

Device Driver Interface  Driver provides other methods  open(), read(), write(), llseek(), ioctl(), fasync(), release()  These can be omitted is not relevant  All calls provided with a common kernel structure (filp)  That can hold local information about the device  open/release – fill in the data structure  read/write provided with pointers to user space  fasync – indicates asynchronous I/O desired

Device Driver Interface  ioctl(int device,int command,{data})  command is device specific (header file defined)  data might be a reference to user address space  Commands can be used to control the device  Pinball: RESET, READREG, WRITEREG, DATA, DISPLAY, INTERR

RTOS Scheduling  Tasks  State: RUNNING, READY/RUNNABLE, WAITING/BLOCKED  Waiting: TIMER, INTERRUPTS, LOCK  Priority  Context (stack pointer, registers) for preemption  Valid state transitions  RUNNING -> READY, READY -> RUNNING  sched() : makes proper task running  RUNNING -> WAITING  suspend() : moves current job to waiting state  WAITING -> READY  wakeup() called when job gets an interrupt

RTOS Task Interface  Task interface to scheduler  yield() [RUNNING->READY], sleep() [RUNNING->TIMERS]  acquire(), release()  read(), write()  Locks  Each lock maintains a queue and a state  Handle acquire and release appropriately  I/O  Each device maintains a queue  Timing  Maintain a timer queue (ordered by wake up time)  Processed on timer interrupts

RTOS Tasks  What does a task look like in a RTOS?  Consider outputting a sound sample  Loop while samples exist  Output current sample  Get time until next sample  Sleep  Note that waiting here is okay (why?)  Consider checking switches in tic-tac-toe

RTOS Tasks  What information does a scheduler need about a real time (periodic) task  For RM/DM scheduling  For EDF scheduling  How might that information be conveyed?

Task Priorities  Suppose each task has a priority  Based on its rate (period)  Smaller rates have higher priority  Sporadic tasks have lower priority  What happens then?  Assume that periodic tasks use less than 50% of time  What can you say about them meeting deadlines

RTOS Scheduling  Real time tasks and real time priorities  Other tasks: simple method  Round robin, FIFO, priority based; fair share  Priority approach using dynamic priority (UNIX)  Priority increases if suspended voluntarily  CPU-bound processes are penalized  Low-priority “snubbed” processes are increased  Limit to priority fluctuation  This doesn’t work for real time tasks

RTOS Examples: Arduino  Operating system is a set of libraries  Provide access to I/O lines (analog/digital)  PWM output, analog input, pull-up  Read/write from SD or memory  Provide access to timers, interrupts  Provide network access  Initialization/Loop  No scheduling

RTOS: μCOS (MUCOS, Micro-C OS)  Library of C routines implementing OS functions  User stays in control  Highly protable, ROM-able, scalable, preemptive, deterministic  Up to 64 tasks (56 user)  Connectivity to GUI and file system interfaces (drivers)  8 to 64 bit processors supported  Functions  Task management, memory management, time management, IPC

μCOS Task Management  Rate monotonic scheduling  All tasks are periodic  Tasks have priority (based on period)  Same priority tasks are handled via round robin  Assumes true periodic load is < 69%  States  Processing: new, ready, waiting, running, terminated  Critical regions  OS_ENTER_CRITICAL, OS_EXIT_CRITICAL  Task switching  OS_TASK_SW switches task  Saves registers, restores registers, returns to new task

μCOS Functionality  Memory Management  Done in terms of partitions (fixed size blocks)  Allocation is constant time and deterministic  Multiple partitions provide blocks of different sizes  Time Management  Clock tick every ms increments a counter  Delay and resume based on the counter  IPC  Semaphores, mailboxes, message queues  ISR routines can interact using wait/signal

μCOS Features  Addons (additional libraries)  Bitmapped graphics  FAT file system  Embeddability  Individually enable or disable features  Semaphores, mailboxes, message queues  Task manipulations (delete, change priority)  Number of tasks, events, queue sizes  Small footprint (15k with everything enabled)

Conventional Operating Systems  Memory model  Independent address spaces  Allocation and deallocation  Stack management  Device support  Abstraction based on descriptors  Clock and other basic devices built in  High-level I/O support (e.g. networking)  Thread / process model (with scheduling)  IPC support (pipes, sockets, shared memory)  Synchronization primitives

Conventional OS Problems  Size (for embedded)  Micro-kernel based architectures help here  Unpredictable (and poor) latency  Slow interrupt handlers  Unpreemptible kernel code  Latency might be built into hardware  System management interrupts on x86  DMA bus mastering; USB handling; VGA console; Page faults  Unpredictable Scheduling  Desktop/server heuristics  Scheduling overhead grows with workload  Poor support for precise timing  Timing accuracy related to tick overhead

Are the Problems Fixable?  Want to retain the bulk of prior work  Hundreds of device drivers  Many abstractions make programming easier  TCP/IP, File systems, IPC, Memory  How can we do this?  Two approaches to this are used  Fixing the problems  Sidestepping the problems

Next Time  We’ll look at real operating systems for RT/embedded programming