Chapter 3 – Processes (Pgs 101 – 141). Processes  Pretty much identical to a “job”  A task that a computer is performing  Consists of: 1. Text Section.

Slides:



Advertisements
Similar presentations
Adapted from slides ©2005 Silberschatz, Galvin, and Gagne Lecture 4: Processes.
Advertisements

Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Objectives Understand Process concept Process scheduling Creating.
Chapter 3: Processes.
Processes CSCI 444/544 Operating Systems Fall 2008.
Operating System Concepts with Java – 7 th Edition, Nov 15, 2006 Silberschatz, Galvin and Gagne ©2007 Chapter 3: Processes.
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.
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.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
1 Process Description and Control Chapter 3 = Why process? = What is a process? = How to represent processes? = How to control processes?
1/26/2007CSCI 315 Operating Systems Design1 Processes Notice: The slides for this lecture have been largely based on those accompanying the textbook Operating.
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.
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  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.
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.
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Chapter 3 Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Jan 19, 2005 Chapter 3: Processes Process Concept.
AE4B33OSS Chapter 3: Processes. 3.2Silberschatz, Galvin and Gagne ©2005AE4B33OSS Chapter 3: Processes Process Concept Process Scheduling Operations on.
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.
Chapter 3: Processes (6 th edition chap 4). 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter 3: Processes. 3.2CSCI 380 Chapter 3: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication.
1 11/1/2015 Chapter 4: Processes l Process Concept l Process Scheduling l Operations on Processes l Cooperating Processes l Interprocess Communication.
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.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Process Concept Process Scheduling Operations.
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.
Chapter 3: Process-Concept. Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating.
3.1 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes Overview: Process Concept Process Scheduling Operations on Processes.
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  process  process creation/termination  context  process control block (PCB)  context switch  5-state process model  process scheduling short/medium/long.
Chapter 3: Processes-Concept. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 3: Processes-Concept Overview Process Scheduling.
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.
 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 Chapter 3: Processes Process Concept Process Scheduling Operations.
Chapter 3: Process-Concept. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Chapter 3: Process-Concept Process Concept Process Scheduling.
4.1 Operating System Chapter 4: Processes Process Concept Process Scheduling Operations on Processes Cooperating Processes Interprocess Communication Communication.
Chapter 3: Processes. 3.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts - 7 th Edition, Feb 7, 2006 Chapter 3: Processes Process Concept.
1 Module 3: Processes Reading: Chapter Next Module: –Inter-process Communication –Process Scheduling –Reading: Chapter 4.5, 6.1 – 6.3.
Lecture 3 Process.
Chapter 3: Process Concept
Topic 3 (Textbook - Chapter 3) Processes
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.
Chapter 3: Processes.
Chapter 4: Processes Process Concept Process Scheduling
Lecture 2: Processes Part 1
Process & its States Lecture 5.
Chapter 3: Processes.
Chapter 3: Processes.
Chapter 3: Process Concept
Processes August 10, 2019 OS:Processes.
Presentation transcript:

Chapter 3 – Processes (Pgs 101 – 141)

Processes  Pretty much identical to a “job”  A task that a computer is performing  Consists of: 1. Text Section – Program Code 2. Data Section – Heap, Stack, & Free Space 3. Current State – CPU Register Values  Program: Passive entity on disk  Process: Active entity in memory  Thread:A part of a process (Ch. 4)

Process Layout (x86) c.f., Text Fig 3.1

Process States  New: Being created  Running: Has a CPU, being executed  Suspended: Not running (covers both ready and waiting)  Ready: Could be running if assigned to a CPU  Waiting: Needs something (e.g., I/O, signal)  Terminated: Done

Fig. 3.2 Process State

Process Control Block (PCB)  O/S (Kernel) Data Structure for a process  State - ready, etc.  Registers – current values, includes PC  Scheduling Info – priority, queue address  Memory Info – pages tables, base address  Accounting Info – owner, parent, CPU use, pid  I/O Status Info – open files, devices assigned

The Unix ps command -l F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S rt_sig pts/18 00:00:00 zsh 0 R pts/18 00:00:00 ps  F = Flags, S = State, UID = User, PID = Process  PPID = Parent, C = CPU % use, PRI = Priority  NI = Nice, ADDR = Swap Addr, SZ = Num pages  WCHAN = Kernel function where sleeping  TTY = Controlling Terminal Device  TIME = CPU Time, CMD = File Name  Lots of other data is available using options!

Scheduling Queues  Happy little places for processes to wait (just like the lines at Starbucks)  Job Queue: All processes in the system  Ready Queue: All processes ready to run  Device Queue(s): Processes waiting for a particular device (each has own queue)  Often just a linked list of PCBs

Queueing Diagram (Fig 3.7)

Scheduler  O/S component that selects a process from a queue  Long term (job): select process to be loaded into memory (make ready)  Short term (cpu): select ready process to run  I/O: select process from the I/O queue for that device  Context Switch: Changing the executing process on a CPU; requires saving state of outgoing process, restoring state (if any) of incoming process

Process Mix  Computers work best when a variety of processes with different needs exist  CPU-bound process: most of its life is computations, very little I/O  I/O-bound process: most of its life is spent doing I/O, minimal computation  Long term scheduling works best if a mix of these is in memory

