Processes. Operating System CS 217. Supports virtual machines. Provides services: User Process. User Process. OS Kernel. Hardware

Similar documents
Process Management! Goals of this Lecture!

Process Management 1

CSC 1600 Unix Processes. Goals of This Lecture

CPSC 341 OS & Networks. Processes. Dr. Yingwu Zhu

Fall 2015 COMP Operating Systems. Lab #3

Process a program in execution; process execution must progress in sequential fashion. Operating Systems

Operating Systems. Lecture 05

Processes. Overview. Processes. Process Creation. Process Creation fork() Processes. CPU scheduling. Pål Halvorsen 21/9-2005

Processes. Dr. Yingwu Zhu

518 Lecture Notes Week 3

Process Management 1

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Princeton University. Computer Science 217: Introduction to Programming Systems. Process Management

SOFTWARE ARCHITECTURE 3. SHELL

CSci 4061 Introduction to Operating Systems. Processes in C/Unix

Parents and Children

CS240: Programming in C

Processes. Process Concept

Princeton University Computer Science 217: Introduction to Programming Systems. Process Management

Chapter 3: Processes. Operating System Concepts 8th Edition,

Operating System Structure

System Programming. Process Control III

Windows architecture. user. mode. Env. subsystems. Executive. Device drivers Kernel. kernel. mode HAL. Hardware. Process B. Process C.

Roadmap. Tevfik Ko!ar. CSC Operating Systems Spring Lecture - III Processes. Louisiana State University. Virtual Machines Processes

Computer Systems II. First Two Major Computer System Evolution Steps

OS Lab Tutorial 1. Spawning processes Shared memory

fork System-Level Function

Processes. OS Structure. OS Structure. Modes of Execution. Typical Functions of an OS Kernel. Non-Kernel OS. COMP755 Advanced Operating Systems

Processes COMPSCI 386

Mon Sep 17, 2007 Lecture 3: Process Management

Lesson 2. process id = 1000 text data i = 5 pid = 1200

Process. Prepared by Prof. Hui Jiang Dept. of EECS, York Univ. 1. Process in Memory (I) PROCESS. Process. How OS manages CPU usage? No.

Unix-Linux 2. Unix is supposed to leave room in the process table for a superuser process that could be used to kill errant processes.

Operating System Labs. Yuanbin Wu

Operating systems and concurrency - B03

INF1060: Introduction to Operating Systems and Data Communication. Pål Halvorsen. Wednesday, September 29, 2010

Getting to know you. Anatomy of a Process. Processes. Of Programs and Processes

Processes. Today. Next Time. ! Process concept! Process model! Implementing processes! Multiprocessing once again. ! Scheduling processes

Process Management! Goals of this Lecture!

Processes. CS3026 Operating Systems Lecture 05

CHAPTER 2: PROCESS MANAGEMENT

Prepared by Prof. Hui Jiang Process. Prof. Hui Jiang Dept of Electrical Engineering and Computer Science, York University

PROCESS CONTROL BLOCK TWO-STATE MODEL (CONT D)

Chapter 3: Process-Concept. Operating System Concepts 8 th Edition,

TCSS 422: OPERATING SYSTEMS

What Is A Process? Process States. Process Concept. Process Control Block (PCB) Process State Transition Diagram 9/6/2013. Process Fundamentals

COE518 Lecture Notes Week 2 (Sept. 12, 2011)

CS 475. Process = Address space + one thread of control Concurrent program = multiple threads of control

CS24: INTRODUCTION TO COMPUTING SYSTEMS. Spring 2018 Lecture 20

CS 326: Operating Systems. Process Execution. Lecture 5

Process Creation in UNIX

Chapter 3: Process Concept

Chapter 3: Process Concept

CS 322 Operating Systems Practice Midterm Questions

CS 471 Operating Systems. Yue Cheng. George Mason University Fall 2017

Lecture 5. Systems Programming: Unix Processes Creation: fork & exec Process Communication: Pipes

Chap 4, 5: Process. Dongkun Shin, SKKU

