Processes and operating systems

Slides:



Advertisements
Similar presentations
Network II.5 simulator ..
Advertisements

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.
Chapter 3 Process Description and Control
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
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)
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zInterprocess communication. zOperating system performance.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Chapter 3 Operating Systems Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Segmentation & O/S Input/Output Chapter 4 & 5 Tuesday, April 3, 2007.
Scheduling policies for real- time embedded systems.
© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems  Operating systems.
© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems Operating systems. 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Slides created by: Professor Ian G. Harris Operating Systems  Allow the processor to perform several tasks at virtually the same time Ex. Web Controlled.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Unit - I Real Time Operating System. Content : Operating System Concepts Real-Time Tasks Real-Time Systems Types of Real-Time Tasks Real-Time Operating.
Introduction to operating systems What is an operating system? An operating system is a program that, from a programmer’s perspective, adds a variety of.
Big Picture Lab 4 Operating Systems C Andras Moritz
 Operating system.  Functions and components of OS.  Types of OS.  Process and a program.  Real time operating system (RTOS).
Introduction to Operating Systems Concepts
Chapter 13: I/O Systems.
Chapter 3: Windows7 Part 5.
REAL-TIME OPERATING SYSTEMS
Memory Management.
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.
Chapter 19: Real-Time Systems
Processes and threads.
Processes and operating systems
Operating systems Deadlocks.
Topics Covered What is Real Time Operating System (RTOS)
Lesson Objectives Aims Key Words
Operating Systems (CS 340 D)
Wayne Wolf Dept. of EE Princeton University
Operating System Structure
Intro to Processes CSSE 332 Operating Systems
Virtual Memory Networks and Communication Department.
Operating Systems (CS 340 D)
Chapter 3: Windows7 Part 5.
HW & Systems: Operating Systems IS 101Y/CMSC 101 Computational Thinking and Design Tuesday, October 22, 2013 Carolyn Seaman University of Maryland, Baltimore.
Operating Systems Chapter 5: Input/Output Management
Operating System Concepts
13: I/O Systems I/O hardwared Application I/O Interface
CS703 - Advanced Operating Systems
Chapter 2: The Linux System Part 3
Operating Systems.
Lecture Topics: 11/1 General Operating System Concepts Processes
Operating systems Deadlocks.
Process Description and Control
Chapter 5: I/O Systems.
Processes and operating systems
Chapter 2: Operating-System Structures
Concurrency: Mutual Exclusion and Process Synchronization
Chapter 19: Real-Time Systems
Process Description and Control
Processes and operating systems
February 5, 2004 Adrienne Noble
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 10 Multiprocessor and Real-Time Scheduling
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 13: I/O Systems I/O Hardware Application I/O Interface
Chapter 2: Operating-System Structures
Contact Information Office: 225 Neville Hall Office Hours: Monday and Wednesday 12:00-1:00 and by appointment. Phone:
Chapter 13: I/O Systems.
Chapter 3: Process Management
Module 12: I/O Systems I/O hardwared Application I/O Interface
Presentation transcript:

Processes and operating systems © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Operating systems The operating system controls resources: who gets the CPU; when I/O takes place; how much memory is allocated. The most important resource is the CPU itself. CPU access controlled by the scheduler. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components RTOS Real-time operating systems (RTOSs),which are OSs that provide facilities for satisfying real-time requirements. A RTOS allocates resources using algorithms that take real time into account. General-purpose OSs, in contrast, generally allocate resources using other criteria like fairness. Trying to allocate the CPU equally to all processes without regard to time can easily cause processes to miss their deadlines. © 2000 Morgan Kaufman Overheads for Computers as Components

