More on Processes Chapter 3. Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments.

Slides:



Advertisements
Similar presentations
Process Description and Control
Advertisements

Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Process Description and Control
Exceptional Control Flow Processes Today. Control Flow Processors do only one thing: From startup to shutdown, a CPU simply reads and executes (interprets)
 2004 Deitel & Associates, Inc. All rights reserved. 1 Chapter 3 – Process Concepts Outline 3.1 Introduction 3.1.1Definition of Process 3.2Process States:
Day 11 Processes. Operating Systems Control Tables.
6/9/2015B.Ramamurthy1 Process Description and Control B.Ramamurthy.
Process Description and Control
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.
Process Description and Control Chapter 3. Major Requirements of an Operating System Interleave the execution of several processes to maximize processor.
Figure 2.8 Compiler phases Compiling. Figure 2.9 Object module Linking.
OS Fall ’ 02 Introduction Operating Systems Fall 2002.
Page 1 Processes and Threads Chapter 2. Page 2 Processes The Process Model Multiprogramming of four programs Conceptual model of 4 independent, sequential.
Page 1 Processes and Threads Chapter Processes 2.2 Threads 2.3 Interprocess communication 2.4 Classical IPC problems 2.5 Scheduling.
1 Process Description and Control Chapter 3. 2 Process Management—Fundamental task of an OS The OS is responsible for: Allocation of resources to processes.
CSCE 351: Operating System Kernels
3.5 Interprocess Communication
OS Spring’03 Introduction Operating Systems Spring 2003.
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.
Inter-Process Communication  most OSs provide several abstractions for inter- process communication: message passing, shared memory, etc.  communication.
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.
OS Spring’04 Introduction Operating Systems Spring 2004.
CSE 451: Operating Systems Autumn 2013 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process Description and Control
Process Description and Control Chapter 3. Major Requirements of an OS Interleave the execution of several processes to maximize processor utilization.
Process Description and Control
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 3 Process Description and Control Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Chapter 41 Processes Chapter 4. 2 Processes  Multiprogramming operating systems are built around the concept of process (also called task).  A process.
Chapter 3 Process Description and Control
Lecture 3 Process Concepts. What is a Process? A process is the dynamic execution context of an executing program. Several processes may run concurrently,
Hardware process When the computer is powered up, it begins to execute fetch-execute cycle for the program that is stored in memory at the boot strap entry.
Processes and Process Control 1. Processes and Process Control 2. Definitions of a Process 3. Systems state vs. Process State 4. A 2 State Process Model.
Politecnico di Milano © 2001 William Fornaciari Operating System Processes Lecturer: William Fornaciari Politecnico di Milano
Interrupt driven I/O. MIPS RISC Exception Mechanism The processor operates in The processor operates in user mode user mode kernel mode kernel mode Access.
Operating Systems 1 K. Salah Module 1.2: Fundamental Concepts Interrupts System Calls.
Processes, Threads, and Process States. Programs and Processes  Program: an executable file (before/after compilation)  Process: an instance of a program.
Process Description and Control Chapter 3. Source Modified slides from Missouri U. of Science and Tech.
1 Process Description and Control Chapter 3. 2 Requirements of an Operating System Interleave the execution of multiple processes to maximize processor.
Interrupt driven I/O Computer Organization and Assembly Language: Module 12.
1 Process Description and Control Chapter 3. 2 Process A program in execution An instance of a program running on a computer The entity that can be assigned.
Introduction Contain two or more CPU share common memory and peripherals. Provide greater system throughput. Multiple processor executing simultaneous.
Operating Systems Unit 2: – Process Context switch Interrupt Interprocess communication – Thread Thread models Operating Systems.
Interrupts and Exception Handling. Execution We are quite aware of the Fetch, Execute process of the control unit of the CPU –Fetch and instruction as.
CSCI/CMPE 4334 Operating Systems Review: Exam 1 1.
Processes and Threads Chapter 3 and 4 Operating Systems: Internals and Design Principles, 6/E William Stallings Patricia Roy Manatee Community College,
Introduction to Operating Systems
Processes and threads.
Chapter 3 – Process Concepts
Day 08 Processes.
Day 09 Processes.
Overview of today’s lecture
Structure of Processes
2P13 Week 2.
CSE 451: Operating Systems Spring 2012 Module 6 Review of Processes, Kernel Threads, User-Level Threads Ed Lazowska 570 Allen.
Process & its States Lecture 5.
Process Description and Control
Process Description and Control
Process Description and Control
Process Control B.Ramamurthy 2/22/2019 B.Ramamurthy.
Process Description and Control
Process Description and Control
Process Description and Control
Process Description and Control
Unix Process Control B.Ramamurthy 4/11/2019 B.Ramamurthy.
Chapter 2 Processes and Threads 2.1 Processes 2.2 Threads
Process Description and Control
Process Description and Control in Unix
Presentation transcript:

More on Processes Chapter 3

Process image _the physical representation of a process in the OS _an address space consisting of code, data and stack segments _a process control structure _ identification: process, parent process, user _ context of the execution: PC, SP, other registers _ control: scheduling (state, priority), resources (memory, opened files), IPC

