SlideShare a Scribd company logo
1 of 66
Instructor
Mr. S. Christalin Nelson
Process Management
Overview (1/8)
• Program
– Passive entity
• E.g. Executable file stored on disk (Contains a list of instructions)
• Process
– Active entity
• A program in execution (Executable file loaded into memory)
• E.g. Word-processing program run by an user on PC, System Task
(Sending output to printer)
– Alternatively called as a Job or time-shared program
• Batch Systems => Jobs
• Time-shared Systems => User program or tasks
– Single user System runs processes concurrently (Word, Browser, etc)
• Embedded Device with no multitasking -> OS performs its
internal activities
4/1/2022 Instructor: Mr.S.Christalin Nelson 3 of 66
Overview (2/8)
• Unit of work in modern systems
– Early Computers
• Execute one process at a time
• Process has access to all system resources
– Contemporary Computer Systems
• Allow multi-programing - Execute processes concurrently (switch
CPU between processes)
• Processes share the system resources
• System consists of collection of processes
– OS processes (Executes system code)
– User processes (Executes user code)
4/1/2022 Instructor: Mr.S.Christalin Nelson 4 of 66
Overview (3/8)
• Processes need
– Resources (physical/logical) to accomplish a task
• Example: CPU time, memory, files, I/O devices
• Resource allocation
– During process creation (OR) Execution
– Initialization data (inputs)
• Example of a Process: “Display file status on screen”
– Gets file name (I/P) -> Executes appropriate instructions &
system calls -> Displays desired information -> Terminate -> OS
reclaims the reusable resources
4/1/2022 Instructor: Mr.S.Christalin Nelson 5 of 66
Overview (4/8)
• A process can be executed by one or many threads
– Thread
• A component of a process (light-weight process)
• Example:
– MS Word as a process has Spell checker within it as thread
– Multithreaded Server Architecture
4/1/2022 Instructor: Mr.S.Christalin Nelson 6 of 66
Overview (5/8)
• Program – Process – Thread
– efficient to use one process that contains multiple threads
since process creation is time consuming and resource
intensive
4/1/2022 Instructor: Mr.S.Christalin Nelson 7 of 66
Overview (6/8)
• Single-threaded process
– No. of Program Counters: 1
– Sequentially execute the instructions in the process
• Multi-threaded process
– It is efficient to use one process that contains multiple threads
as process creation is time consuming and resource intensive
– No. of Program Counters: 1 per thread
4/1/2022 Instructor: Mr.S.Christalin Nelson
What is use of a PC?
Store Address of
next instruction to
be executed
8 of 66
Overview (7/8)
• Single & Multicore Systems
– Single-core systems – Concurrent execution of threads
– Multi-core systems – Parallel execution of threads
– Example: Consider an application with 4 threads
– Note: Parallelism vs. Concurrency
• Concurrency – Allow all the tasks to make progress
• Parallelism – Perform more than one task simultaneously
4/1/2022 Instructor: Mr.S.Christalin Nelson 9 of 66
Overview (8/8)
• OS Activities related to Process management
– CPU Scheduling (processes & threads)
– Create and delete processes
– Suspend and resume processes
– Process synchronization mechanisms
– Process communication mechanisms
4/1/2022 Instructor: Mr.S.Christalin Nelson 10 of 66
Process Structure in Memory (1/5)
4/1/2022 Instructor: Mr.S.Christalin Nelson 11 of 66
Process Structure in Memory (2/5)
• Text or Code Segment
– Stores executable instructions of a program (machine
instructions that CPU executes).
– ‘Sharable’
• Only a single copy needs to be in memory for frequently executed
programs (E.g. Text editors, C compiler).
– Often ‘Read-only’/Executable to prevent a program from
accidentally modifying its instructions.
4/1/2022 Instructor: Mr.S.Christalin Nelson 12 of 66
Process Structure in Memory (3/5)
• Data Segment or Initialized DS
– Stores static & global variables that are initialized by
programmer.
– Can be classified into ‘Read Only’ & ‘Read-Write’.
• BSS Segment or Uninitialized DS
– Stores static & global variables that are initialized to zero by
the system before program starts execution.
– Called “bss” segment for “block started by symbol”.
4/1/2022 Instructor: Mr.S.Christalin Nelson 13 of 66
Process Structure in Memory (4/5)
• Heap Segment
– Used for dynamic allocation when program runs.
– Shared by all shared libraries and dynamically loaded modules
in a process.
• Stack Segment
– Stores temporary data. i.e. Local (auto) variables, Stack frame
• Note: Stack frame
– Contains set of values pushed for one function call (function
parameters or at least caller’s return address)
– During each recursive function call a new stack frame is used
– Grows downward to lower addresses.
– ‘Stack pointer’ register points to top of stack.
4/1/2022 Instructor: Mr.S.Christalin Nelson 14 of 66
Process Structure in Memory (5/5)
• Methods for loading exe file into memory
– Double Click icon/app, Enter the name of executable (./a.out)
• Two processes associated with one program is considered as
2 separate execution sequences
– Text section –> Equivalent
– Data, Heap & Stack section –> Different
• A process can spawn many processes as it runs
• Process can be an execution environment for other code
– Example: Java programming environment
• Java executable program is executed within JVM. JVM executes
as a process that interprets the loaded Java code & takes actions
(via native machine instructions) on behalf of that code
– In simulation code is written for a different instruction set
4/1/2022 Instructor: Mr.S.Christalin Nelson 15 of 66
Process States (1/3)
• State is defined partly by current activity of a process
– i.e. During execution the state of a process changes
– Only 1 process runs on any processor
• Many processes may be ready & waiting
4/1/2022 Instructor: Mr.S.Christalin Nelson 16 of 66
Process States (2/3)
• Different states
– New: Process is being created
– Ready: Process is waiting to be assigned to a processor
– Running: Instructions are being executed
– Waiting: Process is waiting for some event to occur
• E.g. For I/O completion or reception of a signal
– Terminated: Process has finished execution
• Note: Names can vary across OSs
4/1/2022 Instructor: Mr.S.Christalin Nelson 17 of 66
Process States (3/3)
• What comprises state of a process or task?
– If P2 is to be created & run -> state of P1 must be saved
• P1 can be later resumed with no side-effects
• Only one copy of registers exist -> Must be saved in memory
4/1/2022 Instructor: Mr.S.Christalin Nelson 18 of 66
Process control block (1/6)
• Repository of information about a
specific process
• PCB contains
– (1) Process state
– (2) Process ID
– (3) Program counter
– (4) CPU registers (Vary in type/number)
• E.g. Accumulators, Index registers, Stack
pointers, & other General-purpose
registers, Condition-code register
– (5) CPU-scheduling information
• Includes process priority, pointers to
scheduling queues, & scheduling
parameters (if any)
4/1/2022 Instructor: Mr.S.Christalin Nelson 19 of 66
Process control block (2/6)
• PCB has information associated with a specific process
– (6) Memory-management information
• Includes value of base & limit registers, value of page/segment
tables (depending on memory system used by OS)
– (7) Accounting information
• Includes amount of CPU & real time used, time limits, account
numbers, job or process numbers
– (8) I/O status information
• Includes list of I/O devices allocated to process, list of open files
4/1/2022 Instructor: Mr.S.Christalin Nelson 20 of 66
Process control block (3/6)
4/1/2022 Instructor: Mr.S.Christalin Nelson
• Context Switching (1/2)
– Process Context
• Machine environment during the time the process is actively
using the CPU
– i.e. Context includes PC, general purpose registers, etc.
– CPU switches between processes
• The OS must
– Save context of currently executing process (if any) &
– Restore context of that process being resumed
• Time taken depends on hardware support
21 of 66
Process control block (4/6)
4/1/2022 Instructor: Mr.S.Christalin Nelson
• Context Switching (2/2)
22 of 66
Process control block (5/6)
• Paging
4/1/2022 Instructor: Mr.S.Christalin Nelson 23 of 66
Process control block (6/6)
• Segmentation
4/1/2022 Instructor: Mr.S.Christalin Nelson 24 of 66
Process scheduler
• Objectives of MP & timesharing systems
– Multiprogramming systems
• Maximize CPU utilization
• Have some process running at all times
– Time sharing systems
• Switch CPU among processes
• Process Scheduler?
– Meets the objectives by selecting an available process
4/1/2022 Instructor: Mr.S.Christalin Nelson 26 of 66
Scheduling Queues (1/5)
• Job Queue
– All processes in the system awaiting admission
• Ready Queue
– Set of all processes residing in main memory, ready to execute
• New process, Parent process return back to ready Queue after a
wait for its child process to complete
– Structure of Ready Queue
4/1/2022 Instructor: Mr.S.Christalin Nelson 27 of 66
Scheduling Queues (2/5)
• Device Queue(s)
– Set of processes waiting for an I/O device (or for other
processes)
– Each device has its own device queue
4/1/2022 Instructor: Mr.S.Christalin Nelson 28 of 66
Scheduling Queues (3/5)
• Queuing Diagram
– A common representation of process scheduling
• Notation used
– Rectangular Boxes: Queues
– Circles: Resources that serve the queues
– Arrows: Flow of processes in the system
4/1/2022 Instructor: Mr.S.Christalin Nelson
Job Queue
29 of 66
Scheduling Queues (4/5)
• After allocation of CPU, a Process can
– Execute
– Create new child process & Wait for child’s termination
• Eventually enters Ready Queue
– Get interrupted & Process removed from CPU
• Put back in Ready Queue
– Wait for event occurrence (e.g. Completion of an I/O request)
• Issue an I/O request & placed in I/O Queue -> eventually enters
Ready Queue.
– Finally Quit
• Removed from all queues, PCB & resources are deallocated.
4/1/2022 Instructor: Mr.S.Christalin Nelson 30 of 66
Scheduling Queues (5/5)
• Process migration among various scheduling queues
throughout its lifetime
4/1/2022 Instructor: Mr.S.Christalin Nelson 31 of 66
Schedulers
• System software used by OS to select processes from Queue
• Long-term, Short-term & Medium-term schedulers
– Job scheduler (also known as Long-term scheduler)
• Selects processes from Job pool in secondary into Ready Queue
– Careful mixture of I/O bound & CPU bound processes to yield
optimum system throughput
• Controls Degree of Multiprogramming
– CPU scheduler (also known as Short-term scheduler)
• Selects processes to be executed next & allocates CPU to it
– Process with a long burst time can lead to starvation
• Executes at least once every 100 milliseconds
– Medium-term Scheduler
• Swapping out a process from main memory (Suspension)
– Swapping in or Resumption could occur later from the point it
stopped executing
4/1/2022 Instructor: Mr.S.Christalin Nelson 32 of 66
Operations of Processes (1/3)
• Process Creation
– fork()
• Parent & child process competes for CPU
with all other processes in system
• OS decides
– Which process to execute
– When to execute
– How long to execute
4/1/2022 Instructor: Mr.S.Christalin Nelson 34 of 66
Operations of Processes (2/3)
• Process Creation (contd.)
– Orphans
• Process whose parent process has terminated,
though it remains running itself
• It will be immediately adopted by special “init”
system process with PID 1
• wait()
– Blocks caller until one of its child process terminates
– Parent can obtain exit status of terminated child
» Success: returns PID of child
» Failure (no child): returns -1
– Zombies
4/1/2022 Instructor: Mr.S.Christalin Nelson 35 of 66
Operations of Processes (3/3)
• Process Creation (contd.)
– exec() family
• Process Termination
4/1/2022 Instructor: Mr.S.Christalin Nelson 36 of 66
Cooperating Processes (1/2)
• Types of Concurrent processes
– Independent Processes
• Cannot affect or be affected by other processes executing in
system
• Does not share data with any other process
– Cooperating Processes
• Can affect or be affected by other processes executing in system
• Shares data with any other process
• Requires IPC mechanisms for data & information exchange
– IPC Models
» Shared Memory Model, Message Passing Model
» Note: Many systems implement both
4/1/2022 Instructor: Mr.S.Christalin Nelson 38 of 66
Cooperating Processes (2/2)
• Advantages of Process Cooperation
– Information sharing
• Concurrent access
– Computation speedup
• Subtasks execute in parallel with others multicore systems
– Modularity
• Dividing system functions into separate processes/threads
– Convenience
• Working with many processes at the same time
4/1/2022 Instructor: Mr.S.Christalin Nelson 39 of 66
Shared-memory model
• Establish a region of memory that can be shared
– Processes can exchange information by
reading/writing data (not simultaneously)
– Processes determine form of data & location
• Not under OS’s control
• Faster than message passing model
– System calls are required only to establish shared
memory region
– Does not require kernel intervention
• Difficult to implement in a distributed system
• Suffers from cache coherency issues in multicore
systems
4/1/2022 Instructor: Mr.S.Christalin Nelson 40 of 66
Producer-Consumer Problem
• Producer & Consumer processes should run concurrently
– Producer process produces information & Consumer process
consumes this information
– Examples
4/1/2022 Instructor: Mr.S.Christalin Nelson
Compiler Assembler Loader
Assembly Code Object Modules
Web Server Client
HTML files & images
• Solution: Use shared memory
– Types of Buffers
• Unbounded-buffer: No practical limit on buffer size
• Bounded-buffer: Assume a fixed buffer size
– Producer & Consumer must be synchronized
• Producer produces an item & Consumer consumes another item
• Code to access/manipulate shared memory - written by
application programmer
Who
waits?
41 of 66
Message-passing model (1/2)
4/1/2022 Instructor: Mr.S.Christalin Nelson
• Processes can exchange messages (smaller amounts of data)
• Slower than Shared memory model
– Implemented using system calls
– Require kernel intervention (more time)
• Easier to implement in a distributed system
– Example: Internet Chat
• Better performance in multicore systems
• Min. 2 operations
– Send & Receive message
• Message Size
– Fixed (or) Variable
42 of 66
Message-passing model (2/2)
4/1/2022 Instructor: Mr.S.Christalin Nelson
• Requirements of two communicating processes
– Establish Communication link between them
– Exchange messages via send/receive
• Implementation of communication link
– Physical (e.g., shared memory, hardware bus, network)
– Logical (e.g., logical properties)
• Methods (with Logical implementation & communication)
– Direct or Indirect communication
– Synchronous or Asynchronous communication
– Automatic or Explicit buffering
43 of 66
Naming (1/4)
• Identify communicating processes (say P & Q)
• Direct Communication
– Hard coded: Identifiers should be explicitly stated
• Symmetric Scheme of Addressing
– P: Send (Q, message)
– Q: Receive (P, message)
• Asymmetric Scheme of Addressing
– P: Send (Q, message)
– Q: Receive (id, message) – Receive from any process
– Properties of communication link
• Links are established automatically
• One link associated with exactly one pair of processes
• Between each pair there exists exactly one link
• Link may be unidirectional (usually bi-directional)
4/1/2022 Instructor: Mr.S.Christalin Nelson 44 of 66
Naming (2/4)
• Indirect Communication
– Each mailbox or port has a unique ID (say A). Mailbox is shared.
• Send (A, message)
• Receive (A, message)
– Properties of communication link
• Link established only if processes share a common mailbox
• A link may be associated with many processes
• Each pair of processes may share several communication links
(each link corresponds to a mailbox)
• Link may be unidirectional or bi-directional
4/1/2022 Instructor: Mr.S.Christalin Nelson 45 of 66
Naming (3/4)
• Indirect Communication (Contd.)
– Who owns the mailbox?
• Process owns mailbox (part of process’s address space)
– Receives messages only through this mailbox
– On process termination, the mailbox disappears
• OS owns mailbox (Independent & not attached to any particular
process). Process operations include
– Create a new mailbox
» Ownership & receiving privilege may be passed to other
processes through appropriate system calls
– Send & Receive messages through mailbox
– Destroy a mailbox
4/1/2022 Instructor: Mr.S.Christalin Nelson 46 of 66
Naming (4/4)
• Indirect Communication (Contd.)
– Mailbox sharing: Who gets the message?
• Consider P, Q, and R share mailbox A. P sends. R & Q receive
• Solutions
– Associate a link with at most two processes
– Only one process can execute a receive operation at a time
– System arbitrarily selects receiver & notifies Sender
» May use Round Robin
4/1/2022 Instructor: Mr.S.Christalin Nelson 47 of 66
Synchronization
• Message passing can be either synchronous (blocking) or
Asynchronous (non-blocking)
– Blocking send
• Sender blocked until receiver process or mailbox gets message
– Non-blocking send
• Sender can send message & continue
– Blocking receive
• Receiver blocked until message is available
– Non-blocking receive
• Receiver receives a valid message or null
• Different combinations are possible
– Rendezvous between sender & receiver -> Blocking Send &
Receive
4/1/2022 Instructor: Mr.S.Christalin Nelson 48 of 66
Buffering
• Direct or indirect communication – exchanged messages
reside in a temporary queue
– Queue Implementation
• Zero capacity – 0 waiting messages
– Blocking Send
• Bounded capacity – finite length of n messages
– If link not full: Non-Blocking Send
» Place message (copy entire message or pointer to it)
– If link full: Blocking Send
• Unbounded capacity – infinite length
– Non-Blocking Send (Sender never waits)
4/1/2022 Instructor: Mr.S.Christalin Nelson 49 of 66
Additional communication strategies
• Low level method
– Sockets
• Allow only unstructured stream of bytes exchanged between
communicating threads – Client/Server application could impose
a structure on the data
• High-level methods
– Remote Procedure Calls (RPCs)
– Pipes
4/1/2022 Instructor: Mr.S.Christalin Nelson 51 of 66
Sockets (1/2)
4/1/2022 Instructor: Mr.S.Christalin Nelson
• Endpoint for communication between distributed processes
– Identified by concatenation of IP address & Port
• i.e. Computer & Software/Service (Port vs. Socket ?)
• Communication consists between a pair of sockets
– Use Client-Server Architecture
• Server socket waits by listening to specified port
– IP: 161.25.19.8, Port: 80 => 161.25.19.8:80
• Client initiates request for connection -> System allocates unique
port (>1024) for each client process
– IP: 146.86.5.20, Port: 1625 => 146.86.5.20:1625
• Client request from client socket
• Server receives in server socket
• Server accepts a connection
52 of 66
Sockets (2/2)
• Ports
– 0 to 1023: Well known ports
• Assigned by IANA (common protocols & services)
– 1024 to 49151: Registered ports
• Assigned by ICANN to a specific service
– 49152 to 65535: Ephemeral or dynamic (private, high) ports
• Ephemeral ports: Used for shorter duration by client applications
– Persistent ports: Used for longer duration by server applications
4/1/2022 Instructor: Mr.S.Christalin Nelson 53 of 66
RPC (1/6)
• Used
– Between systems with network connections
– Implementing a distributed file system
• Message-based communication scheme to provide remote
service
– (Vs. IPC messages) Well structured & not just data packets
– RPC daemon listens to a port on Remote system
– Client send message to RPC daemon in the correct port
• Contains identifier (specifying function to execute) & fn.
parameters
– Function is executed as requested & Output is sent back to
requester in separate message
4/1/2022 Instructor: Mr.S.Christalin Nelson 54 of 66
RPC (2/6)
• RPC Semantics allows client to invoke procedure on remote
host as it would invoke a procedure locally
– Separate client-side Stub for each remote procedure
• Locates remote port -> Parameter marshalling (packaging) ->
Send message to server
– Server-side Stub
• Receives message -> Invokes procedure -> Returns value (if any)
• Note: Stub code in Windows
– Compiled from a specification written in Microsoft Interface
Definition Language (MIDL)
4/1/2022 Instructor: Mr.S.Christalin Nelson 55 of 66
RPC (3/6)
• Issues
– (1) Differences in data representation on client & server (Little-
Endian, Big-Endian)
• Solution: RPC systems have machine-independent data rep.
– E.g. External data rep. (XDR) used during parameter marshalling
– (2) Semantics of a call: Due to common network errors RPCs
can fail, duplicated & executed more than once (vs. Local call)
• Solution: OS ensures messages are acted on “exactly once”,
rather than “at most once”
– At most once
» Attach Timestamp with message -> Ignore incoming messages
that have a timestamp already in history
– Exactly once
» “At most once” protocol + Send acknowledgement to client
» Client resends each RPC call periodically until it receives ACK
4/1/2022 Instructor: Mr.S.Christalin Nelson 56 of 66
RPC (4/6)
• Issues (contd.)
– (3) Binding of client & server port (None have full information)
• Standard calls: Binding replaces procedure call’s name by its
memory address during link, load, or execution time
• Solutions
– Predetermine binding information (Fixed port no. for a service)
» (Compile time) Associate fixed server port no. with RPC ->
(After compilation) Server cannot change port no.
– Dynamic binding by rendezvous mechanism
» OS provides a rendezvous (called matchmaker) daemon on
fixed RPC port -> Client sends message to rendezvous daemon
contains RPC name & requests RPC port no. -> Port no. given ->
RPC sent to port no. until process terminates (or server crash)
» Requires extra overhead of initial request, More flexible
4/1/2022 Instructor: Mr.S.Christalin Nelson 57 of 66
4/1/2022 Instructor: Mr.S.Christalin Nelson 58 of 74
RPC (6/6)
• Implementing a distributed file system (DFS)
– Set of RPC daemons & clients
– Message sent to DFS port on a server with reqd. disk operation
(read, write, rename, delete, or status) -> Return message
contains data resulting from that call -> DFS daemon executes
on behalf of client
• Message might request whole file transfer or a simple block
– Whole file: several requests may be needed
4/1/2022 Instructor: Mr.S.Christalin Nelson 59 of 66
Pipes (1/6)
• Conduit allowing two processes to communicate
• Issues
– Allows bidirectional or unidirectional communication?
• If 2-way communication is allowed, is it half duplex or full duplex
– Must a relationship (such as parent–child) exist between
communicating processes?
– Can pipes communicate over network or must communicating
processes reside on same machine?
• Types
– Ordinary Pipes
– Named Pipes
4/1/2022 Instructor: Mr.S.Christalin Nelson 60 of 66
Pipe (2/6)
• Ordinary Pipe
– Unidirectional
• Producer (write-end) & Consumer (read-end)
• Bidirectional: Requires 2 pipes
– Requires parent–child relationship between communicating
processes (UNIX & Windows)
• Two processes communicate in producer-consumer fashion
• Cannot be accessed by other process
• Initially, parent & child process close their unused ends of pipe
– close()
– Used for communication between processes on same machine
4/1/2022 Instructor: Mr.S.Christalin Nelson 61 of 66
Pipe (3/6)
• Ordinary Pipe (contd.)
– Unix
• Creation: pipe(int fd[])
• Access: read(), write() system calls
– Windows systems (referred as "Anonymous pipes”)
• Creation: CreatePipe()
• Access: ReadFile(), WriteFile()
• Programmer specifies the attributes to be inherited by child
4/1/2022 Instructor: Mr.S.Christalin Nelson
Read
End
Write
End
62 of 66
Pipe (4/6)
• Named Pipes
– Communication can be bidirectional
– Parent–child relationship is not required
• Several processes can use a pipe (can have several writers)
– Pipe continue to exist after communicating processes have
finished
– Supported by UNIX & Windows systems
4/1/2022 Instructor: Mr.S.Christalin Nelson 63 of 66
Pipe (5/6)
• Named Pipes (contd.)
– UNIX (referred as FIFOs)
• Appear as typical files in the file system
• FIFOs allow bidirectional communication (only half-duplex is
permitted)
– 2 FIFOs required
• Creation: mkfifo() system call
• Manipulation: open(), read(), write(), close() system calls
• Continue to exist until it is explicitly deleted from file system
• Communicating processes must reside on same machine
– Inter-machine communication requires use of sockets
• Transmits only byte-oriented data
4/1/2022 Instructor: Mr.S.Christalin Nelson 64 of 66
Pipe (6/6)
• Named Pipes (contd.)
– Windows
• Full-duplex communication is allowed
• Creation: CreateNamedPipe()
• Communication: ReadFile(), WriteFile()
– Client connects to a named pipe using ConnectNamedPipe()
• Communicating processes can reside on same or different
machines
• Transmits either byte or message oriented data
4/1/2022 Instructor: Mr.S.Christalin Nelson 65 of 66
Process Management

More Related Content

What's hot

Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
Data Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfData Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfChristalin Nelson
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithmBinal Parekh
 
Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2Christalin Nelson
 
Relational_Algebra_Calculus Operations.pdf
Relational_Algebra_Calculus Operations.pdfRelational_Algebra_Calculus Operations.pdf
Relational_Algebra_Calculus Operations.pdfChristalin Nelson
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data miningYury Velikanov
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingTanel Poder
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Aaron Shilo
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfChristalin Nelson
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshootingNathan Winters
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into CassandraBrian Hess
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell ScriptingMustafa Qasim
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OSMsAnita2
 
Chapter 16 - Distributed System Structures
Chapter 16 - Distributed System StructuresChapter 16 - Distributed System Structures
Chapter 16 - Distributed System StructuresWayne Jones Jnr
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1Federico Campoli
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Shivam Mitra
 

What's hot (20)

Sql commands
Sql commandsSql commands
Sql commands
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
Data Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdfData Modeling - Enhanced ER diagrams & Mapping.pdf
Data Modeling - Enhanced ER diagrams & Mapping.pdf
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Window scheduling algorithm
Window scheduling algorithmWindow scheduling algorithm
Window scheduling algorithm
 
Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2Advanced Data Structures - Vol.2
Advanced Data Structures - Vol.2
 
Relational_Algebra_Calculus Operations.pdf
Relational_Algebra_Calculus Operations.pdfRelational_Algebra_Calculus Operations.pdf
Relational_Algebra_Calculus Operations.pdf
 
Oracle AWR Data mining
Oracle AWR Data miningOracle AWR Data mining
Oracle AWR Data mining
 
Oracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention TroubleshootingOracle Latch and Mutex Contention Troubleshooting
Oracle Latch and Mutex Contention Troubleshooting
 
Linux scheduler
Linux schedulerLinux scheduler
Linux scheduler
 
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
Exploring Oracle Database Performance Tuning Best Practices for DBAs and Deve...
 
DBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdfDBMSArchitecture_QueryProcessingandOptimization.pdf
DBMSArchitecture_QueryProcessingandOptimization.pdf
 
Sql server troubleshooting
Sql server troubleshootingSql server troubleshooting
Sql server troubleshooting
 
Bulk Loading into Cassandra
Bulk Loading into CassandraBulk Loading into Cassandra
Bulk Loading into Cassandra
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
 
Deadlock Avoidance - OS
Deadlock Avoidance - OSDeadlock Avoidance - OS
Deadlock Avoidance - OS
 
Chapter 16 - Distributed System Structures
Chapter 16 - Distributed System StructuresChapter 16 - Distributed System Structures
Chapter 16 - Distributed System Structures
 
Postgresql database administration volume 1
Postgresql database administration volume 1Postgresql database administration volume 1
Postgresql database administration volume 1
 
Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...Process management in operating system | process states | PCB | FORK() | Zomb...
Process management in operating system | process states | PCB | FORK() | Zomb...
 
Cassandra 101
Cassandra 101Cassandra 101
Cassandra 101
 

Similar to Process Management

Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxAmanuelmergia
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxAmanuelmergia
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentationchnrketan
 
EMBEDDED OS
EMBEDDED OSEMBEDDED OS
EMBEDDED OSAJAL A J
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdfAmanuelmergia
 
Memory Management in Operating Systems for all
Memory Management in Operating Systems for allMemory Management in Operating Systems for all
Memory Management in Operating Systems for allVSKAMCSPSGCT
 
08 operating system support
08 operating system support08 operating system support
08 operating system supportdilip kumar
 
08 operating system support
08 operating system support08 operating system support
08 operating system supportBitta_man
 
Process Management.pdf
Process Management.pdfProcess Management.pdf
Process Management.pdfYashjangid9
 
OS_Unit II - Process Management_CATI.pptx
OS_Unit II - Process Management_CATI.pptxOS_Unit II - Process Management_CATI.pptx
OS_Unit II - Process Management_CATI.pptxGokhul2
 
08 operating system support
08 operating system support08 operating system support
08 operating system supportAnwal Mirza
 
Processes in Operating System
Processes in Operating SystemProcesses in Operating System
Processes in Operating SystemArafat Hossan
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSKathirvel Ayyaswamy
 

Similar to Process Management (20)

Operating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptxOperating Systems chap 2_updated2.pptx
Operating Systems chap 2_updated2.pptx
 
Operating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptxOperating Systems chap 2_updated2 (1).pptx
Operating Systems chap 2_updated2 (1).pptx
 
Chapter -2 operating system presentation
Chapter -2 operating system presentationChapter -2 operating system presentation
Chapter -2 operating system presentation
 
Processes
ProcessesProcesses
Processes
 
EMBEDDED OS
EMBEDDED OSEMBEDDED OS
EMBEDDED OS
 
Lecture 2- Processes.pdf
Lecture 2- Processes.pdfLecture 2- Processes.pdf
Lecture 2- Processes.pdf
 
Memory Management in Operating Systems for all
Memory Management in Operating Systems for allMemory Management in Operating Systems for all
Memory Management in Operating Systems for all
 
Ch3 processes
Ch3   processesCh3   processes
Ch3 processes
 
Lecture5
Lecture5Lecture5
Lecture5
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
Process Management.pdf
Process Management.pdfProcess Management.pdf
Process Management.pdf
 
Os
OsOs
Os
 
OS_Unit II - Process Management_CATI.pptx
OS_Unit II - Process Management_CATI.pptxOS_Unit II - Process Management_CATI.pptx
OS_Unit II - Process Management_CATI.pptx
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
08 operating system support
08 operating system support08 operating system support
08 operating system support
 
Process Management
Process ManagementProcess Management
Process Management
 
Processes in Operating System
Processes in Operating SystemProcesses in Operating System
Processes in Operating System
 
CS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMSCS9222 ADVANCED OPERATING SYSTEMS
CS9222 ADVANCED OPERATING SYSTEMS
 
Operating system 2 by adi
Operating system 2 by adiOperating system 2 by adi
Operating system 2 by adi
 

More from Christalin Nelson

More from Christalin Nelson (15)

Indexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdfIndexing Structures in Database Management system.pdf
Indexing Structures in Database Management system.pdf
 
Packages and Subpackages in Java
Packages and Subpackages in JavaPackages and Subpackages in Java
Packages and Subpackages in Java
 
Bitwise complement operator
Bitwise complement operatorBitwise complement operator
Bitwise complement operator
 
Applications of Stack
Applications of StackApplications of Stack
Applications of Stack
 
Data Storage and Information Management
Data Storage and Information ManagementData Storage and Information Management
Data Storage and Information Management
 
Application Middleware Overview
Application Middleware OverviewApplication Middleware Overview
Application Middleware Overview
 
Network security
Network securityNetwork security
Network security
 
Directory services
Directory servicesDirectory services
Directory services
 
System overview
System overviewSystem overview
System overview
 
Storage overview
Storage overviewStorage overview
Storage overview
 
Database overview
Database overviewDatabase overview
Database overview
 
Computer Fundamentals-2
Computer Fundamentals-2Computer Fundamentals-2
Computer Fundamentals-2
 
Computer Fundamentals - 1
Computer Fundamentals - 1Computer Fundamentals - 1
Computer Fundamentals - 1
 
Advanced data structures vol. 1
Advanced data structures   vol. 1Advanced data structures   vol. 1
Advanced data structures vol. 1
 
Programming in c++
Programming in c++Programming in c++
Programming in c++
 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

Process Management

  • 1. Instructor Mr. S. Christalin Nelson Process Management
  • 2.
  • 3. Overview (1/8) • Program – Passive entity • E.g. Executable file stored on disk (Contains a list of instructions) • Process – Active entity • A program in execution (Executable file loaded into memory) • E.g. Word-processing program run by an user on PC, System Task (Sending output to printer) – Alternatively called as a Job or time-shared program • Batch Systems => Jobs • Time-shared Systems => User program or tasks – Single user System runs processes concurrently (Word, Browser, etc) • Embedded Device with no multitasking -> OS performs its internal activities 4/1/2022 Instructor: Mr.S.Christalin Nelson 3 of 66
  • 4. Overview (2/8) • Unit of work in modern systems – Early Computers • Execute one process at a time • Process has access to all system resources – Contemporary Computer Systems • Allow multi-programing - Execute processes concurrently (switch CPU between processes) • Processes share the system resources • System consists of collection of processes – OS processes (Executes system code) – User processes (Executes user code) 4/1/2022 Instructor: Mr.S.Christalin Nelson 4 of 66
  • 5. Overview (3/8) • Processes need – Resources (physical/logical) to accomplish a task • Example: CPU time, memory, files, I/O devices • Resource allocation – During process creation (OR) Execution – Initialization data (inputs) • Example of a Process: “Display file status on screen” – Gets file name (I/P) -> Executes appropriate instructions & system calls -> Displays desired information -> Terminate -> OS reclaims the reusable resources 4/1/2022 Instructor: Mr.S.Christalin Nelson 5 of 66
  • 6. Overview (4/8) • A process can be executed by one or many threads – Thread • A component of a process (light-weight process) • Example: – MS Word as a process has Spell checker within it as thread – Multithreaded Server Architecture 4/1/2022 Instructor: Mr.S.Christalin Nelson 6 of 66
  • 7. Overview (5/8) • Program – Process – Thread – efficient to use one process that contains multiple threads since process creation is time consuming and resource intensive 4/1/2022 Instructor: Mr.S.Christalin Nelson 7 of 66
  • 8. Overview (6/8) • Single-threaded process – No. of Program Counters: 1 – Sequentially execute the instructions in the process • Multi-threaded process – It is efficient to use one process that contains multiple threads as process creation is time consuming and resource intensive – No. of Program Counters: 1 per thread 4/1/2022 Instructor: Mr.S.Christalin Nelson What is use of a PC? Store Address of next instruction to be executed 8 of 66
  • 9. Overview (7/8) • Single & Multicore Systems – Single-core systems – Concurrent execution of threads – Multi-core systems – Parallel execution of threads – Example: Consider an application with 4 threads – Note: Parallelism vs. Concurrency • Concurrency – Allow all the tasks to make progress • Parallelism – Perform more than one task simultaneously 4/1/2022 Instructor: Mr.S.Christalin Nelson 9 of 66
  • 10. Overview (8/8) • OS Activities related to Process management – CPU Scheduling (processes & threads) – Create and delete processes – Suspend and resume processes – Process synchronization mechanisms – Process communication mechanisms 4/1/2022 Instructor: Mr.S.Christalin Nelson 10 of 66
  • 11. Process Structure in Memory (1/5) 4/1/2022 Instructor: Mr.S.Christalin Nelson 11 of 66
  • 12. Process Structure in Memory (2/5) • Text or Code Segment – Stores executable instructions of a program (machine instructions that CPU executes). – ‘Sharable’ • Only a single copy needs to be in memory for frequently executed programs (E.g. Text editors, C compiler). – Often ‘Read-only’/Executable to prevent a program from accidentally modifying its instructions. 4/1/2022 Instructor: Mr.S.Christalin Nelson 12 of 66
  • 13. Process Structure in Memory (3/5) • Data Segment or Initialized DS – Stores static & global variables that are initialized by programmer. – Can be classified into ‘Read Only’ & ‘Read-Write’. • BSS Segment or Uninitialized DS – Stores static & global variables that are initialized to zero by the system before program starts execution. – Called “bss” segment for “block started by symbol”. 4/1/2022 Instructor: Mr.S.Christalin Nelson 13 of 66
  • 14. Process Structure in Memory (4/5) • Heap Segment – Used for dynamic allocation when program runs. – Shared by all shared libraries and dynamically loaded modules in a process. • Stack Segment – Stores temporary data. i.e. Local (auto) variables, Stack frame • Note: Stack frame – Contains set of values pushed for one function call (function parameters or at least caller’s return address) – During each recursive function call a new stack frame is used – Grows downward to lower addresses. – ‘Stack pointer’ register points to top of stack. 4/1/2022 Instructor: Mr.S.Christalin Nelson 14 of 66
  • 15. Process Structure in Memory (5/5) • Methods for loading exe file into memory – Double Click icon/app, Enter the name of executable (./a.out) • Two processes associated with one program is considered as 2 separate execution sequences – Text section –> Equivalent – Data, Heap & Stack section –> Different • A process can spawn many processes as it runs • Process can be an execution environment for other code – Example: Java programming environment • Java executable program is executed within JVM. JVM executes as a process that interprets the loaded Java code & takes actions (via native machine instructions) on behalf of that code – In simulation code is written for a different instruction set 4/1/2022 Instructor: Mr.S.Christalin Nelson 15 of 66
  • 16. Process States (1/3) • State is defined partly by current activity of a process – i.e. During execution the state of a process changes – Only 1 process runs on any processor • Many processes may be ready & waiting 4/1/2022 Instructor: Mr.S.Christalin Nelson 16 of 66
  • 17. Process States (2/3) • Different states – New: Process is being created – Ready: Process is waiting to be assigned to a processor – Running: Instructions are being executed – Waiting: Process is waiting for some event to occur • E.g. For I/O completion or reception of a signal – Terminated: Process has finished execution • Note: Names can vary across OSs 4/1/2022 Instructor: Mr.S.Christalin Nelson 17 of 66
  • 18. Process States (3/3) • What comprises state of a process or task? – If P2 is to be created & run -> state of P1 must be saved • P1 can be later resumed with no side-effects • Only one copy of registers exist -> Must be saved in memory 4/1/2022 Instructor: Mr.S.Christalin Nelson 18 of 66
  • 19. Process control block (1/6) • Repository of information about a specific process • PCB contains – (1) Process state – (2) Process ID – (3) Program counter – (4) CPU registers (Vary in type/number) • E.g. Accumulators, Index registers, Stack pointers, & other General-purpose registers, Condition-code register – (5) CPU-scheduling information • Includes process priority, pointers to scheduling queues, & scheduling parameters (if any) 4/1/2022 Instructor: Mr.S.Christalin Nelson 19 of 66
  • 20. Process control block (2/6) • PCB has information associated with a specific process – (6) Memory-management information • Includes value of base & limit registers, value of page/segment tables (depending on memory system used by OS) – (7) Accounting information • Includes amount of CPU & real time used, time limits, account numbers, job or process numbers – (8) I/O status information • Includes list of I/O devices allocated to process, list of open files 4/1/2022 Instructor: Mr.S.Christalin Nelson 20 of 66
  • 21. Process control block (3/6) 4/1/2022 Instructor: Mr.S.Christalin Nelson • Context Switching (1/2) – Process Context • Machine environment during the time the process is actively using the CPU – i.e. Context includes PC, general purpose registers, etc. – CPU switches between processes • The OS must – Save context of currently executing process (if any) & – Restore context of that process being resumed • Time taken depends on hardware support 21 of 66
  • 22. Process control block (4/6) 4/1/2022 Instructor: Mr.S.Christalin Nelson • Context Switching (2/2) 22 of 66
  • 23. Process control block (5/6) • Paging 4/1/2022 Instructor: Mr.S.Christalin Nelson 23 of 66
  • 24. Process control block (6/6) • Segmentation 4/1/2022 Instructor: Mr.S.Christalin Nelson 24 of 66
  • 25.
  • 26. Process scheduler • Objectives of MP & timesharing systems – Multiprogramming systems • Maximize CPU utilization • Have some process running at all times – Time sharing systems • Switch CPU among processes • Process Scheduler? – Meets the objectives by selecting an available process 4/1/2022 Instructor: Mr.S.Christalin Nelson 26 of 66
  • 27. Scheduling Queues (1/5) • Job Queue – All processes in the system awaiting admission • Ready Queue – Set of all processes residing in main memory, ready to execute • New process, Parent process return back to ready Queue after a wait for its child process to complete – Structure of Ready Queue 4/1/2022 Instructor: Mr.S.Christalin Nelson 27 of 66
  • 28. Scheduling Queues (2/5) • Device Queue(s) – Set of processes waiting for an I/O device (or for other processes) – Each device has its own device queue 4/1/2022 Instructor: Mr.S.Christalin Nelson 28 of 66
  • 29. Scheduling Queues (3/5) • Queuing Diagram – A common representation of process scheduling • Notation used – Rectangular Boxes: Queues – Circles: Resources that serve the queues – Arrows: Flow of processes in the system 4/1/2022 Instructor: Mr.S.Christalin Nelson Job Queue 29 of 66
  • 30. Scheduling Queues (4/5) • After allocation of CPU, a Process can – Execute – Create new child process & Wait for child’s termination • Eventually enters Ready Queue – Get interrupted & Process removed from CPU • Put back in Ready Queue – Wait for event occurrence (e.g. Completion of an I/O request) • Issue an I/O request & placed in I/O Queue -> eventually enters Ready Queue. – Finally Quit • Removed from all queues, PCB & resources are deallocated. 4/1/2022 Instructor: Mr.S.Christalin Nelson 30 of 66
  • 31. Scheduling Queues (5/5) • Process migration among various scheduling queues throughout its lifetime 4/1/2022 Instructor: Mr.S.Christalin Nelson 31 of 66
  • 32. Schedulers • System software used by OS to select processes from Queue • Long-term, Short-term & Medium-term schedulers – Job scheduler (also known as Long-term scheduler) • Selects processes from Job pool in secondary into Ready Queue – Careful mixture of I/O bound & CPU bound processes to yield optimum system throughput • Controls Degree of Multiprogramming – CPU scheduler (also known as Short-term scheduler) • Selects processes to be executed next & allocates CPU to it – Process with a long burst time can lead to starvation • Executes at least once every 100 milliseconds – Medium-term Scheduler • Swapping out a process from main memory (Suspension) – Swapping in or Resumption could occur later from the point it stopped executing 4/1/2022 Instructor: Mr.S.Christalin Nelson 32 of 66
  • 33.
  • 34. Operations of Processes (1/3) • Process Creation – fork() • Parent & child process competes for CPU with all other processes in system • OS decides – Which process to execute – When to execute – How long to execute 4/1/2022 Instructor: Mr.S.Christalin Nelson 34 of 66
  • 35. Operations of Processes (2/3) • Process Creation (contd.) – Orphans • Process whose parent process has terminated, though it remains running itself • It will be immediately adopted by special “init” system process with PID 1 • wait() – Blocks caller until one of its child process terminates – Parent can obtain exit status of terminated child » Success: returns PID of child » Failure (no child): returns -1 – Zombies 4/1/2022 Instructor: Mr.S.Christalin Nelson 35 of 66
  • 36. Operations of Processes (3/3) • Process Creation (contd.) – exec() family • Process Termination 4/1/2022 Instructor: Mr.S.Christalin Nelson 36 of 66
  • 37.
  • 38. Cooperating Processes (1/2) • Types of Concurrent processes – Independent Processes • Cannot affect or be affected by other processes executing in system • Does not share data with any other process – Cooperating Processes • Can affect or be affected by other processes executing in system • Shares data with any other process • Requires IPC mechanisms for data & information exchange – IPC Models » Shared Memory Model, Message Passing Model » Note: Many systems implement both 4/1/2022 Instructor: Mr.S.Christalin Nelson 38 of 66
  • 39. Cooperating Processes (2/2) • Advantages of Process Cooperation – Information sharing • Concurrent access – Computation speedup • Subtasks execute in parallel with others multicore systems – Modularity • Dividing system functions into separate processes/threads – Convenience • Working with many processes at the same time 4/1/2022 Instructor: Mr.S.Christalin Nelson 39 of 66
  • 40. Shared-memory model • Establish a region of memory that can be shared – Processes can exchange information by reading/writing data (not simultaneously) – Processes determine form of data & location • Not under OS’s control • Faster than message passing model – System calls are required only to establish shared memory region – Does not require kernel intervention • Difficult to implement in a distributed system • Suffers from cache coherency issues in multicore systems 4/1/2022 Instructor: Mr.S.Christalin Nelson 40 of 66
  • 41. Producer-Consumer Problem • Producer & Consumer processes should run concurrently – Producer process produces information & Consumer process consumes this information – Examples 4/1/2022 Instructor: Mr.S.Christalin Nelson Compiler Assembler Loader Assembly Code Object Modules Web Server Client HTML files & images • Solution: Use shared memory – Types of Buffers • Unbounded-buffer: No practical limit on buffer size • Bounded-buffer: Assume a fixed buffer size – Producer & Consumer must be synchronized • Producer produces an item & Consumer consumes another item • Code to access/manipulate shared memory - written by application programmer Who waits? 41 of 66
  • 42. Message-passing model (1/2) 4/1/2022 Instructor: Mr.S.Christalin Nelson • Processes can exchange messages (smaller amounts of data) • Slower than Shared memory model – Implemented using system calls – Require kernel intervention (more time) • Easier to implement in a distributed system – Example: Internet Chat • Better performance in multicore systems • Min. 2 operations – Send & Receive message • Message Size – Fixed (or) Variable 42 of 66
  • 43. Message-passing model (2/2) 4/1/2022 Instructor: Mr.S.Christalin Nelson • Requirements of two communicating processes – Establish Communication link between them – Exchange messages via send/receive • Implementation of communication link – Physical (e.g., shared memory, hardware bus, network) – Logical (e.g., logical properties) • Methods (with Logical implementation & communication) – Direct or Indirect communication – Synchronous or Asynchronous communication – Automatic or Explicit buffering 43 of 66
  • 44. Naming (1/4) • Identify communicating processes (say P & Q) • Direct Communication – Hard coded: Identifiers should be explicitly stated • Symmetric Scheme of Addressing – P: Send (Q, message) – Q: Receive (P, message) • Asymmetric Scheme of Addressing – P: Send (Q, message) – Q: Receive (id, message) – Receive from any process – Properties of communication link • Links are established automatically • One link associated with exactly one pair of processes • Between each pair there exists exactly one link • Link may be unidirectional (usually bi-directional) 4/1/2022 Instructor: Mr.S.Christalin Nelson 44 of 66
  • 45. Naming (2/4) • Indirect Communication – Each mailbox or port has a unique ID (say A). Mailbox is shared. • Send (A, message) • Receive (A, message) – Properties of communication link • Link established only if processes share a common mailbox • A link may be associated with many processes • Each pair of processes may share several communication links (each link corresponds to a mailbox) • Link may be unidirectional or bi-directional 4/1/2022 Instructor: Mr.S.Christalin Nelson 45 of 66
  • 46. Naming (3/4) • Indirect Communication (Contd.) – Who owns the mailbox? • Process owns mailbox (part of process’s address space) – Receives messages only through this mailbox – On process termination, the mailbox disappears • OS owns mailbox (Independent & not attached to any particular process). Process operations include – Create a new mailbox » Ownership & receiving privilege may be passed to other processes through appropriate system calls – Send & Receive messages through mailbox – Destroy a mailbox 4/1/2022 Instructor: Mr.S.Christalin Nelson 46 of 66
  • 47. Naming (4/4) • Indirect Communication (Contd.) – Mailbox sharing: Who gets the message? • Consider P, Q, and R share mailbox A. P sends. R & Q receive • Solutions – Associate a link with at most two processes – Only one process can execute a receive operation at a time – System arbitrarily selects receiver & notifies Sender » May use Round Robin 4/1/2022 Instructor: Mr.S.Christalin Nelson 47 of 66
  • 48. Synchronization • Message passing can be either synchronous (blocking) or Asynchronous (non-blocking) – Blocking send • Sender blocked until receiver process or mailbox gets message – Non-blocking send • Sender can send message & continue – Blocking receive • Receiver blocked until message is available – Non-blocking receive • Receiver receives a valid message or null • Different combinations are possible – Rendezvous between sender & receiver -> Blocking Send & Receive 4/1/2022 Instructor: Mr.S.Christalin Nelson 48 of 66
  • 49. Buffering • Direct or indirect communication – exchanged messages reside in a temporary queue – Queue Implementation • Zero capacity – 0 waiting messages – Blocking Send • Bounded capacity – finite length of n messages – If link not full: Non-Blocking Send » Place message (copy entire message or pointer to it) – If link full: Blocking Send • Unbounded capacity – infinite length – Non-Blocking Send (Sender never waits) 4/1/2022 Instructor: Mr.S.Christalin Nelson 49 of 66
  • 50.
  • 51. Additional communication strategies • Low level method – Sockets • Allow only unstructured stream of bytes exchanged between communicating threads – Client/Server application could impose a structure on the data • High-level methods – Remote Procedure Calls (RPCs) – Pipes 4/1/2022 Instructor: Mr.S.Christalin Nelson 51 of 66
  • 52. Sockets (1/2) 4/1/2022 Instructor: Mr.S.Christalin Nelson • Endpoint for communication between distributed processes – Identified by concatenation of IP address & Port • i.e. Computer & Software/Service (Port vs. Socket ?) • Communication consists between a pair of sockets – Use Client-Server Architecture • Server socket waits by listening to specified port – IP: 161.25.19.8, Port: 80 => 161.25.19.8:80 • Client initiates request for connection -> System allocates unique port (>1024) for each client process – IP: 146.86.5.20, Port: 1625 => 146.86.5.20:1625 • Client request from client socket • Server receives in server socket • Server accepts a connection 52 of 66
  • 53. Sockets (2/2) • Ports – 0 to 1023: Well known ports • Assigned by IANA (common protocols & services) – 1024 to 49151: Registered ports • Assigned by ICANN to a specific service – 49152 to 65535: Ephemeral or dynamic (private, high) ports • Ephemeral ports: Used for shorter duration by client applications – Persistent ports: Used for longer duration by server applications 4/1/2022 Instructor: Mr.S.Christalin Nelson 53 of 66
  • 54. RPC (1/6) • Used – Between systems with network connections – Implementing a distributed file system • Message-based communication scheme to provide remote service – (Vs. IPC messages) Well structured & not just data packets – RPC daemon listens to a port on Remote system – Client send message to RPC daemon in the correct port • Contains identifier (specifying function to execute) & fn. parameters – Function is executed as requested & Output is sent back to requester in separate message 4/1/2022 Instructor: Mr.S.Christalin Nelson 54 of 66
  • 55. RPC (2/6) • RPC Semantics allows client to invoke procedure on remote host as it would invoke a procedure locally – Separate client-side Stub for each remote procedure • Locates remote port -> Parameter marshalling (packaging) -> Send message to server – Server-side Stub • Receives message -> Invokes procedure -> Returns value (if any) • Note: Stub code in Windows – Compiled from a specification written in Microsoft Interface Definition Language (MIDL) 4/1/2022 Instructor: Mr.S.Christalin Nelson 55 of 66
  • 56. RPC (3/6) • Issues – (1) Differences in data representation on client & server (Little- Endian, Big-Endian) • Solution: RPC systems have machine-independent data rep. – E.g. External data rep. (XDR) used during parameter marshalling – (2) Semantics of a call: Due to common network errors RPCs can fail, duplicated & executed more than once (vs. Local call) • Solution: OS ensures messages are acted on “exactly once”, rather than “at most once” – At most once » Attach Timestamp with message -> Ignore incoming messages that have a timestamp already in history – Exactly once » “At most once” protocol + Send acknowledgement to client » Client resends each RPC call periodically until it receives ACK 4/1/2022 Instructor: Mr.S.Christalin Nelson 56 of 66
  • 57. RPC (4/6) • Issues (contd.) – (3) Binding of client & server port (None have full information) • Standard calls: Binding replaces procedure call’s name by its memory address during link, load, or execution time • Solutions – Predetermine binding information (Fixed port no. for a service) » (Compile time) Associate fixed server port no. with RPC -> (After compilation) Server cannot change port no. – Dynamic binding by rendezvous mechanism » OS provides a rendezvous (called matchmaker) daemon on fixed RPC port -> Client sends message to rendezvous daemon contains RPC name & requests RPC port no. -> Port no. given -> RPC sent to port no. until process terminates (or server crash) » Requires extra overhead of initial request, More flexible 4/1/2022 Instructor: Mr.S.Christalin Nelson 57 of 66
  • 59. RPC (6/6) • Implementing a distributed file system (DFS) – Set of RPC daemons & clients – Message sent to DFS port on a server with reqd. disk operation (read, write, rename, delete, or status) -> Return message contains data resulting from that call -> DFS daemon executes on behalf of client • Message might request whole file transfer or a simple block – Whole file: several requests may be needed 4/1/2022 Instructor: Mr.S.Christalin Nelson 59 of 66
  • 60. Pipes (1/6) • Conduit allowing two processes to communicate • Issues – Allows bidirectional or unidirectional communication? • If 2-way communication is allowed, is it half duplex or full duplex – Must a relationship (such as parent–child) exist between communicating processes? – Can pipes communicate over network or must communicating processes reside on same machine? • Types – Ordinary Pipes – Named Pipes 4/1/2022 Instructor: Mr.S.Christalin Nelson 60 of 66
  • 61. Pipe (2/6) • Ordinary Pipe – Unidirectional • Producer (write-end) & Consumer (read-end) • Bidirectional: Requires 2 pipes – Requires parent–child relationship between communicating processes (UNIX & Windows) • Two processes communicate in producer-consumer fashion • Cannot be accessed by other process • Initially, parent & child process close their unused ends of pipe – close() – Used for communication between processes on same machine 4/1/2022 Instructor: Mr.S.Christalin Nelson 61 of 66
  • 62. Pipe (3/6) • Ordinary Pipe (contd.) – Unix • Creation: pipe(int fd[]) • Access: read(), write() system calls – Windows systems (referred as "Anonymous pipes”) • Creation: CreatePipe() • Access: ReadFile(), WriteFile() • Programmer specifies the attributes to be inherited by child 4/1/2022 Instructor: Mr.S.Christalin Nelson Read End Write End 62 of 66
  • 63. Pipe (4/6) • Named Pipes – Communication can be bidirectional – Parent–child relationship is not required • Several processes can use a pipe (can have several writers) – Pipe continue to exist after communicating processes have finished – Supported by UNIX & Windows systems 4/1/2022 Instructor: Mr.S.Christalin Nelson 63 of 66
  • 64. Pipe (5/6) • Named Pipes (contd.) – UNIX (referred as FIFOs) • Appear as typical files in the file system • FIFOs allow bidirectional communication (only half-duplex is permitted) – 2 FIFOs required • Creation: mkfifo() system call • Manipulation: open(), read(), write(), close() system calls • Continue to exist until it is explicitly deleted from file system • Communicating processes must reside on same machine – Inter-machine communication requires use of sockets • Transmits only byte-oriented data 4/1/2022 Instructor: Mr.S.Christalin Nelson 64 of 66
  • 65. Pipe (6/6) • Named Pipes (contd.) – Windows • Full-duplex communication is allowed • Creation: CreateNamedPipe() • Communication: ReadFile(), WriteFile() – Client connects to a named pipe using ConnectNamedPipe() • Communicating processes can reside on same or different machines • Transmits either byte or message oriented data 4/1/2022 Instructor: Mr.S.Christalin Nelson 65 of 66