© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems zMotivation for processes. zThe process abstraction. zContext.

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

Process management Information maintained by OS for process management  process context  process control block OS virtualization of CPU for each process.
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
Processes and operating systems zMultiple tasks and multiple processes. ySpecifications of process timing. zPreemptive real-time operating systems.
Operating Systems COMP 4850/CISG 5550 Processes Introduction to Threads Dr. James Money.
Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
Big Picture Lab 4 Operating Systems Csaba Andras Moritz.
© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zMultiple tasks and multiple processes. ySpecifications.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Thursday, June 08, 2006 The number of UNIX installations has grown to 10, with more expected. The UNIX Programmer's Manual, 2nd Edition, June, 1972.
Overview Processes Context switching Operating systems
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
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.
Threads CSCI 444/544 Operating Systems Fall 2008.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
Real-Time Kernels and Operating Systems. Operating System: Software that coordinates multiple tasks in processor, including peripheral interfacing Types.
1 Introduction Chapter What is an operating system 1.2 History of operating systems 1.3 The operating system zoo 1.4 Computer hardware review 1.5.
© 2008 Wayne Wolf Overheads for Computers as Components 2 nd ed. Processes and operating systems zInterprocess communication. zOperating system performance.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
ThreadsThreads operating systems. ThreadsThreads A Thread, or thread of execution, is the sequence of instructions being executed. A process may have.
CSC 501 Lecture 2: Processes. Process Process is a running program a program in execution an “instantiation” of a program Program is a bunch of instructions.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems zMotivation for processes. zThe process abstraction. zContext.
What Every Developer Should Know about the Kernel Dr. Michael L. Collard 1.
Threads G.Anuradha (Reference : William Stallings)
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
Computer Studies (AL) Operating System Process Management - Process.
© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems Operating systems. 1.
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.
Concurrency & Context Switching Process Control Block What's in it and why? How is it used? Who sees it? 5 State Process Model State Labels. Causes of.
ECE291 Computer Engineering II Lecture 15 Dr. Zbigniew Kalbarczyk University of Illinois at Urbana- Champaign.
Operating Systems ECE344 Ashvin Goel ECE University of Toronto Unix System Calls and Posix Threads.
1 VxWorks 5.4 Group A3: Wafa’ Jaffal Kathryn Bean.
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.
Ch4 Process and Operating System. Content Motivation for processes The process abstraction Context switching and Multitasking Operating System Scheduling.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
What is a Process ? A program in execution.
Assembly Language Co-Routines
CPS110: Implementing threads on a uni-processor Landon Cox January 29, 2008.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Big Picture Lab 4 Operating Systems C Andras Moritz
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Threads prepared and instructed by Shmuel Wimer Eng. Faculty, Bar-Ilan University 1July 2016Processes.
Processes and operating systems
Topics Covered What is Real Time Operating System (RTOS)
CS 143A Quiz 1 Solution.
Mid Term review CSC345.
Processes and operating systems
Ch4 Process and Operating System
Threads and Concurrency
EE 472 – Embedded Systems Dr. Shwetak Patel.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Chapter 3: Processes.
Processes David Ferry CSCI 3500 – Operating Systems
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix and Windows
CS510 Operating System Foundations
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

© 2000 Morgan Kaufman Overheads for Computers as Components Processes and operating systems zMotivation for processes. zThe process abstraction. zContext switching. zMultitasking. zProcesses and UML.

© 2000 Morgan Kaufman Overheads for Computers as Components Why multiple processes? zProcesses help us manage timing complexity: ymultiple rates xmultimedia xautomotive yasynchronous input xuser interfaces xcommunication systems

© 2000 Morgan Kaufman Overheads for Computers as Components Example: engine control zTasks: yspark control ycrankshaft sensing yfuel/air mixture yoxygen sensor yKalman filter engine controller

