Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes Tarek Abdelzaher Vikram Adve.

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

Processes & Threads Today Next Time Process concept Process model
Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.
Introduction to Processes
The Process Model.
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.
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Unix Processes.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 What is a Process ? The activity of program execution. Also called a task or job Has associated with it: Code Data Resources A State An executing set.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
CS-502 Fall 2006Processes in Unix, Linux, & Windows 1 Processes in Unix, Linux, and Windows CS502 Operating Systems.
CSSE Operating Systems
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
Process Description and Control A process is sometimes called a task, it is a program in execution.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
BINA RAMAMURTHY UNIVERSITY AT BUFFALO System Structure and Process Model 5/30/2013 Amrita-UB-MSES
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Introduction to Processes CS Intoduction to Operating Systems.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
Process. Processes A process is an abstraction for sequence of operations that implement a computation/program. A process may be manipulated, suspended,
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
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.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
Operating Systems Processes 1.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Linux Processes Travis Willey Jeff Mihalik. What is a process? A process is a program in execution A process includes: –program counter –stack –data section.
Processes Dr. Yingwu Zhu. Process Concept Process – a program in execution – What is not a process? -- program on a disk - a process is an active object,
Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes and Threads.
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.
CS4315A. Berrached:CMS:UHD1 Process Management Chapter 6.
1  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
Correct C Programs. The C compiler cc [filename.c] Options include: -o [output file name] -lm to include the maths library -E to get output from preprocessor.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Slide 1 COMP 3438 System Programming UNIX Processes UNIX Processes (Chapters 2 & 3)
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
A process is a program in execution A running system consists of multiple processes – OS processes Processes started by the OS to do “system things” –
Lecture 3 Process.
Chapter 3: Processes.
Topic 3 (Textbook - Chapter 3) Processes
Process Management Presented By Aditya Gupta Assistant Professor
Unix Process Management
Chapter 3: Processes.
Processes A process is a running program.
Example questions… Can a shell kill itself? Can a shell within a shell kill the parent shell? What happens to background processes when you exit from.
Tarek Abdelzaher Vikram Adve Marco Caccamo
System Structure and Process Model
Chapter 3: Processes.
System Structure and Process Model
CGS 3763 Operating Systems Concepts Spring 2013
System Structure B. Ramamurthy.
System Structure and Process Model
Operating Systems Lecture 6.
CGS 3763 Operating Systems Concepts Spring 2013
Process & its States Lecture 5.
Chapter 3: Processes.
Process Creation Process Termination
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Chapter 3: Processes.
Processes in Unix and Windows
CS510 Operating System Foundations
Presentation transcript:

Copyright ©: Nahrstedt, Angrave, Abdelzaher1 Processes Tarek Abdelzaher Vikram Adve

Copyright ©: Nahrstedt, Angrave, Abdelzaher 2 Users, Programs, Processes Users have accounts on the system Users launch programs Many users may launch same program One user may launch many instances of the same program Processes: an executing program (the unit of work of a modern computer)

Copyright ©: Nahrstedt, Angrave, Abdelzaher 3 Process States Possible process states Running (occupy CPU) Blocked Ready (does not occupy CPU) Other states: suspended, terminated Question: in a single processor machine, how many process can be in running state?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 4 Linux: 5 State Process Model Add states for creating and deleting process Add transitions Timeout, Dispatch, Event Occurs

Copyright ©: Nahrstedt, Angrave, Abdelzaher 5 How to List all Processes? On Windows: run Windows task manager Hit Control+ALT+delete Click on the “processes” tab On UNIX $ ps –e Try “man ps” to understand more about its usage.

Copyright ©: Nahrstedt, Angrave, Abdelzaher 6 Process Execution and Context Switching

Copyright ©: Nahrstedt, Angrave, Abdelzaher 7 Process Identification UNIX identifies processes via a unique Process ID Each process also knows its parent process ID since each process is created from a parent process. Root process is the ‘init’ process ‘getpid’ and ‘getppid’ – functions to return process ID (PID) and parent process ID (PPID) Example 1 #include int main (void) { printf(“I am process %ld\n”, (long)getpid()); printf(“My parent id is %ld\n”, (long)getppid()); return 0; }

Copyright ©: Nahrstedt, Angrave, Abdelzaher 8 Creating a Process – fork() fork() creates a duplicate of the calling process: Both processes continue with return from fork() Child gets exact copy of code, stack, file descriptors, heap, globals, and program counter Child gets new pid, ppid, time; no signals, file locks, … fork() returns -1 if fork fails 0 in child process child’s PID in parent process

Copyright ©: Nahrstedt, Angrave, Abdelzaher 9 Creating a Process in Unix Example 2 #include int main(void) { pid_t x; x = fork(); if (x == 0) printf(“In child: fork() returned %ld\n”, (long) x); else printf(“In parent: fork() returned %ld\n", (long) x); } What does this print?

Copyright ©: Nahrstedt, Angrave, Abdelzaher 10 Chain and Fan Child Parent Child … … pid_t childpid = 0; for (i=1;i<n;i++) if (childpid = fork()) break; pid_t childpid = 0; for (i=1;i<n;i++) if ((childpid = fork()) <=0) break; Chain Fan

Copyright ©: Nahrstedt, Angrave, Abdelzaher 11 Process Operations: Creation A new process needs resources such as CPU, memory, file descriptors, I/O devices Child can get resources from OS or from parent Child address space is duplicate of parent process Child process is given a subset of parent resources Prevents too many processes from overloading system Execution possibilities are Parent continues concurrently with child Parent waits until child has terminated

Copyright ©: Nahrstedt, Angrave, Abdelzaher 12 Process Termination Normal exit (voluntary) End of main() exit(0) Error exit (voluntary) exit(2) or abort() Fatal error (involuntary) Divide by 0, seg fault, exceeded resources Killed by another process (involuntary) Signal: kill(procID)

Copyright ©: Nahrstedt, Angrave, Abdelzaher 13 Process Operations: Termination When a process terminates: Open files are flushed and closed Tmp files are deleted Child’s resources are de-allocated File descriptors, memory, semaphores, file locks, … Parent process is notified via a signal Exit status is available to parent via wait()

Copyright ©: Nahrstedt, Angrave, Abdelzaher 14 Process Hierarchies Parent creates a child process, a child process can create its own processes Forms a hierarchy UNIX calls this a "process group" Windows has no concept of process hierarchy all processes are created equal

Copyright ©: Nahrstedt, Angrave, Abdelzaher 15 wait(), waitpid() System Calls wait() causes parent process to wait (block) until some child finishes wait() returns child’s pid and exit status to parent waitpid() waits for a specific child errnoCause ECHILDCaller has no unwaited-for children EINTRFunction was interrupted by signal EINVALOptions parameter of waitpid was invalid

Copyright ©: Nahrstedt, Angrave, Abdelzaher 16 Waiting for a child to finish (Try “man –s 2 wait”) #include pid_t childpid; childpid = wait(NULL); if (childpid != -1) printf(“waited for child with pid %ld\n”, childpid);