MULTIPLE TASKS AND MULTIPLE PROCESSES Most embedded systems require functionality and timing that is too complex to embody in a single program. We break the system into multiple tasks in order to manage when things happen. Basic abstractions that will be manipulated by the RTOS to build multirate systems . Tasks and Processes Multirate Systems Timing Requirements on Processes CPU Metrics Process State and Scheduling Some Scheduling Policies Running Periodic Processes © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Designing a telephone answering Machine: define recording a phone call and operating the user’s control panel as distinct tasks, because they perform logically distinct operations and they must be performed at very different rates. These different tasks are part of the system’s functionality © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components A process is a single execution of a program. If we run the same program two different times, we have created two different processes. Each process has its own state that includes not only its registers but all of its memory. In some OSs, the memory management unit is used to keep each process in a separate address space. In others, particularly lightweight RTOSs, the processes run in the same address space. Processes that share the same address space are often called threads. To be more precise, task can be composed of several processes or threads © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components the separation of an application into tasks may be reflected in the program structure, consider how we would build a stand-alone compression unit based on a compression algorithm this device is connected to serial ports on both ends. The input to the box is an uncompressed stream of bytes. The box emits a compressed string of bits on the output serial line, based on a predefined compression table. Such a box may be used, for example, to compress data being sent to a modem. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components The program’s need to receive and send data at different rates—for example, the program may emit 2 bits for the first byte and then 7 bits for the second byte a more elegant solution is to create a queue of output bits, with those bits being removed from the queue and sent to the serial port in 8-bit sets. if we spend too much time in packaging and emitting output characters, we may drop an input character. asynchronous input- compression mode button- Sampling the button’s state- button-handling routine- illustrates how requirements on timing and execution rate can create major problems in programming © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Multirate Systems Implementing code that satisfies timing requirements is even more complex when multiple rates of computation must be handled. Multirate embedded computing systems are very common,including automobile engines, printers,and cell phones. In all these systems,certain operations must be executed periodically,and each operation is executed at its own rate © 2000 Morgan Kaufman Overheads for Computers as Components

Timing Requirements on Processes Processes can have several different types of timing requirements imposed on them by the application. The timing requirements on a set of processes strongly influence the type of scheduling that is appropriate. two important requirements on processes: release time and deadline. The release time is the time at which the process becomes ready to execute; this is not necessarily the time at which it actually takes control of the CPU and starts to run. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components The period of a process is the time between successive executions. The process’s rate is the inverse of its period. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components illustrates process execution in a system with four CPUs. The various execution instances of program P1 have been subscripted to distinguish their initiation times. In this case, the initiation interval is equal to onefourth of the period. It is possible for a process to have an initiation rate less than the period even in single-CPU systems. If the process execution time is significantly less than the period, it may be possible to initiate multiple copies of a program at slightly offset times. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components What happens when a process misses a deadline? The practical effects of a timing violation depend on the application—the results can be catastrophic in an automotive control system, where as a missed deadline in a multimedia system may cause an audio or video glitch. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components The order of execution of processes may be constrained when the processes pass data between each other. Following Figure shows a set of processes with data dependencies among them. Before a process can become ready,all the processes on which it depends must complete and send their data to it. The data dependencies define a partial ordering on process execution—P1 and P2 can execute in any order (or in interleaved fashion) but must both complete before P3, and P3 must complete before P4. All processes must finish before the end of the period. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components The data dependencies must form a directed acyclic graph (DAG)—a cycle in the data dependencies is difficult to interpret in a periodically executed system. A set of processes with data dependencies is known as a task graph. we will consider a component of the task graph (a set of nodes connected by data dependencies) as a task and the complete graph as the task set. Figure also shows a second task with two processes. The two tasks ({P1, P2, P3, P4} and {P5, P6}) have no timing relationships between them. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components communication among processes of different rates is very common. Figure illustrates the communication required among three elements of an MPEG audio/video decoder. Data come into the decoder in the system format, which multiplexes audio and video data. Multirate communication is necessarily one way—for example, the system process writes data to the video process, but a separate communication mechanism must be provided for communication from the video process back to the system process. © 2000 Morgan Kaufman Overheads for Computers as Components

CPU Metrics The initiation time is the time at which a process actually starts executing on the CPU. The completion time is the time at which the process finishes its work. The most basic measure of work is the amount of CPU time expended by a process. The CPU time of process i is called Ci . Note that the CPU time is not equal to the completion time minus initiation time; several other processes may interrupt execution. The total CPU time consumed by a set of processes is Utilization is the ratio of the CPU time that is being used for useful computations to the total available CPU time.

Overheads for Computers as Components Process state A process can be in one of three states: executing on the CPU; ready to run; waiting for data. executing gets data and CPU gets CPU preempted needs data gets data ready waiting needs data © 2000 Morgan Kaufman Overheads for Computers as Components

Operating system structure OS needs to keep track of: process priorities; scheduling state; process activation record. Processes may be created: statically before system starts; dynamically during execution. © 2000 Morgan Kaufman Overheads for Computers as Components

Embedded vs. general-purpose scheduling Workstations try to avoid starving processes of CPU access. Fairness = access to CPU. Embedded systems must meet deadlines. Low-priority processes may not run for a long time. © 2000 Morgan Kaufman Overheads for Computers as Components

Priority-driven scheduling Each process has a priority. CPU goes to highest-priority process that is ready. Priorities determine scheduling policy: fixed priority; time-varying priorities. © 2000 Morgan Kaufman Overheads for Computers as Components

