CE01000-3 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.

Slides:



Advertisements
Similar presentations
Abhinav Kamra Computer Science, Columbia University 4.1 Operating System Concepts Silberschatz, Galvin and Gagne  2002 Chapter 4: Processes Process Concept.
Advertisements

Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Chapter 3: Processes.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
CMPT 300: Operating Systems I Ch 3: Processes Dr. Mohamed Hefeeda
Process Concept n An operating system executes a variety of programs: –Batch system – jobs –Time-shared systems – user programs or tasks n Textbook uses.
Chapter 3: Processes. Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
Operating System Concepts
Operating Systems (CSCI2413) Lecture 3 Processes phones off (please)
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Silberschatz and Galvin  Operating System Concepts Module 4: Processes Process Concept Process Scheduling Operation on Processes Cooperating.
Silberschatz, Galvin and Gagne  Applied Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operation on Processes.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication in Client-Server Systems.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Operating Systems Part III: Process Management (Process States and Transitions)
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Processes: program + execution state
Chapter 3 Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
1 CS.217 Operating System By Ajarn..Sutapart Sappajak,METC,MSIT Chapter 4 Process Slide 1 Chapter 4 Process.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication.
8-Sep Operating Systems Yasir Kiani. 8-Sep Agenda for Today Review of previous lecture Process scheduling concepts Process creation and termination.
Chapter 2 Processes Processes Topics Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Processes – Part I Processes – Part I. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Review on OSs Upon brief introduction of OSs,
11/13/20151 Processes ICS 240: Operating Systems –William Albritton Information and Computer Sciences Department at Leeward Community College –Original.
CS212: OPERATING SYSTEM Lecture 2: Process 1. Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Processes.
Copyright © 2006 by The McGraw-Hill Companies, Inc. All rights reserved. McGraw-Hill Technology Education Lecture 3 Operating Systems.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition, Chapter 3: Process-Concept.
Operating Systems (CS 340 D) Dr. Abeer Mahmoud Princess Nora University Faculty of Computer & Information Systems Computer science Department.
Processes. Process Concept Process Scheduling Operations on Processes Interprocess Communication Communication in Client-Server Systems.
Lecture 4: Processes & Threads. Lecture 4 / Page 2AE4B33OSS Silberschatz, Galvin and Gagne ©2005 Contents The concept of Process Process states and life-cycle.
 Process Concept  Process Scheduling  Operations on Processes  Cooperating Processes  Interprocess Communication  Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
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.
Silberschatz, Galvin and Gagne  2002 Modified for CSCI 399, Royden, Operating System Concepts Operating Systems Lecture 8 Processes II Read Ch.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Operating System Components) These components reflect the services made available by the O.S. Process Management Memory Management I/O Device Management.
Lecture 3 Process.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
Operating System Concepts
Operating Systems (CS 340 D)
Process Management Presented By Aditya Gupta Assistant Professor
Chapter 3: Process Concept
Chapter 3: Processes.
Operating Systems (CS 340 D)
Chapter 3: Processes.
Process Virtualization. Process Process is a program that has initiated its execution. A program is a passive entity; whereas a process is an active entity.
CGS 3763 Operating Systems Concepts Spring 2013
Chapter 4: Processes Process Concept Process Scheduling
Lecture 2: Processes Part 1
Recap OS manages and arbitrates resources
Operating Systems Lecture 6.
Process & its States Lecture 5.
Chapter 3: Processes.
Operating System Concepts
Chapter 3: Processes.
Chapter 3: Processes Process Concept Process Scheduling
Chapter 3: Process Concept
Presentation transcript:

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 state Resource queues Process scheduling Context switching Process creation and termination Co-operating processes

Concept of a process OS shares resources between user programs (see last week). Before user program can make any requests or do anything on the system it must exist in a way that allows the CPU to execute it and the OS to interact with it. User program is simply a file of text that specifies what actions the computer should perform.

Concept of a process (Cont.) In order to run, a representation of the user program must be created by the OS - known as a process. It is the process that runs on the computer. Process is a program in execution. Processes are basic units that resources are shared between.

Concept of a process (Cont.) Think of a user program as a design/specification for a machine, process is the actual machine working after it has been built.

Process structure A process includes: program section - contains a copy of the machine code instructions user data section - to hold variable data values

Process structure (Cont.) system data section - area to hold process context info when process interrupted - program counter, processor registers, etc and system information about resources allocated to process, etc. user and system data sections obviously may be different from one run of a process to another

Process state

Process State (Cont.) As a process executes, it changes state. new: The process is created by OS ready: The process is waiting to be assigned to a processor. running: Instructions are being executed on processor waiting: The process is waiting for some event to occur terminated: The process has finished execution.

