We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Modified over 6 years ago
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
© De Montfort University, 2004CSCI2413 - L32 Lecture Outline Concept of a “Process” Process Creation/Termination Process states Process Control Block (PCB) An overview of process scheduling –concepts –problems
© De Montfort University, 2004CSCI2413 - L33 Concept of a “Process” Recall –a process is an instance of a program that is being executed a program which is loaded into memory and is running A process must execute in sequential fashion –even though it may be interrupted by the operating system so that other processes may run
© De Montfort University, 2004CSCI2413 - L34 Process Creation Parent process creates child processes which, in turn, can create others to form a process ‘tree’ Options for process creation –resource sharing options parent and children share all resources children share subset of parent’s resources parent and child share no resources –execution options parent and children execute concurrently parent waits until children terminate
© De Montfort University, 2004CSCI2413 - L35 Process Termination Normal termination occurs if the process reaches its final instruction, execute exit A parent process may terminate execution of its child process (abort) –this may be because the child has exceeded a resource limit the user requests a child to terminate (because it’s stuck) the parent process is itself being terminated
© De Montfort University, 2004CSCI2413 - L36 Process States As a process executes, it changes state new the process is being created running instructions are being executed ready the process is ready to run, but is waiting for the processor to become available blocked (waiting) the process is waiting for some event to occur terminated the process has finished execution
© De Montfort University, 2004CSCI2413 - L37 Process State Diagram ready running scheduler dispatch interrupt blocked I/O or event block I/O or event completion new admitted terminated exit
© De Montfort University, 2004CSCI2413 - L38 Process Information OS must hold info. about a process so that it can change its state Typical information held –process management process state, program counter, processor registers, time process started, process id, parent id –memory management code location and size, data location and size, stack –I/O management files open and modes, I/O devices in use, current directory
© De Montfort University, 2004CSCI2413 - L39 Process Control Block (PCB) OS holds info. for each process in PCB (also referred to as, process table) –one entry per process When a process starts, OS allocates an entry in its PCB –the process runs until it is interrupted OS updates the process info. –or makes a system call (e.g. to open a file) OS performs the system call and updates the process info.
© De Montfort University, 2004CSCI2413 - L310 Process Control Block Process Number (ID) Process state Priority Program Counter Memory Pointers I/o states information Registers Accounting Information. To distinguish it from other processes Executing, running etc. Priority level Hold address of next instr. Hold base address of code or data I/O states and requests Time limits, account numbers
© De Montfort University, 2004CSCI2413 - L311 Context Switch When processor switches to another process, OS saves the state of the old process and load the saved state for the new process This is called a context switch –the time spent doing this is overhead (idle) –the system does no useful work while switching This time depends on both the OS and the hardware support
© De Montfort University, 2004CSCI2413 - L312 CPU Switch From Process to Process
© De Montfort University, 2004CSCI2413 - L313 Scheduling Concepts Suppose there are two jobs in the process table, both of which are in the ready state –which one should the operating system return to the ‘running’ state? –suppose one job requested a disk I/O operation and one process was doing a lengthy calculation using a lot of processor time, and was interrupted does that alter the choice? The operating system has to make a choice –there are different factors that affect the choice –there are different algorithms to make the selection
© De Montfort University, 2004CSCI2413 - L314 Scheduling Types There are different classes of scheduler types –long term selects which processes should be brought into the queue –short term selects which process should be executed by the processor –medium term selects which process is temporarily suspended and swapped out of main memory to reduce the number of processes occupying memory –not used in all operating systems
© De Montfort University, 2004CSCI2413 - L315 Scheduling Queues I/O waiting queue I/O ready queue CPU the short term scheduler decides which process to allocate to the CPU the long term scheduler decides which processes can join the ready queue partially executed swapped-out processes a medium term scheduler decides which processes to swap out of main queue
© De Montfort University, 2004CSCI2413 - L316 Potential Problems Imagine an operating system has a print spooler –when a process wants to print a file it enters the file name in a special spool directory –another process (the spooler demon) periodically checks to see if there are any files to be printed –the operating system maintains two variables out: holds the number of the next file to be printed in: holds the number of the next free slot Now imagine two processes trying to print a file at the same time –each needs to submit the file name to the spool queue This create a ‘RACE’ condition (more about this later)
© De Montfort University, 2004CSCI2413 - L317 Summary The process model – Process Creation/Termination –process states Process implementation –process control block An overview of process scheduling –concepts –Problems (Race condition, more in later lectures)
Chapter 3 Process Description and Control
A. Frank - P. Weisberg Operating Systems Process Scheduling and Switching.
Introduction to Processes
Processes CSCI 444/544 Operating Systems Fall 2008.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1/27/2010CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying an earlier version.
Review: Operating System Manages all system resources ALU Memory I/O Files Objectives: Security Efficiency Convenience.
1/23/2008CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
CSSE Operating Systems
Process Concept An operating system executes a variety of programs
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
Process Description and Control A process is sometimes called a task, it is a program in execution.
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 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.
Chapter 41 Processes Chapter 4. 2 Processes Multiprogramming operating systems are built around the concept of process (also called task). A process.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
ITEC 502 컴퓨터 시스템 및 실습 Chapter 2-1: Process Mi-Jung Choi DPNM Lab. Dept. of CSE, POSTECH.
© 2021 SlidePlayer.com Inc. All rights reserved.