Introduction to OS Processes in Unix, Linux, and Windows MOS 2.1 Mahmoud El-Gayyar

Processes and More. CSCI 315 Operating Systems Design Department of Computer Science

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

Week 2 Intro to the Shell with Fork, Exec, Wait. Sarah Diesburg Operating Systems CS 3430

Chapter 3: Process Concept

The Shell, System Calls, Processes, and Basic Inter-Process Communication

Process management 1

CSCE 313 Introduction to Computer Systems. Instructor: Dezhen Song

CSC Operating Systems Spring Lecture - XII Midterm Review. Tevfik Ko!ar. Louisiana State University. March 4 th, 2008.

Processes. Jin-Soo Kim Computer Systems Laboratory Sungkyunkwan University

CSCE 313: Intro to Computer Systems

Processes. CS439: Principles of Computer Systems January 30, 2019

Processes. Processes (cont d)

Lecture 2 Process Management

The Kernel Abstraction. Chapter 2 OSPP Part I

UNIX System Calls. Sys Calls versus Library Func

Operating Systems. Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000) alphapeeler.sf.net/pubkeys/pkey.htm

Notice: This set of slides is based on the notes by Professor Perrone of Bucknell and the textbook authors Silberschatz, Galvin, and Gagne

Processes. Electrical and Computer Engineering Stephen Kim ECE/IUPUI RTOS & Apps 1

CSC209 Fall Karen Reid 1

Processes. q Process concept q Process model and implementation q Multiprocessing once again q Next Time: Scheduling

Altering the Control Flow

SE350: Operating Systems

REVIEW OF COMMONLY USED DATA STRUCTURES IN OS

csci3411: Operating Systems

CS 33. Architecture and the OS. CS33 Intro to Computer Systems XIX 1 Copyright 2018 Thomas W. Doeppner. All rights reserved.

Processes. CS 475, Spring 2018 Concurrent & Distributed Systems

CS 370 Operating Systems

Chapter 3 Processes we will completely ignore threads today

OS lpr. www. nfsd gcc emacs ls 9/18/11. Process Management. CS 537 Lecture 4: Processes. The Process. Why Processes? Simplicity + Speed

Chapter 3: Processes. Chapter 3: Processes. Process in Memory. Process Concept. Process State. Diagram of Process State

CSCE Operating Systems Interrupts, Exceptions, and Signals. Qiang Zeng, Ph.D. Fall 2018

CSC 539: Operating Systems Structure and Design. Spring 2006

Killing Zombies, Working, Sleeping, and Spawning Children

CS 31: Intro to Systems Processes. Kevin Webb Swarthmore College March 31, 2016

OS lpr. www. nfsd gcc emacs ls 1/27/09. Process Management. CS 537 Lecture 3: Processes. Example OS in operation. Why Processes? Simplicity + Speed

Processes. CSE 2431: Introduction to Operating Systems Reading: Chap. 3, [OSC]

CS 550 Operating Systems Spring Process III

Processes: Introduction. CS 241 February 13, 2012

CS510 Operating System Foundations. Jonathan Walpole

Creating Threads COMP755

Processes. Process Management Chapter 3. When does a process gets created? When does a process gets terminated?

Ricardo Rocha. Department of Computer Science Faculty of Sciences University of Porto

Transcription:

es CS 217 Operating System Supports virtual machines Promises each process the illusion of having whole machine to itself Provides services: Protection Scheduling Memory management File systems Synchronization etc. OS Kernel Hardware 1

What is a? A process is a running program with its own or state» PC, PSR, registers Address space (memory)» Text, bss, data, heap, stack OS Kernel Hardware Operating System Resource allocation Sharing Protection Fairness Higher-level abstractions OS Kernel Hardware Common strategies Chop up resources into small pieces and allocate small pieces at fine-grain level Introduce level of indirection and provide mapping from virtual resources to physical ones Use past history to predict future behavior 2