Execution mode _most processors support at least two modes of execution: privileged(kernel-mode) and non-privileged (user-mode) for protection reasons _the portion of the OS executed in kernel-mode is called kernel (basic functions which must be protected from interference by user programs) _in kernel-mode the OS can do anything (no protection) _user processes execute in user-mode _in user-mode a process can access only its address space

Interrupts and traps _Interrupts: asynchronous _ external events (not related to the processor state) which occur independently of the instruction execution in the processor _ can be masked (specifically or not) _ Traps: synchronous _ conditionally or unconditionally caused by the execution of the current instruction _ Interrupts and traps force the processor to save the current state of execution and jump to a new state indicated in the interrupt vector

Mode switching _one or several bits in the processor status word (PS) indicate the current (sometimes also the previous) mode of execution _these bits can be changed explicitly while in kernel-mode but not in user-mode _the processor status word can be loaded from the interrupt vector along with the address of the interrupt handler _by setting the kernel mode bit in the interrupt vectors user processes enter kernel-mode to execute interrupt handlers

Signals _UNIX mechanism to upcall a handler indicated by the user process when an event occurs: segmentation violation, message arrival etc... _the kernel handles the event first, then puts an activation record on the user-level stack corresponding to the event handler _when the user process is scheduled next it executes the handler first _from the handler the user process returns to where it was when the event occurred

System calls _to request an OS service a process issues a system call _in monolithic OS a system call is implemented as a trap _when executing the user program code a process runs in user-mode _when executing the OS code corresponding to a system call a process runs in kernel-mode _in microkernel OS a system call is implemented as an IPC

System call in monolithic OS kernel mode user mode read(....) pc ps code for read system call trap interrupt vector for trap instruction iret in-kernel file system(monolithic OS)

Process creation _can be performed by the OS transparently to the user or can be made visible to the user as a system call _in UNIX a process (parent process) can spawn another process (child process) by calling fork _the child process is created as a copy of the parent process (process image and process control structure) except for the identification and scheduling state _parent and child processes run on two different address spaces => by default no memory sharing

Copy on Write (COW) _copy the entire process image is time consuming, optimizations are possible _code segment can be made read-only and shared _copy-on-write for data segments _ at fork time the data segment is mapped read-only and shared between the child and the parent process _ the copy is performed lazily, in page increments at first write

When to Switch a Process Clock interrupt –process has executed for the maximum allowable time slice I/O interrupt Memory fault –memory address is in virtual memory so it must be brought into main memory

When to Switch a Process Trap –error occurred –may cause process to be moved to Exit state Supervisor call –such as file open

Change of Process State Save context of processor including program counter and other registers Update the process control block of the process that is currently running Move process control block to appropriate queue - ready, blocked Select another process for execution

Change of Process State Update the process control block of the process selected Update memory-management data structures Restore context of the selected process

Execution of the Operating System Non-process Kernel –execute kernel outside of any process –operating system code is executed as a separate entity that operates in privileged mode Execution Within User Processes –operating system software within context of a user process –process executes in privileged mode when executing operating system code

Execution of the Operating System Process-Based Operating System –major kernel functions are separate processes –Useful in multi-processor or multi- computer environment

UNIX SVR4 Process Management Most of the operating system executes within the environment of a user process

Process switching _processor can switch modes from user to kernel and back to user while running the same process _process switching is the act of taking a process off the processor and replacing it with another one that is waiting to run _process switching occurs in kernel-mode and is a result of process scheduling that is performed when one of the following occurs: _ Time slice allocated to the process expires _ a blocking system call _ memory fault due to a page miss

Process switching in UNIX _each process has a kernel stack which is accessible only to the kernel but is part of the process image _each process has a page table which maps both its memory image and the kernel memory image _when switching mode from user to kernel, process switches to its kernel stack but doesn’t change the page table

Process switching in UNIX ( cont’d ) _ the execution state of the old process is saved on its kernel stack _ the kernel switches from the old address space to the address space of the process scheduled to run next _ the execution state of the new process to run is restored from its kernel stack

Inter-process communication _ most OSs provide several abstractions for inter- process communication: message passing, shared memory, etc.. _ communication requires synchronization between processes (i.e. data must be produced before it is consumed) _ synchronization can be implicit (message passing) or must be explicit (shared memory) _ explicit synchronization can be provided by the OS (semaphores, monitors, etc..) or can be achieved exclusively in user-mode (if processes share memory)

Message passing _ protected communication between different address spaces send (destination, message) receive(source, message) _ synchronization on send: _ asynchronous (non-blocking send) _ blocking send until the message “is sent” _ blocking send until the message is received _ synchronization on receive: _ asynchronous (non-blocking receive) _ blocking receive until message arrives

Message passing (cont’d) _ message addressing _ direct: specify the process _ indirect: specify the queue _ mutual exclusion using messages _ non-blocking send _ blocking receive

Message passing implementation _ two copy operations in a conventional implementation x=1 send(process2, &X) receive(process1,&Y) print Y process 1 process 2 X Y kernel buffers 1st copy 2nd copy kernel

Shared memory implementation _ no copying but synchronization is necessary X=1 print Y process 1 process 2 X Y kernel physical memory shared region