CSE 451: Operating Systems Winter 2012 Processes Mark Zbikowski Gary Kimura.

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

CSE 451: Operating Systems Winter 2007 Module 4 Processes Ed Lazowska Allen Center 570.
IT344 – Operating Systems Winter 2011, Dale Rowe.
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.
CSE 451: Operating Systems Winter 2009 Module 4 Processes Mark Zbikowski Gary Kimura.
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.
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.
CSE451 Processes Spring 2001 Gary Kimura Lecture #4 April 2, 2001.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Processes April 5, 2000 Instructor: Gary Kimura Slides courtesy of Hank Levy.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
CSE 451: Operating Systems Spring 2012 Module 4 Processes Ed Lazowska Allen Center 570.
Lecture Topics: 11/3 Address spaces Memory protection Creating a process –NT style –Unix style.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Slide 6-1 Copyright © 2004 Pearson Education, Inc. Operating Systems: A Modern Perspective, Chapter 6.
COP 4600 Operating Systems Spring 2011 Dan C. Marinescu Office: HEC 304 Office hours: Tu-Th 5:00-6:00 PM.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Implementing Processes and Process Management Brian Bershad.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
Processes and Threads CS550 Operating Systems. Processes and Threads These exist only at execution time They have fast state changes -> in memory and.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
CE Operating Systems Lecture 10 Processes and process management in Linux.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
CSE 451: Operating Systems Winter 2015 Module 5 1 / 2 User-Level Threads & Scheduler Activations Mark Zbikowski 476 Allen Center.
2 Processor(s)Main MemoryDevices Process, Thread & Resource Manager Memory Manager Device Manager File Manager.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Lecture 5 Page 1 CS 111 Online Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Processes and threads.
Process Management Process Concept Why only the global variables?
Chapter 3: Process Concept
Lecture Topics: 11/1 Processes Process Management
CSE 451: Operating Systems Autumn 2013 Module 4 Processes
Process Creation Processes get created (and destroyed) all the time in a typical computer Some by explicit user command Some by invocation from other running.
Operating Systems: A Modern Perspective, Chapter 6
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Module 4 Processes
Processes in Unix, Linux, and Windows
Lecture 2: Processes Part 1
Processes in Unix, Linux, and Windows
System Structure and Process Model
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
CSE 451: Operating Systems Winter 2011 Processes
CSE 451: Operating Systems Winter 2010 Module 4 Processes
Lecture Topics: 11/1 General Operating System Concepts Processes
Process Description and Control
Processes Hank Levy 1.
Processes and Process Management
Process Description and Control
CSE 451: Operating Systems Winter 2009 Module 5 Threads
Chapter 3: Processes.
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
CSE 451: Operating Systems Winter 2003 Lecture 4 Processes
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Autumn 2009 Module 4 Processes
IT 344: Operating Systems Winter 2008 Module 4 Processes
Implementing Processes, Threads, and Resources
CSE 451: Operating Systems Winter 2007 Module 4 Processes
Processes in Unix and Windows
CS510 Operating System Foundations
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
CSE 451: Operating Systems Spring 2006 Module 4 Processes
CSE 153 Design of Operating Systems Winter 2019
Processes Hank Levy 1.
CSE 451: Operating Systems Autumn 2010 Module 4 Processes
Presentation transcript:

CSE 451: Operating Systems Winter 2012 Processes Mark Zbikowski Gary Kimura

Process management This module begins a series of topics on processes, threads, and synchronization –this is the most important part of the class, well, except for file systems and disks… Today: processes and process management –what are the OS units of ownership / execution? –how are they represented inside the OS? –how is the CPU scheduled across processes? –what are the possible execution states of a process? and how does the system move between them? –How are they created? –How can this be made faster 2

A Digression – Mechanism and Policy Mechanism – how to do something (schedule a thread, fix a lightbulb) Policy – when to do something, who is authorized to do it (network packet arrived for thread, light is burned out by anyone but me) Mechanisms should NOT dictate policy. –Allows multiple policies for same mechanism (fix lights in batches) –Allows multiple mechanisms for same policy (fix lights by myself [unreliable,cheap], call electrician [reliable,expensive]) 4 January, 20103

