Chapter 3 Process Management.

Slides:



Advertisements
Similar presentations
Ch4. Processes Process Concept (1) new waiting terminate readyrunning admitted interrupt exit scheduler dispatch I/O or event completion.
Advertisements

Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
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
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.
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
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Process Management. Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication.
Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Interprocess Communication Examples of IPC Systems Communication in Client-Server.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Process Concept Process – a program.
Computer Architecture and Operating Systems CS 3230: Operating System Section Lecture OS-1 Process Concepts Department of Computer Science and Software.
Chapter 3 Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
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.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Outline n Process Concept n Process.
Processes. Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
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,
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.
Processes CSCI 4534 Chapter 4. Introduction Early computer systems allowed one program to be executed at a time –The program had complete control of the.
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.
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.
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.
Processes and threads.
Chapter 3: Processes.
Process Management Process Concept Why only the global variables?
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 4: Processes Process Concept Process Scheduling
Processes Overview: Process Concept Process Scheduling
Chapter 3: Process Concept
Chapter 3: Processes.
Intro to Processes CSSE 332 Operating Systems
Operating Systems (CS 340 D)
Applied Operating System Concepts
Chapter 3: Processes.
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
CGS 3763 Operating Systems Concepts Spring 2013
Process & its States Lecture 5.
Chapter 3: Processes.
Operating System Concepts
Process Description and Control
“Processes” By: Maryam Raeisian- 2014
Chapter 3: Processes.
Chapter 3: Processes.
Outline Chapter 2 (cont) Chapter 3: Processes Virtual machines
Chapter 3: Process Concept
Processes August 10, 2019 OS:Processes.
Presentation transcript:

Chapter 3 Process Management

Process definition A process is a program in execution Process needs resources : CPU time memory to files accomplish I/O device its tasks These resources are allocated to process when it is created or during execution Process is the unit of work of system System consists of collection of processes

Process OS processes execute system code, user code Processes can be executed concurrently (parallel) or sequential Program can be single thread or Multithreading Thread is a sequence of instructions that can be managed independently Thread is the component of process Multithreading more than one thread in the same process share resources and memory

Multithreading process

Process concept What to call the CPU activities ? (CPU Cycle) All kind of CPU activities are called process Batch system time shared single user OS system Execute jobs execute task run several programs Is an operating system that work without the interaction of user Are process

Process Process is more than program code, it includes: Current activity represented by the value of program counter Content of processor registers Stack which contains temporary data (function, parameters, return address, local variable) in which is inserted data used during instruction execution Data section : which include global variables Heap that is memory dynamically allocated during process runtime

click program Loaded into memory Passive CPU In execution process Active But Not yet process PC In which instruction Data section heap Memory Content of registers Stack

are variables declared at the beginning of the program and Global variables : are variables declared at the beginning of the program and can be used in any part of the program Local variables : are variables declared inside part of the program and can be used only inside this part of the program When the user click two times on a program It creates two separate processes With two stacks and two heaps …..

Process state The state is part of the current activity of the process The process can have the following states: New : created Running instructions are being executed Waiting the process waits some event like I/O Ready the process is waiting to be assigned a processor Terminated the process finished execution In each instant only one process can be running on a processor

Diagram of Process State

Process control block PCB Each process in operating system is represented by PCB that contains information about the process . It contains the following information : process state : new , running, waiting, ready , terminating PC Program counter that indicates the address of next instruction to be executed (this information must be saved when an interrupt is happened) CPU registers : type , index of registers, stack , pointers

Process control block PCB continue CPU scheduling : information , priorities Memory management information : limit registers, page table segment, table depend on memory used by OS Accounting information : amount of CPU, real time used, tile limits, account number, job or process number I/O status information : list of I/O devices allocated to the process , list of open file….

Click New program 1 Running 3 passive CPU 3 registers 7 2 PC 6 I/O 4 Ready Scheduling Interrupt Segment Page 5 Memory

Threads A process is a program that perform single thread Ex: word cannot type and control errors at the same time New OS can support more than one thread at time

Process scheduling The objective of multiprogramming is to have some process running at all times to maximize the CPU utilization Time sharing is to switch the CPU among processes so, the user can interact with program while in execution needs process scheduling Selects the available process for program execution on the CPU

Process scheduling One process no need for scheduling More than one process ……..scheduling

Ready Queue And Various I/O Device Queues

Scheduling queue Process enter The system Memory system P P C C B B Ready queue Job queue Waiting or Ready processes Linked list

Scheduling queue Header contains pointer to the first and last PCB (Program Control Block) that contains information about process Each PCB contains a pointer to the next process to be executed in this queue ready waiting for I/O device queue each device has its own queue keyboard Mouse CPU

Scheduler OS must select which process enter each queue, this selection is done by scheduler Many processes enter the system ….. All are sent to the queue …. Spooling Scheduler choose ………. Long term scheduler ………..short term scheduler

Long term scheduler Choose one process from spooler and load it into memory Execute 1 process each 100 milliseconds + it takes 10 millisecond for deciding which process is assigned …… during this time the memory is idle ….that means time is wasted One minute between create each process , it select I/O bound process Is a process that spends more CPU bound process Time in I/O operation than more computation A CPU operation time

If all processes are CPU bound waiting queue will be empty I/O bound CPU bound Mixed If all processes I/O bound Ready queue Will be Empty If all processes are CPU bound waiting queue will be empty Unix and Windows has no long term scheduler

Swapping Swapping means move some process from short term memory to midterm memory All that is done by scheduling algorithms