Example: Scheduling We have a single physical CPU and a whole lot of processes/jobs to run Which process do we run next? For how long do we run it? Solution 1: Run each of them to completion in first-come first-served order CPU-bound processes 1 2 4 5 Time 10 29 7 12 Average wait time of processes: (0+ 10+ 9+ 42+ 49)/ 5 = 28 Example: Scheduling We have a single physical CPU and a whole lot of processes/jobs to run Which process do we run next? For how long do we run it? CPU-bound processes Another solution: Run them to completion in shortest-first order 1 2 4 5 Time 10 29 7 12 Average wait time of processes: (0+ + 10+ 20+ 2)/ 5 = 1

CPU-I/O Burst Cycle Typical execution of process: load add store read from file wait for I/O store increment index write to file wait for I/O load add store read from file... wait for I/O CPU Burst Wait for I/O CPU Burst Wait for I/O Most processes are not CPU-bound CPU-I/O Burst Cycle Schedule CPU burst for process B while process A is waiting for I/O Better utilize CPU A: B: CPU I/O CPU I/O CPU I/O CPU I/O CPU I/O CPU I/O 4

Time Slicing Divide up time into quantums Schedule quantums, not complete jobs Schedule another process if perform I/O Preempt process at end of quantum Motivations CPU-I/O Burst Cycle Interactive response 1 2 4 5 Time 10 29 7 12 Time Slicing 1 2 4 5 1 2 4 5 1 2 4 5 1 2 4 5 1 2 5 2 5 2 2 2 2 2 2 2 15 2 6 44 61 Life Cycle of a Running: instructions are being executed Waiting: waiting for some event (e.g., i/o finish) Ready: ready to be assigned to a processor New Ready Running Halted Waiting 5

Context Switch Control Block For each process, the kernel keeps track of... state (new, ready, waiting, halted) CPU registers (PC, PSR, global, local,...) CPU scheduling information (priority, queues,...) Memory management information (page tables,...) Accounting information (time limits, group ID,...) I/O status information (open files, I/O requests,...) 6

Fork Create a new process (system call) child process inherits state from parent process parent and child have separate copies of that state parent and child share access to any open files pid = fork(); if (pid!= 0) { /* in parent */... } /* in child */... Fork Inheritted: user and group IDs environment close-on-exec flag signal handling settings supplementary group IDs set-user-id mode bit set-group-id mode bit profiling on/off/mode status debugger tracing status nice value stdin scheduler class all shared memory segments all mapped files file pointers non-degrading priority process group ID session ID current working directory root directory file mode creation mask resource limits controlling terminal all machine register states control register(s) Separate in child process ID address space (memory) file descriptors active process group ID. parent process ID process locks, file locks, page locks, text locks and data locks pending signals timer signal reset times share mask 7

Exec Overlay current process image with a specified image file (system call) affects process memory and registers has no affect on file table Example: execlp( ls, ls, -l, NULL); fprintf(stderr, exec failed\n ); exit(1); Exec (cont) Many variations of exec int execlp(const char *file, const char *arg,...) int execl(const char *path, const char *arg,...) int execv(const char *path, char * const argv[]) int execle(const char *path, const char *arg,..., char * const envp[]) Also execve and execvp 8

Fork/Exec Commonly used together by the shell... parse command line... pid = fork()) if (pid == -1) fprintf(stderr, fork failed\n ); else if (pid == 0) { /* in child */ execvp(file, argv); fprintf(stderr, exec failed\n ); } else { /* in parent */ pid = wait(&status); }... return to top of loop... Wait Parent waits for a child (system call) blocks until status of a child changes returns pid of the child process returns 1 if no children exist (already exited) pid_t wait(int *status); 9

System Convenient way to invoke fork/exec/wait Forks new process Execs command Waits until it is complete int system(const char *cmd); Example: int main() { system( echo Hello world ); } Summary Operating systems manage resources Divide up resources (e.g., quantum time slides) Allocate them (e.g., process scheduling) A processes is a running program with its own or state Address space (memory) Create and manage processes with... fork exec wait system }Used in shell 10