1 Last Time: OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features.

Slides:



Advertisements
Similar presentations
3.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Process An operating system executes a variety of programs: Batch system.
Advertisements

CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Processes CSCI 444/544 Operating Systems Fall 2008.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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.
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
Process Concept An operating system executes a variety of programs
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Concept Process – a program.
Operating Systems Chapter 2
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,
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 7 OS System Structure.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 2 Processes Processes Topics Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Computer Studies (AL) Operating System Process Management - Process.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 2 Process Management. 2 Objectives After finish this chapter, you will understand: the concept of a process. the process life cycle. process states.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Lecture 4: Processes & Threads. Lecture 4 / Page 2AE4B33OSS Silberschatz, Galvin and Gagne ©2005 Contents The concept of Process Process states and life-cycle.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
U NIVERSITY OF M ASSACHUSETTS, A MHERST Department of Computer Science Emery Berger University of Massachusetts, Amherst Operating Systems CMPSCI 377 Lecture.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Lecture 3 Process.
Chapter 3: Processes.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
Processes in Unix, Linux, and Windows
Process & its States Lecture 5.
Mid Term review CSC345.
Chapter 3: Processes.
Operating System Concepts
Processes Hank Levy 1.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Processes Hank Levy 1.
Chapter 3: Process Concept
Presentation transcript:

1 Last Time: OS & Computer Architecture Modern OS Functionality (brief review) Architecture Basics Hardware Support for OS Features

2 Last Time: Services & Hardware Support OS ServiceHardware Support Protection Interrupts Traps I/O Synchronization Virtual Memory Scheduling

3 This Time: OS Organizations & Processes OS Organizations (kernels) Processes

4 Monolithic Kernel Classic UNIX approach, Linux Everything in kernel +Fast -Risky

5 Layered OS Design +Modular, simple, portable, easy to design/debug -Communication overhead, copying, bookkeeping “THE” operating system Dijkstra

6 The Microkernel Approach Goal: Minimize contents of kernel Why?

7 Microkernel: Motivation Minimize contents of kernel: Reduces risk of crashing OS Put as much functionality as possible in user-level processes Simplifies extension, modification & customization First μ-kernel: Hydra (CMU) Current systems: Mach (also CMU), by Rick Rashid et al. (now head of MSR)

8 μ -kernels vs. Monolithic Kernels Past conventional wisdom: (1990’s) Mach – beautiful research idea but “failed” in practice Too slow! Linux – ugly, monolithic, but fast Today: much faster computers Mach: fast enough (Mac OS X)  Reliability, simplicity, robustness now more important than performance

9 OS Structures & Processes OS Organizations (kernels) Processes

10 Process OS manages variety of activities: User programs, batch jobs, command scripts Daemons: print spoolers, name servers, file servers, etc. Each activity encapsulated in process: Context (PC, registers, etc.) required for activity to run

11 Process != program Process is a running program One program may comprise many processes Many processes may run same program

12 OS and Processes OS manages & schedules processes Creation, deletion Resource allocation (e.g., CPU, memory) Suspension & resumption Inter-process communication Synchronization

13 Processes Process Concept Process States Process Scheduling Process Management Interprocess Communication

14 Process Concept Process – program in execution Process includes: text section: program code current activity: program counter, contents in registers stack data section heap

15 Processes Process Concept Process States Process Scheduling Process Management Interprocess Communication

16 Process States New Process being created Running Instructions being executed Waiting Process waiting for some event to occur Ready Process waiting to be assigned to a processor Terminated (duh)

17 Process State Diagram Transitions: Program actions (system calls) OS actions (scheduling) External events (interrupts)

18 Process Execution Example void main() { printf (“Hello world\n”); } 1. New 2. Ready 3. Running 4. Waiting for I/O 5. Ready 6. Running 7. Terminated

19 Process Data Structures Process Control Block: Tracks state OS allocates, places on queue OS deallocates on termination Lots of info: Process state Program counter CPU registers Memory-management information Accounting information I/O status information

20 Processes Process Concept Process States Process Scheduling Process Management Interprocess Communication

21 Process Scheduling Queues Job queue Set of all processes in system Ready queue Set of processes residing in main memory ready & waiting to execute Device queues Set of processes waiting for I/O device One per device Process migration between the various queues.

22 Process Queues Example

23 CPU Scheduling time

24 PCBs and Hardware State Switching processes: context switch Relatively expensive Time between switches (quantum) must be long enough to amortize this cost Start: OS picks ready process Loads register values from PCB Stop: OS saves registers into PCB

25 Process Scheduling Queuing-diagram representation:

26 Processes Process Concept Process States Process Scheduling Process Management Interprocess Communication

27 Process Creation One process can create other processes Creator = parent, new processes = children Parent can wait for child to complete, or continue in parallel UNIX: fork() used to create child processes Copies variables & registers from parent to child Only difference between parent & child: return value Parent: returns process id of child Child: returns 0

28 Process Creation Example Logging into UNIX creates shell process Every command typed into shell: Child of shell process (spawned by fork ) Executes command via exec Example: Type “emacs” OS forks new process exec executes emacs If followed by “&”, runs in parallel; otherwise, waits until done

29 Example UNIX Program: Fork

30 Fork Example: What happened? #include int main(){ int parentID = getpid(); char prgname[1024]; gets(prgname); int cid = fork(); if(cid == 0){ execlp(prgname, prgname, 0); printf(“I did not find program %s\n“, prgname); } else{ sleep(1); waitpid(cid, 0, 0); printf("Program %s is finished. \n"); } return 0; } Parent process: #include int main(){ int parentID = getpid(); char prgname[1024]; gets(prgname); int cid = fork(); if(cid == 0){ execlp(prgname, prgname, 0); printf(“I did not find program %s\n“, prgname); } else{ sleep(1); waitpid(cid, 0, 0); printf("Program %s is finished. \n"); } return 0; } Child process:

31 Parent & Child Process #include int main(){ int pid; pid = fork(); if(pid == 0){ printf("Child: My PID = %d\n", getpid()); printf("Child: Running...\n"); sleep(20); printf("Child: Done sleeping, returning.\n"); } else{ printf("Parent: My PID = %d\n", getpid()); printf("Parent: Running...\n"); sleep(10); printf("Parent: Done sleeping, returning.\n"); } return 0; }

32 Process Termination On termination, OS reclaims all resources assigned to process UNIX processes: Can terminate self via exit system call Can terminate child via kill system call

33 Example: Process Termination

34 Processes Process Concept Process States Process Scheduling Process Management Interprocess Communication

35 Cooperating Processes Cooperating processes: one process can affect or be affected by other processes Advantages: Can improve performance by overlapping activities or performing work in parallel Can enable simpler program design Simplifies distribution Processes can live on different machines

36 Interprocess Communication Processes communicate in one of two ways: Message passing: Send and receive information Numerous means: sockets, pipes, etc. Shared memory: Establish mapping to named memory object Use mmap Fork processes that share this structure

37 Process Summary Process = unit of execution Represented by Process Control Blocks Contain process state, registers, etc. Process state: New, Ready, Waiting, Running, or Terminated One running process at a time (on a uniprocessor) Context switch when changing process executing on CPU Communicate by message passing or shared memory