Context switch When an interrupt is happened the state of the process is saved …….PCB Process ……………state saved To resume activity ……. State restore Context switch when the kernel switch between state saved to state restore It adds overhead on the system because the system does nothing useful

Operation on processes The processes in most systems can be executed in parallel can be created and deleted dynamically Process creation : a process is created using create process system call A process can create many other processes . The first is called Parent and the subsequent processes are called children forming a tree of processes a process is identified using unique process identifier Pid that is an integer number

Process creation Consider a process needs resources, when a process is created the resources are allocated to it by its parent. If no available resources it can obtain a subset of the parent’s resources. The parent can distribute resources between its children without overloading the system Resources allocated to a child process must be passed by away of the parent

Process creation (continue) When a process creates a sub process, there are two possibilities : Execution memory addresses Parent and the parent parent and the child Child are wait until its child use the uses new Executed child end execution same memory memory Concurrently space space

Process creation in Unix Creating new process is done by Fork () call system The new process consists on copying the address space of the original process The two processes continue execution after fork system call with one difference that the returned value of fork () function is 0 for child process and is not zero for parent process parent and child can communicate to each other and the parent can create more child and uses the wait () system call and manage memory address space The child process inherits privileges from its parent

Process Creation

C Program Forking Separate Process #include <sys/types.h> #include <studio.h> #include <unistd.h> int main() { pid_t pid; /* fork another process */ pid = fork(); if (pid < 0) { /* error occurred */ fprintf(stderr, "Fork Failed"); return 1; } else if (pid == 0) { /* child process */ execlp("/bin/ls", "ls", NULL); else { /* parent process */ /* parent will wait for the child */ wait (NULL); printf ("Child Complete"); return 0;

A Tree of Processes on Solaris

Windows creating process Creating process in windows is done using Win 32 API using create process () system call that means loading the program into memory and load mspaint.exe application for execution.

Process terminate Process terminate when it finishes executing its final statement and asks the OS to delete it by using exit () system call The parent process resume activity using wait () system call All resources (physical and virtual memory, open files, I/O buffer ) are de-allocated by OS A process is terminate when it ends execution or by other process (parent)

Process terminate A parent terminate child process if : Child process has exceeds the use of some resources The task assigned to child is no longer needed If the parent is exiting the OS does not permit to child to continue execution.

Inter-process communication Processes executing concurrently in OS can be either independent or cooperating processes A process is independent if cannot affect or be affected by the other processes executed in the system Any process that does not share data with other processes is independent Cooperating process may share data with other processes (child)

Why cooperating ? Information sharing Computation speedup, if we want a task to run faster, we divide it into subtasks and are executed in parallel . Speedup is allowed when more than one processor works together Modularity : dividing the system into modules or functions or threads Convenience : allows multi operations in parallel

Communication between processes Cooperating process must communicate to each other . Types of communication Inter-process remote call indirect Communication

Inter-process communication Memory shared message passing Part of memory is used communicating Between the two processes processes Both processes can read exchange data and And write to this region information by away of kernel

Shared Memory Allows maximum Speedup and Convenience For communication No need for kernel Intervention Is faster than Message passing

Message passing Useful for By away Exchanging small Of kernel Amount of data By away Of kernel Easy to Implement No conflict

How to share Establishing the region to be shared between the communicating processes from the memory address space assigned Creating one process ……address space Another process ….new address space Generally OS prevent that one process accesses the resources of another process…..the two processes must cooperate to remove the restrictions Both processes can read and write on the region without the OS control but not simultanously Part shared

Example of Cooperating processes Producer Consumer Consume information Produce information Unlimited buffer buffer Shared memory Limited Buffer size

Explanation of producer- consumer example Producer produces data stored in the buffer, the buffer is emptied by the consumer To allow this paradigm to work correctly, consumer and producer must be synchronized To To access shared data Consumer must Consume only The data produced by The producer The buffer is implemented using circular array with two pointers in and out In point to the next position in the buffer Out points to the first position in the buffer In==out mean buffer empty (in+1)%buffer size == out means buffer full

Message passing system Processes communicate and synchronized without sharing memory Distributed systems over network Chat send (message) receive (message)

Indirect communication Message passing communication Direct communication Indirect communication synchronization Synchronous asynchronous buffering Automatic Explicit buffer Each process want to send Message must explicit The name of the sender Send (P, message) By a way of third part server

Link property in direct communication Link automatically Established between Two processes (after knowing process identity Exist only One link Link associated between two processes Full duplex

Naming mechanism for direct communication Symmetric Only by message name Send( process name , message ) Receive (process name , message) (router) Asymmetric By ID Send (process name, message) Receive ( id, message) Is less desirable , it requires More work (switch)

Link property for indirect communication Link is established Between two processes if They share Some resources Example : mail box Between the communicating Processes May be Different links router Link may be used by More than one process

Example P1 send message to A “ send (A, message)”, A want to respond to P1, P2,P3 that share the same mailbox which will receive the message b? The answer is depend on the link property : Each link can only one process Be shared can execute receive who receive Between only operation at time operation Two processes must be selected (round robin)

Synchronization Communication between two processes is done by send or receive operations After send Block non block Block sending The process blocks Sending message send Until the previous Message arrive At destination After receive block non block The process block Receiving until Ending processing

Synchronization Send(block) ……… Receive (block) …… Sender : send message + block …….wait Receiver : receive message +block ……….end block rendezvous Resume activity

No waiting in the buffer Packet arrived will be sent Buffering Zero capacity No waiting in the buffer Packet arrived will be sent Sender :send + block Bounded capacity Length n When becoming full Blocking receive Unbounded capacity Never blocking Send or receive