Operating Systems CMPSC 473 Processes (4) September 19 2008 - Lecture 10 Instructor: Bhuvan Urgaonkar.

Slides:



Advertisements
Similar presentations
Chapter 3 Process Description and Control
Advertisements

Threads Irfan Khan Myo Thein What Are Threads ? a light, fine, string like length of material made up of two or more fibers or strands of spun cotton,
Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads.
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 5 Processes and Threads Copyright © 2008.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
1 Processes Professor Jennifer Rexford
Processes CSCI 444/544 Operating Systems Fall 2008.
Process in Unix, Linux and Windows CS-3013 C-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Ceng Operating Systems Chapter 2.1 : Processes Process concept Process scheduling Interprocess communication Deadlocks Threads.
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.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control 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.
Chapter 51 Threads Chapter 5. 2 Process Characteristics  Concept of Process has two facets.  A Process is: A Unit of resource ownership:  a virtual.
Processes Part I Processes & Threads* *Referred to slides by Dr. Sanjeev Setia at George Mason University Chapter 3.
Operating Systems CSE 411 CPU Management Sept Lecture 11 Instructor: Bhuvan Urgaonkar.
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Operating Systems CMPSC 473 Threads September 16, Lecture 7 Instructor: Bhuvan Urgaonkar.
Introduction to Processes CS Intoduction to Operating Systems.
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.
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Linux Kernel introduction COSC 513 Xiaoping Yang.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
1 Chapter 2.1 : Processes Process concept Process concept Process scheduling Process scheduling Interprocess communication Interprocess communication Threads.
Multiprogramming. Readings r Silberschatz, Galvin, Gagne, “Operating System Concepts”, 8 th edition: Chapter 3.1, 3.2.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Operating Systems CMPSC 473 Lecture 8: Threads September Instructor: Bhuvan Urgaonkar.
Computer Studies (AL) Operating System Process Management - Process.
Operating Systems CMPSC 473 Processes August 31, Lecture 3 Instructor: Bhuvan Urgaonkar.
1 Chapter 4 Processes R. C. Chang. 2 Linux Processes n Each process is represented by a task_struct data structure (task and process are terms that Linux.
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.
CSC 660: Advanced Operating SystemsSlide #1 CSC 660: Advanced OS Processes.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
Operating Systems CSE 411 CPU Management Sept Lecture 10 Instructor: Bhuvan Urgaonkar.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Operating Systems CMPSC 473 Processes (3) September Lecture 9 Instructor: Bhuvan Urgaonkar.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
CSC 660: Advanced Operating Systems
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.
What is a Process ? A program in execution.
Operating Systems CMPSC 473 Processes (5) September Lecture 11 Instructor: Bhuvan Urgaonkar.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
ECE 297 Concurrent Servers Process, fork & threads ECE 297.
Processes David Ferry, Chris Gill CSE 522S - Advanced Operating Systems Washington University in St. Louis St. Louis, MO
Processes and threads.
Operating Systems CMPSC 473
Process Management Process Concept Why only the global variables?
Chapter 3: Processes.
Processes David Ferry, Chris Gill
Processes in Unix, Linux, and Windows
Threads & multithreading
Processes in Unix, Linux, and Windows
Processes in Unix, Linux, and Windows
Operating Systems Processes (Ch 4.1).
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Chapter 3: Processes.
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix, Linux, and Windows
Processes in Unix and Windows
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Process Description and Control in Unix
Processes David Ferry, Chris Gill, Brian Kocoloski
Presentation transcript:

Operating Systems CMPSC 473 Processes (4) September Lecture 10 Instructor: Bhuvan Urgaonkar

Overview of Process- related Topics How a process is born –Parent/child relationship –fork, clone, … How it leads its life –Loaded: Later in the course –Executed CPU scheduling Context switching Where a process “lives”: Address space –OS maintains some info. for each process: PCB –Process = Address Space + PCB How processes request services from the OS –System calls How processes communicate Some variants of processes: LWPs and threads How processes die Done Partially done

Kernel Mode Stack thread_info structure PCB (task_struct) esp curent Stack Since KM stacks make little use of the stack, only a few thousand bytes suffice –An example of “Design for the most common case”, we’ll see more –Linux: 8KB, thread_info 52 bytes thread_info task

Kernel Mode Stack thread_info structure PCB (task_struct) esp curent Stack Since KM stacks make little use of the stack, only a few thousand bytes suffice –An example of “Design for the most common case”, we’ll see more –Linux: 8KB Why combine KM stack and thread_info into a union? thread_info union thread_union { struct thread_info thread_info; unsigned long stack[2048]; }; task

Kernel Mode Stack thread_info structure PCB (task_struct) esp curent Stack Since KM stacks make little use of the stack, only a few thousand bytes suffice –An example of “Design for the most common case”, we’ll see more –Linux: KM Stack 8KB, thread_info 52 bytes Why combine KM stack and thread_info into a union? –You might think spatial locality –The kernel can easily obtain the address of the thread_info structure of the process currently running on the CPU from the value of the esp register –task field is at offset 0 –Other benefits apply to multi-processors: makes it easy to efficiently find the current process on each processor Earlier approach: Have an array of current pointers thread_info task union thread_union { struct thread_info thread_info; unsigned long stack[2048]; };

Resource Limits Kernel imposes limits on the amount of resources a process may have –E.g., address space size, open files Linux: For each resource, for each process struct rlimit { unsigned long rlim_cur; unsigned long rlim_max; } System calls: getrlimit (), setrlimit () to increase upto some max allowed by kernel

Relationships among processes Several relatives of P recorded in its PCB –real_parent Process that called fork to create P Or init (process 1) –parent Usually real_parent –Kernel signals this parent process when child exits Or process that issues ptrace () to monitor P Pop quiz: If you run a background process and exit the shell, who is the parent of the process? –children –siblings Why maintain these?

Process Switch Suspend the current process and resume a previously suspended process –Also called context switch or task switch What does the kernel need to save when suspending a process? –Hint: The entire address space is already saved (either in memory or on swap space). What else would the process need when it has to be resumed?

Process Switch Suspend the current process and resume a previously suspended process –Also called context switch or task switch What does the kernel need to save when suspending a process? –Hint: The entire address space is already saved (either in memory or on swap space). What else would the process need when it has to be resumed? –CPU registers This is called the hardware context of the process Linux: Part of h/w context saved within PCB, rest on kernel mode stack (why?)

Process Switch So process switch involves –Saving h/w context of currently running process –Restoring h/w context of process to resume Who decides which process to resume?

Process Switch So process switch involves –Saving h/w context of currently running process –Restoring h/w context of process to resume Who decides which process to resume? –The CPU scheduler –Generic code for a process switch next = schedule (prev); switch_to (next, prev); > GORY! SKIPPING!! blah blah blah Note: next starts executing not blah. How? Project 1 will give you a taste of this :)

Creating Processes fork () Take 1: Used in older kernels –Create a copy of the entire address space of the parent –Create a new PCB for the new process –Update parent, children, sibling pointers –Place the new process in the ready queue S. L. O. W.

Creating Processes fork () Problems with Take 1 –Child rarely needs to read/modify ALL the resources inherited from the parent –Often, it immediately issues an execve() rendering all the effort that went into copying the address space useless!

Creating Processes fork () What modern kernels do to avoid this waste of precious CPU time COW!! Something in the way she moos …

Creating Processes: COW fork () What modern kernels do to avoid this waste of precious CPU time –Use COW! –Copy-On-Write –Basic idea: Postpone work till the last minute –Sounds familiar? Think assignments, quizzes, …