CSC 501 Lecture 2: Processes. Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute.

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

Chapter 6 Limited Direct Execution
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.
Processes CSCI 444/544 Operating Systems Fall 2008.
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
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Unix & Windows Processes 1 CS502 Spring 2006 Unix/Windows Processes.
Process Concept An operating system executes a variety of programs
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.
CE Operating Systems Lecture 5 Processes. Overview of lecture In this lecture we will be looking at What is a process? Structure of a process Process.
Process in Unix, Linux, and Windows CS-3013 A-term Processes in Unix, Linux, and Windows CS-3013 Operating Systems (Slides include materials from.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
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.
Implementing Processes and Process Management Brian Bershad.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
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.
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.
CSC 360- Instructor: K. Wu Processes. CSC 360- Instructor: K. Wu Agenda 1.What is a process? 2.Process states 3. PCB 4.Context switching 5.Process scheduling.
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,
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,
Processes CS 6560: Operating Systems Design. 2 Von Neuman Model Both text (program) and data reside in memory Execution cycle Fetch instruction Decode.
1 Computer Systems II Introduction to Processes. 2 First Two Major Computer System Evolution Steps Led to the idea of multiprogramming (multiple concurrent.
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.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Virtualizing the CPU: Processes 1. How to provide the illusion of many CPUs? CPU virtualizing – The OS can promote the illusion that many virtual CPUs.
Lecture 3 Process.
Chapter 3: Processes.
Topic 3 (Textbook - Chapter 3) Processes
Mechanism: Limited Direct Execution
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes.
System Structure and Process Model
Chapter 3: Processes.
System Structure and Process Model
CGS 3763 Operating Systems Concepts Spring 2013
System Structure B. Ramamurthy.
CGS 3763 Operating Systems Concepts Spring 2013
System Structure and Process Model
Operating Systems Lecture 6.
Process & its States Lecture 5.
Chapter 3: Processes.
Processes Hank Levy 1.
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Lecture 6: Multiprogramming and Context Switching
Chapter 3: Processes.
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Processes in Unix and Windows
CS510 Operating System Foundations
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Processes Hank Levy 1.
Chapter 3: Process Concept
Presentation transcript:

CSC 501 Lecture 2: Processes

Von Neumann Model Both program and data reside in memory Execution stages in CPU: Fetch instruction Decode instruction Execute instruction Write back result

Process Process is a running program a program in execution an “instantiation” of a program We want to have multiple running programs However, we only have a few CPUs So, limit the number of programs you are running

Time to invent CPU virtualization OS virtualizes the CPU By time sharing it Mechanisms <- this lecture Policies <- next lecture

A Process A running program includes: Memory Registers I/O, opened files APIs: create, destroy, wait, control, status Code Static data Heap Stack

Process Creation Loading: code and static data Eagerly vs lazily Allocate memory for stack, heap Initialize file descriptors Jump to the main

Process states As a process executes, it changes state new: The process is being created running: Instructions are being executed blocked: The process is waiting for some event to occur ready: The process is waiting to be assigned to a processor terminated: The process has finished execution

Admitted Exit I/O: done Scheduled I/O: initiate Descheduled Process Lifecycle New Ready Running Terminated Blocked

Data Structures Process list Common elements in process structure Process state Program counter CPU registers CPU scheduling information Memory-management information Accounting information I/O status information

Example PCB in XINU

Process API On Unix: fork, exec, wait, … Why: they are essential in building a Unix shell

Process Creation UNIX examples fork system call creates new process exec system call used after a fork to replace new process’ memory space with a new program

Exmaple int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); exit(-1); } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); } else { /* parent process */ /* parent will wait for the child to complete */ wait (NULL); printf ("Child Complete"); exit(0); }

Process Termination Possible scenarios for process termination Exit (by itself) Abort (by parent) Kill (by sysadmin)

Process Termination Exit (by itself) Process executes last statement and asks operating system to delete Abort (by parent) Child has exceeded allocated resources Task assigned to child is no longer required If parent is exiting Some operating system do not allow child to continue if its parent terminates All children terminated - cascading termination Kill (by sysadmin) Administration purpose

Process Suspension Temporarily ‘‘stop’’ a process Prohibit from using the CPU Why? What should be done? Change its state in PCB Save its machine states for later resumption Process table entry retained Complete state saved

Limited Direct Execution Time sharing the CPU: Run one process for a little while, then run another one, and so forth Performance and control The “direct execution” part of the idea is simple: Just run the program directly on the CPU.

Protocol without limits Restricted Operations How to take over control

Restricted Operations The need to perform restricted operations Let processes do whatever they want Two modes: user mode and kernel mode How to perform restricted operations System calls, and they are procedure calls

How to execute system call Trap instruction The program executes trap, jump into kernel and raise privilege Kernel does the work Kernel calls return-from-trap, return into the calling user program and reducing the privilege level Save caller’s registers On x86, PC, flags, and a few others saved to a per-process kernel stack

Which code to run Let the calling process specify the address Set up a trap table at boot time The hardware remembers the locations of trap handlers

Switching Between Processes Since OS is not running, how can it do anything? A cooperative approach Used in early version of the Macintosh OS Wait for systems calls which include yield Wait if illegal actions which generate trap What if a process gets stuck in an infinite loop

A Non-Cooperative Approach: The OS Takes Control Timer interrupt Boot time: Set interrupt handler Start timer

Context Switch When CPU switches to another process System must Save the state of the old process (suspend) and Load the saved state for the new process (resume) Context-switch time is overhead System does no useful work while switching Time dependent on hardware support

Saving and Restoring Context Save state of currently executing process Copy all “live” registers to process control block Restore state of process to run next Copy values of live registers from process control block to registers How to get into and out of the context switching code?

Next Process scheduling CPU scheduling Multi-level feedback Lottery scheduling