15-410, S’04 - 1 - The Process Jan. 21, 2004 Dave Eckhardt Bruce Maggs L05_Process 15-410 “System call abuse for fun & profit”

Slides:



Advertisements
Similar presentations
Process Management.
Advertisements

Chapter 3 Process Description and Control
1 CS345 Operating Systems Φροντιστήριο Άσκησης 1.
The Process Model.
CSE 451: Operating Systems Winter 2006 Module 4 Processes Ed Lazowska Allen Center 570.
Processes CSCI 444/544 Operating Systems Fall 2008.
CS 311 – Lecture 14 Outline Process management system calls Introduction System calls  fork()  getpid()  getppid()  wait()  exit() Orphan process.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Forking & Process Scheduling Vivek Pai / Kai Li Princeton University.
Home: Phones OFF Please Unix Kernel Parminder Singh Kang Home:
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.
CSSE Operating Systems
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
University of Pennsylvania 9/12/00CSE 3801 Multiprogramming CSE 380 Lecture Note 3.
Processes in Unix, Linux, and Windows CS-502 Fall Processes in Unix, Linux, and Windows CS502 Operating Systems (Slides include materials from Operating.
Process. Process Concept Process – a program in execution Textbook uses the terms job and process almost interchangeably A process includes: – program.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Introduction to Processes CS Intoduction to Operating Systems.
Lecture 5 Process, Thread and Task September 22, 2015 Kyu Ho Park.
Today’s Topics Introducing process: the basic mechanism for concurrent programming –Process management related system calls Process creation Process termination.
Exec Function calls Used to begin a processes execution. Accomplished by overwriting process imaged of caller with that of called. Several flavors, use.
Multiprogramming CSE451 Andrew Whitaker. Overview Multiprogramming: Running multiple programs “at the same time”  Requires multiplexing (sharing) the.
The Structure of Processes (Chap 6 in the book “The Design of the UNIX Operating System”)
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Processes: program + execution state
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
System calls for Process management
CS 153 Design of Operating Systems Spring 2015 Lecture 5: Processes and Threads.
Silberschatz, Galvin and Gagne  Operating System Concepts Process Concept An operating system executes a variety of programs:  Batch system.
Operating Systems Process Creation
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
15-410, S’ Hardware Overview Jan. 19, 2004 Dave Eckhardt Bruce Maggs L04_Hardware “Dude, what were you thinking?”
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
1 The Process Dave Eckhardt 1 Synchronization ● Exam flavor? – Is 50 minutes enough? – Two mid-terms? Evening exam? ● Concurrency.
What is a Process ? A program in execution.
System calls for Process management Process creation, termination, waiting.
Direct memory access. IO Command includes: buffer address buffer length read or write dada position in disk When IO complete, DMA sends an interrupt request.
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.
S ALVATORE DI G IROLAMO (TA) Networks and Operating Systems: Exercise Session 1.
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” –
Chapter 3: Process Concept
Protection of System Resources
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.
Chapter 3: Processes.
Processes in Unix, Linux, and Windows
IT 344: Operating Systems Module 4 Processes
Structure of Processes
Processes in Unix, Linux, and Windows
More examples How many processes does this piece of code create?
Processes in Unix, Linux, and Windows
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Mid Term review CSC345.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
October 7, 2002 Gary Kimura Lecture #4 October 7, 2002
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
CSE 451: Operating Systems Autumn 2009 Module 4 Processes
IT 344: Operating Systems Winter 2008 Module 4 Processes
CSE 451: Operating Systems Winter 2007 Module 4 Processes
Processes in Unix and Windows
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
CSE 451: Operating Systems Autumn 2004 Module 4 Processes
Process Description and Control in Unix
Process Description and Control in Unix
Presentation transcript:

15-410, S’ The Process Jan. 21, 2004 Dave Eckhardt Bruce Maggs L05_Process “System call abuse for fun & profit”

15-410, S’ Synchronization Project 0 due at midnight Please go through the hand-in page now Anybody reading comp.risks? Today – Chapter 4, but not exactly!

15-410, S’ Outline Process as pseudo-machine – (that's all there is) Process life cycle Process kernel states Process kernel state

15-410, S’ The Computer

15-410, S’ The Process

15-410, S’ Process life cycle Birth – (or, well, fission)SchoolWorkDeath (Nomenclature courtesy of The Godfathers)

15-410, S’ Birth Where do new processes come from? – (Not: under a cabbage leaf, by stork,...) What do we need? – Memory contents ● Text, data, stack – CPU register contents (N of them) – "I/O ports" ● File descriptors, e.g., stdin/stdout/stderr – Hidden “stuff” ● timer state, current directory, umask

15-410, S’ Birth Intimidating? How to specify all of that stuff? – What is your {name,quest,favorite_color}? Gee, we already have one process we like...

15-410, S’ Birth – fork() - 1 Memory – Copy all of it – Maybe using VM tricks so it' s cheaperRegisters – Copy all of them ● All but one: parent learns child's process ID, child gets 0

15-410, S’ Birth – fork() - 2 File descriptors – Copy all of them – Can't copy the files! – Copy references to open-file state Hidden stuff – Do whatever is "obvious"Result – Original, “parent”, process – Fully-specified “child” process, with 0 fork() parameters

15-410, S’ Now what? Two copies of the same process is boring Transplant surgery! – Implant new memory! ● New program text – Implant new registers! ● Old ones don't point well into the new memory – Keep (most) file descriptors ● Good for cooperation/delegation – Hidden state? ● Do what's “obvious”

15-410, S’ Original Process

15-410, S’ Toss Heap, Data

15-410, S’ Load New Code, Data From File

15-410, S’ Reset Stack, Heap

15-410, S’ Fix “Stuff”

15-410, S’ Initialize Registers

15-410, S’ Begin Execution

15-410, S’ What's This Procedure Called? int execve( char *path, char *argv[ ], char *envp[ ])

15-410, S’ Birth - other ways There is another way – Well, twospawn() – Carefully specify all features of new process – Don't need to copy stuff you will immediately toss Plan 9 rfork() / Linux clone() – Build new process from old one – Specify which things get shared vs. copied

15-410, S’ School Old process called execve( char *path, char *argv[ ], char *envp[ ]); Result is char **environ; main(int argc, char *argv[ ]) {... }

15-410, S’ School How does the magic work? – motto: No magic Kernel process setup: we saw... – Toss old data memory – Toss old stack memory – Load executable fileAlso...

15-410, S’ The Stack! Kernel builds stack for new process – Transfers argv[] and envp[] to top of new process stack – Hand-crafts stack frame for __main() – Sets registers ● Stack pointer (to top frame) ● Program counter (to start of __main())

15-410, S’ Work Process states – Running ● User mode ● Kernel mode – Runnable ● User mode ● Kernel mode – Sleeping ● In condition_wait(), more or less

15-410, S’ Work Other process states – Forking – Zombie “Exercise for the reader” – Draw the state transition diagram

15-410, S’ Death Voluntary void exit(int reason); Software exception – SIGXCPU – used "too much" CPU time Hardware exception – SIGSEGV - no memory there for you!

15-410, S’ Death kill(pid, sig); ^C  kill(getpid(), SIGINT); Start logging kill(daemon_pid, SIGUSR1); % kill -USR1 33 Lost in Space kill(Will_Robinson, SIGDANGER); – I apologize to IBM for lampooning their serious signal ● No, I apologize for that apology...

15-410, S’ Process cleanup Resource release – Open files: close() ● TCP: 2 minutes (or more) ● Solaris disk offline - forever (“None shall pass!”) – Memory: releaseAccounting – Record resource usage in a magic fileGone?

15-410, S’ “All You Zombies...” Zombie process – Process state reduced to exit code – Wait around until parent calls wait() ● Copy exit code to parent memory ● Delete PCB

15-410, S’ Kernel process state The dreaded "PCB" – (polychlorinated biphenol?) Process Control Block – “Everything without a memory address” ● Kernel management information ● Scheduler state ● The “stuff”

15-410, S’ Sample PCB contents CPU register save area Process number, parent process number Countdown timer value Memory segment info – User memory segment list – Kernel stack reference Scheduler info – linked list slot, priority, “sleep channel”

15-410, S’ Conceptual Memory Layout

15-410, S’ Physical Memory Layout

15-410, S’ Ready to Implement All This? Not so complicated... – getpid() – fork() – exec() – wait() – exit() What could possibly go wrong?

15-410, S’ Summary Parts of a Process Virtual – Memory regions, registers, I/O “ports” Physical – Memory pages, registers, I/O devices Birth, School, Work, Death “Big Picture” of memory – both of them (Numbers & arrangement are –specific)