Digression, part II Fundamental approach for present day software design, notably microkernels/exokernel (aka “no- kernel”) Separation allows detailed study of design and implementation choices (searching for highest priority activity by computation vs keeping a sorted list where insertion decides priority) Not a recent concept, first papers were in the early 70’s although references can be found in the early 60’s. But I digress… 4 January, 20104

5 The Process The process is the OS’s abstraction for execution –the unit of ownership (root of web/tree of kernel data structures) –the unit of execution (sorta) –the unit of scheduling (kinda) –the dynamic (active) execution context compared with program: static, just a bunch of bytes Process is often called a job, task, or sequential process The goal of the OS is to present each Process with the view that it is executing in it’s own separate, isolated computer

What is a “process”? Simple, classic case (1950’s): a sequential process –An address space (abstraction of “memory”) –A single bit of execution: a “thread” A sequential process is: –The unit of execution –The unit of scheduling –The execution context (registers, OS state, –memory, etc.) 4 January, 20106

What is a process? Process == fundamental abstraction for program execution –an address space which contains: the code for the running program the data for the running program –at least one thread with state Registers, IP Floating point state Stack and stack pointer –a set of OS resources open files, network connections, security caches, sound channels, … In other words, it’s all the stuff you need to run the program 7

8 A process’s address space (very simplified, wait till next lecture) 0x x7FFFFFFF 32-bit address space code (text segment) static data (data segment) heap (dynamic allocated mem) stack (dynamic allocated mem) IP SP

8/24/20159 The OS’s process namespace (Like most things, the particulars depend on the specific OS, but the principles are general) The name for a process is called a process ID (PID) –An integer (how many bits?), possibly a string(!) The PID namespace is global to the system –Only one process at a time has a particular PID: uniqueness Operations that create processes return a PID –E.g., NtCreateProcess, ShellExecute Operations on processes take PIDs as an argument –E.g., NtOpenProcess

10 There’s a data structure called the process object (_ KPROCESS in base\ntos\inc\ke.h) that holds all this stuff –Processes are identified from user space by a process ID, returned by NtCreateProcess. OS keeps all of a process’s hardware execution state in the _KTHREAD (same file) when the process isn’t running –IP, SP, registers, etc. –when a process is unscheduled (i.e., processor is taken away from the process), the state is transferred out of the hardware into the _KTHREAD Note: It’s natural to think that there must be some esoteric techniques being used –fancy data structures that you’d never think of yourself Wrong! It’s pretty much just what you’d think of! Except for some clever assembly code in one place… The Process Object

8/24/2015 © 2010 Gribble, Lazowska, Levy, Zahorjan 11 _KTHREADs and hardware state When a process is running, its hardware state is inside the CPU –IP, SP, registers –CPU contains current values When a process is transitioned to the waiting state, the OS saves its CPU state in the _KTHREAD (actually, _PRCB, but that’s not important ) –when the OS returns the process to the running state, it loads the hardware registers with values from that process’s _KTHREAD The act of switching the CPU from one process to another is called a context switch –systems may do 100s or 1000s of switches/sec. –takes a few microseconds on today’s hardware Choosing which process to run next is called scheduling, more when we talk about threads

12 Process creation New processes are created by existing processes –creator is called the parent –created process is called the child –what creates the first process, and when? In some systems, parent defines or donates resources and privileges for its children –LINUX/UNIX: child inherits parent’s security context, environment, open file list, etc. –NT: all the above are optional (remember, mechanism vs policy), the Windows subsystem provides policy. When child is created, parent may either wait for it to finish, or may continue in parallel, or both!

13 Process Creation 2 In LINUX, fork/exec pairs. –fork() clones the current process, duplicates all memory, “inherit” open files –exec() throws away all memory and loads new program into memory. Keeps all open files! –Very useful, but… wasteful. >99% of all fork() calls followed by exec(). Copy-on-write memory helps but still a big overhead (have to “duplicate” all data structures) Windows has parent process doing the work –Create process –Fill in memory –Pass handles –Create thread with stack and IP –Many system calls (compared with LINUX) but all policy is in user code. More flexible.

14 Process Destruction Privileged operation! –Process can always kill itself –Killing another process requires permission Terminates all threads (next lecture) Releases owned resources to known state –Files –Events –Memory Notification sent to interested parties KPROCESS is freed