Medium Term Scheduler  Monitors memory and removes some processes which it writes to disk (“swap out”)  Later moves the process back to memory so it can be executed (“swap in”)  Will cover this more in Ch. 8  Used to free memory of a process that cannot execute (blocked because it needs resources).

Process Creation  All processes have a parent  Thus there is a process tree  Every process has a PID  Two step process in Unix 1. Create a new (duplicate) process : fork() 2. Overlay duplicate with new program: exec()

Fork() and Exec() (Fig 3.10) pid_t pid = fork(); // Duplicate myself if (pid < 0) error(); // No child, parent OK if (pid == 0) { // Child, don’t know own pid execlp(“/bin/ls”,”ls”,NULL); } else { // Parent w. opt. wait for child completion wait(NULL); printf(“Child complete.\n”); }

fork() : Making a COPY  The copy is identical. Has same code, same heap, same stack, same variables with same values  Only difference is that child has different PID and PPID

Forking  After fork(), either child or parent, or both, could be executing – no guarantees here!  wait() causes parent to wait for child to terminate  exec family of syscalls overlays child process  Additional coding must be performed to allow parent and child to communicate (IPC)

Termination  Processes terminate with the exit() syscall  GCC inserts it for you after the last executable instruction (or a jmp to it if many exit points)  Some O/S terminate all children of a terminating process, “cascading termination”  Parents can terminate their children  Arbitrary processes cannot terminate each other  O/S can terminate a process for a variety of reasons (e.g., security, on errors)  Exit value of a terminated process is stored for a while (e.g., until reboot or PID reused)

Summary (Unix)  New processes made by an existing process using FORK  New process is a copy of the old  Both parent and child are running after the FORK  New process must get new program and data using EXEC  Parent can WAIT for child or continue  Processes terminate using EXIT

Interprocess Communication  Efficiency: Save having 2 copies of something by letting it be shared  Performance: Sharing results of parallel computations  Co-ordination: Synchronising the transfer of results, access to resources etc.  Two primary reasons: 1. Coordination/Synchronisation 2. Data transfer

IPC Models (SGG) 1. Shared Memory – common memory location for both processes to read and write 2. Message Passing – kernel acts as a go- between to receive and send messages (shared memory is managed by the kernel instead)  But, really, its always just some kind of shared memory and there are more than two models

IPC Models  Shared memory  Message passing  Mailboxes & Ports  Remote Procedure Calls  Pipes  Interrupts (users to O/S)  Signals (limited information content)

Producer-Consumer Problem  Producer creates something  Consumer uses that product  Consumer must wait for it to be produced and fully put into memory  Producer must wait for consumer to create space where the product can be put if the space fills up  Requires careful communication and synchronisation

Shared Memory  O/S normally prevents one process from accessing the memory of another  Requires setup to be effective  Processes must somehow co-operate to share the memory effectively or else they can over-write each other’s data  Simultaneous writes cause a big mess!

Unix Shared Memory  A “key” is used to name the shared segment. Any process with the key can access it.  The segment is located using shmget()  The segment is attached using shmat()  Generally “fast” for doing communication  Uses standard Unix permission system  Highly useful techniques are possible  Read/Write coordination is needed

Message Passing  Uses the O/S to receive, buffer, and send a message  Uses the send() and receive() syscalls  What if a process tries to receive when nothing has been (or will be) sent?  Like shared memory, message passing requires careful coding and co-ordination by the two+ processes

Direct Communication  Uses process names (PIDs)  Requires knowing the PID of everyone we communicate with  If a process terminates, must find its PID and delete it  Main drawback is maintaining the list of active PIDs we communicate with  Send goes to only one process so multiple sends may be needed  Works great in many situations though

Indirect Communication  Uses mailboxes or ports  Mailbox is an O/S maintained location where a message can be dropped off or picked up  All mailboxes have a name  Multiple processes can read from the mailbox  Mailbox can be owned by O/S or a process  Still have the problem of communicating the mailbox name/location, but at least now the O/S knows this information as well

Synchronicity (Not the Police Album)  Message passing can be either: 1. Blocking / Synchronous 2. Non-Blocking / Asynchronous  Synchronous send() waits for receipt before returning  Synchronous receive() waits for the send to complete before returning  Asynchronous operations return even if no receipt occurs or if data is not available  When both are synchronous, we have a “rendezvous”

Buffering 1. Zero Capacity: There is no buffer and data is discarded if the communication is not synchronous 2. Bounded Capacity: The buffer is fixed size and sender blocks when the buffer fills 3. “Infinite” Capacity: O/S allocates more space to buffer as required

Remote Procedure Call (RPC)  A protocol designed so that a process on one machine can have computation performed by calling a procedure (function) that is executed by a different process on another machine  Issues with endianism, data encoding  Must define a common data representation  Issues with synchronisation of processes and returning of results

Sockets  Associated with Internet-based IPC  A socket is an IP address (a machine) and a specific port on that machine  We normally don’t see them because WWW services tend to have a default port, e.g., Port 80 for HTTP  Can use (loopback) to test things, e.g., client and server on same machine

Pipes  A connection (with buffer) for sending data  Data of any form can be sent  Best for one directional communication  Can be used two way if emptied between uses  Very common in Unix, considered as the most basic form of IPC  Named pipes (called FIFOs) are file system entities in Unix

To Do:  Complete this week’s lab  Finish reading Chapter 3 (pgs ; this lecture) if you haven’t already