Process Control Block (PCB) PCB - data structure that contains Information associated with each process: Process state and process id. number Copies of CPU registers when program not executing e.g. program counter, data, index, and other registers CPU scheduling information - e.g. priority level

Process Control Block (Cont.) Memory-management information - e.g. base/limit register values Accounting information - CPU time used, etc I/O status information - which I/O resources allocated

Process Control Block (Cont.)

Process Scheduling Queues Process migration between the various queues:

Process Scheduling Queues (Cont.) Job queue – set of all processes wanting to be allowed to compete for use of CPU Ready queue – set of all processes that are in main memory, ready and waiting to execute - a linked list Device queues – set of processes waiting to use an I/O device

Representation of process scheduling

Ready queue and device queues

Execution Schedulers

Execution Schedulers (Cont.) Long-term scheduler (or job scheduler) – selects which processes should be brought into the ready queue - LT scheduler generally only in batch system Short-term scheduler (or CPU scheduler) – selects which process should be executed next and allocates CPU to it.

Execution Schedulers (Cont.) Short-term scheduler is invoked very frequently (milliseconds) -> (must be fast). Long-term scheduler is invoked very infrequently (seconds, minutes) -> (may be slow). The long-term scheduler controls the degree of multiprogramming – this is the number of processes in the system that can be scheduled onto the CPU i.e. number of processes competing for CPU as a resource.

Execution Schedulers (Cont.) Long-term scheduler wants to balance use of CPU between I/O-bound and CPU-bound processes I/O-bound process – have small amount of computation before it needs to do some I/O; many I/O requests -Typical interactive user programs. CPU-bound process – large amount of computation before it needs to do some I/O; few I/O requests - Programs that require sustained periods of calculation e.g. modelling applications

Medium term scheduler

Medium term scheduler (Cont.) If number of processes competing for resources become too many and begin to slow system response times down, then can temporarily swap some processes out to disk and bring them back later. It is intermediate between long and short term. may exist in time sharing systems to provide temporary relief from overloading

CPU switched between processes

Context Switch When CPU switches to another process, the system must save the state of the old process and load the saved state for the new process. Context-switch time is overhead; the system does no useful work while switching. Time taken dependent on hardware support.

Process Creation When a process is created it is created by another process known as the parent process - new process created is the child process of the parent. New process may in turn create other processes, forming a family tree of processes. There must be a first process (init process) - this is process that is created at bootup of the OS and is part of OS.

Process Creation (Cont.) Resource sharing between parent and child processes - options include: Parent and children share all resources, or Children share subset of parent’s resources, or Parent and child share no resources. Execution options: Parent and children execute concurrently, or Parent waits until children terminate.

Process Creation (Cont.) UNIX example fork system call creates new process which is a copy of the parent - but when child process runs it can distinguish itself from parent and normally proceeds to make exec call exec family of system calls used after a fork to replace the process’ memory space with the program the parent wanted to be executed

Process Termination Process executes last statement and asks the operating system to delete it (exit system call). Then Return data from child to parent (via wait). Process’ resources are deallocated by operating system.

Process Termination (Cont.) Parent may terminate execution of children processes (abort). Reasons for this could be: Child has exceeded allocated resources. Task assigned to child is no longer required. Parent is exiting and O/S does not allow children to continue if their parent terminates.

Cooperating Processes Process is independent if it cannot legally affect or be affected by the execution of another process. Process is cooperating if it can legally affect or be affected by the execution of another process.

Cooperating Processes (Cont.) Advantages of process cooperation: Information sharing Computation speed-up - but only if >1 processor Modularity - dividing system functions into separate processes that then talk to each other way in which user process can interact with OS processes to do I/O, etc.

Producer-Consumer Problem Classic example for cooperating processes; producer process produces information that is consumed by a consumer process e.g. program outputting to printer spooler producer places data in buffer, consumer takes data from buffer

Producer-Consumer Problem (Cont.) unbounded-buffer places no practical limit on the size of the buffer - consumer waits when buffer empty bounded-buffer assumes that there is a fixed buffer size - producer waits when buffer full and consumer when empty

Bounded-Buffer – Shared- Memory solution. Data structures: buffer for shared data - an array organised as a circular buffer in-index - where producer to put data out-index - where consumer to get data

Bounded-Buffer – Shared- Memory solution (Cont.) Producer Process repeat …. produce data item …. /* buffer full when in-index is 1 less than out-index */ while buffer full do no-op; buffer[in-index] = data item in-index = (in-index+1) modulo size-of-buffer until false

Bounded-Buffer – Shared- Memory solution (Cont.) Consumer process repeat /* buffer empty when in-index == out-index */ while buffer empty do no-op; get next data item from buffer[out-index] out-index = out-index+1 modulo size-of-buffer …. consume data item …. until false

References Operating System Concepts. Chapter 3.