© 2000 Morgan Kaufman Overheads for Computers as Components Life without processes zCode turns into a mess: yinterruptions of one task for another yspaghetti code time A B C A C A_code(); … B_code(); … if (C) C_code(); … A_code(); … switch (x) { case C: C(); case D: D();...

© 2000 Morgan Kaufman Overheads for Computers as Components Co-routines ADR r14,co2a co1a … ADR r13,co1b MOV r15,r14 co1b … ADR r13,co1c MOV r15,r14 co1c... co2a … ADR r13,co2b MOV r15,r13 co2b … ADR r13,co2c MOV r15,r13 co2c … Co-routine 1 Co-routine 2

© 2000 Morgan Kaufman Overheads for Computers as Components Co-routine methodology zLike subroutine, but caller determines the return address. zCo-routines voluntarily give up control to other co-routines. zPattern of control transfers is embedded in the code.

© 2000 Morgan Kaufman Overheads for Computers as Components Processes zA process is a unique execution of a program. ySeveral copies of a program may run simultaneously or at different times. zA process has its own state: yregisters; ymemory. zThe operating system manages processes.

© 2000 Morgan Kaufman Overheads for Computers as Components Processes and CPUs zActivation record: copy of process state. zContext switch: ycurrent CPU context goes out; ynew CPU context goes in. CPU PC registers process 1 process 2... memory

© 2000 Morgan Kaufman Overheads for Computers as Components Terms zThread = lightweight process: a process that shares memory space with other processes. zReentrancy: ability of a program to be executed several times with the same results.

© 2000 Morgan Kaufman Overheads for Computers as Components Processes in POSIX zCreate a process with fork: yparent process keeps executing old program; ychild process executes new program. process a process b

© 2000 Morgan Kaufman Overheads for Computers as Components fork() zThe fork process creates child: childid = fork(); if (childid == 0) { /* child operations */ } else { /* parent operations */ }

© 2000 Morgan Kaufman Overheads for Computers as Components execv() zOverlays child code: childid = fork(); if (childid == 0) { execv(“mychild”,childargs); perror(“execv”); exit(1); } file with child code

© 2000 Morgan Kaufman Overheads for Computers as Components Context switching zWho controls when the context is switched? zHow is the context switched?

© 2000 Morgan Kaufman Overheads for Computers as Components Co-operative multitasking zImprovement on co-routines: yhides context switching mechanism; ystill relies on processes to give up CPU. zEach process allows a context switch at cswitch() call. zSeparate scheduler chooses which process runs next.

© 2000 Morgan Kaufman Overheads for Computers as Components Problems with co- operative multitasking zProgramming errors can keep other processes out: yprocess never gives up CPU; yprocess waits too long to switch, missing input.

© 2000 Morgan Kaufman Overheads for Computers as Components Context switching zMust copy all registers to activation record, keeping proper return value for PC. zMust copy new activation record into CPU state. zHow does the program that copies the context keep its own context?

© 2000 Morgan Kaufman Overheads for Computers as Components Context switching in ARM zSave old process: STMIA r13,{r0-r14}^ MRS r0,SPSR STMDB r13,{r0,r15} z Start new process: ADR r0,NEXTPROC LDR r13,[r0] LDMDB r13,{r0,r14} MSR SPSR,r0 LDMIA r13,{r0-r14}^ MOVS pc,r14

© 2000 Morgan Kaufman Overheads for Computers as Components Preemptive multitasking zMost powerful form of multitasking: yOS controls when contexts switches; yOS determines what process runs next. zUse timer to call OS, switch contexts: CPU timer interrupt

© 2000 Morgan Kaufman Overheads for Computers as Components Flow of control with preemption time P1OSP1OSP2 interrupt

© 2000 Morgan Kaufman Overheads for Computers as Components Preemptive context switching zTimer interrupt gives control to OS, which saves interrupted process’s state in an activation record. zOS chooses next process to run. zOS installs desired activation record as current CPU state.

© 2000 Morgan Kaufman Overheads for Computers as Components Why not use interrupts? zWe could change the interrupt vector at every period, but: ywe would need management code anyway; ywe would have to know the next period’s process at the start of the current process.

© 2000 Morgan Kaufman Overheads for Computers as Components Processes and UML zA process is an active class---independent thread of control. processClass1 myOperations() start resume myAttributes Signals

© 2000 Morgan Kaufman Overheads for Computers as Components UML signals zSignal: object that is passed between processes for active communication: acomm: datasignal

© 2000 Morgan Kaufman Overheads for Computers as Components Designing with active objects zCan mix normal and active objects: p1: processClass1 master: masterClass w: wrapperClass a: rawMsg ahat: fullMsg