Priority-driven scheduling example Rules: each process has a fixed priority (1 highest); highest-priority ready process gets CPU; process continues until done. Processes P1: priority 1, execution time 10 P2: priority 2, execution time 30 P3: priority 3, execution time 20 © 2000 Morgan Kaufman Overheads for Computers as Components

Priority-driven scheduling example P3 ready t=18 P2 ready t=0 P1 ready t=15 P2 P1 P2 P3 10 20 30 40 50 60 time © 2000 Morgan Kaufman Overheads for Computers as Components

The scheduling problem Can we meet all deadlines? Must be able to meet deadlines in all cases. How much CPU horsepower do we need to meet our deadlines? © 2000 Morgan Kaufman Overheads for Computers as Components

Process initiation disciplines Periodic process: executes on (almost) every period. Aperiodic process: executes on demand. Analyzing aperiodic process sets is harder---must consider worst-case combinations of process activations. © 2000 Morgan Kaufman Overheads for Computers as Components

Timing requirements on processes Period: interval between process activations. Initiation interval: reciprocal of period. Initiation time: time at which process becomes ready. Deadline: time at which process must finish. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Timing violations What happens if a process doesn’t finish by its deadline? Hard deadline: system fails if missed. Soft deadline: user may notice, but system doesn’t necessarily fail. © 2000 Morgan Kaufman Overheads for Computers as Components

Example: Space Shuttle software error Space Shuttle’s first launch was delayed by a software timing error: Primary control system PASS and backup system BFS. BFS failed to synchronize with PASS. Change to one routine added delay that threw off start time calculation. 1 in 67 chance of timing problem. © 2000 Morgan Kaufman Overheads for Computers as Components

Interprocess communication Interprocess communication (IPC): OS provides mechanisms so that processes can pass data. Two types of semantics: blocking: sending process waits for response; non-blocking: sending process continues. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components IPC styles Shared memory: processes have some memory in common; must cooperate to avoid destroying/missing messages. Message passing: processes send messages along a communication channel---no common address space. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Shared memory Shared memory on a bus: memory CPU 1 CPU 2 © 2000 Morgan Kaufman Overheads for Computers as Components

Race condition in shared memory Problem when two CPUs try to write the same location: CPU 1 reads flag and sees 0. CPU 2 reads flag and sees 0. CPU 1 sets flag to one and writes location. CPU 2 sets flag to one and overwrites location. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Atomic test-and-set Problem can be solved with an atomic test-and-set: single bus operation reads memory location, tests it, writes it. ARM test-and-set provided by SWP: ADR r0,SEMAPHORE LDR r1,#1 GETFLAG SWP r1,r1,[r0] BNZ GETFLAG © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Critical regions Critical region: section of code that cannot be interrupted by another process. Examples: writing shared memory; accessing I/O device. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Semaphores Semaphore: OS primitive for controlling access to critical regions. Protocol: Get access to semaphore with P(). Perform critical region operations. Release semaphore with V(). © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Message passing Message passing on a network: CPU 1 CPU 2 message message message © 2000 Morgan Kaufman Overheads for Computers as Components

Process data dependencies One process may not be able to start until another finishes. Data dependencies defined in a task graph. All processes in one task run at the same rate. P1 P2 P3 P4 © 2000 Morgan Kaufman Overheads for Computers as Components

Other operating system functions Date/time. File system. Networking. Security. © 2000 Morgan Kaufman Overheads for Computers as Components

Some Scheduling Policies A scheduling policy defines how processes are selected for promotion from the ready state to the running state. Every multitasking OS implements some type of scheduling policy. Choosing the right scheduling policy not only ensures that the system will meet all its timing requirements, but it also has a profound influence on the CPU horsepower required to implement the system’s functionality. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components Schedulability means whether there exists a schedule of execution for the processes in a system that satisfies all their timing requirements. Utilization is one of the key metrics in evaluating a scheduling policy. Our most basic requirement is that CPU utilization be no more than 100% since we can’t use the CPU more than 100% of the time. © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components When we evaluate the utilization of the CPU, we generally do so over a finite period that covers all possible combinations of process executions. For periodic processes, the length of time that must be considered is the hyperperiod, which is the least-common multiple of the periods of all the processes. The complete schedule for the least-common multiple of the periods is sometimes called the unrolled schedule © 2000 Morgan Kaufman Overheads for Computers as Components

Overheads for Computers as Components © 2000 Morgan Kaufman Overheads for Computers as Components