DC Module4 Comprehensive Notes
DC Module4 Comprehensive Notes
MODULE 4
Resource & Process Management
University of Mumbai | BE Computer Engineering | Semester 8
Comprehensive Exam Notes with Diagrams
Task Assignment Assign each task of a process to Task characteristics and inter-task
the optimal node based on IPC costs are known in advance
cost + execution cost
Load Balancing Equalize workload across ALL Uniform distribution required;
nodes — transfer processes from dynamic state info available
heavy to light nodes
Load Sharing Just ensure NO node is idle while Simpler systems; preventing
others are busy — NOT full idleness is sufficient
equalization
VI. Scalability
The algorithm must handle both small networks (few nodes) and large networks (thousands of nodes) without
degradation. Algorithms relying on broadcasting state info to ALL nodes are NOT scalable. Design must degrade
gracefully with increasing network size.
Main Assumptions
● Processes have already been split into tasks before scheduling.
● Computation requirement of tasks and speed of processors are KNOWN IN ADVANCE.
● Cost of processing tasks on nodes is known (derived from processor speed × computation required).
● IPC cost between every pair of tasks is known: if tasks communicate n times with average time t, then
IPC cost = n × t.
● Resource requirements and available resources on each node are known.
● REASSIGNMENT of tasks is NOT possible once assigned.
1. Minimize IPC Costs Place communicating tasks on the Goal 4: If all tasks on one node, no
SAME node to avoid network parallelism.
overhead.
2. Quick Turnaround Complete all tasks in shortest total Goal 3: Parallelism may require
time. splitting tasks.
3. High Parallelism Spread tasks across MULTIPLE Goal 1: Parallel execution
nodes for simultaneous execution. increases IPC cost.
4. Efficient Resource Use Use all nodes' resources — don't Goal 1: Concentrating tasks
leave nodes idle. wastes other nodes.
📌 KEY CONFLICT
Goal 1 (minimize IPC) says put all tasks on ONE node. Goal 3 (parallelism) and Goal 4 (resource use) say
spread across ALL nodes. The optimal assignment BALANCES both — this is why it is NP-hard.
📌 EXAM NOTE
This type of numerical is frequently asked. Learn to compute: (1) Execution Cost for each assignment.
(2) IPC Cost = only costs for tasks on DIFFERENT nodes. (3) Total Cost = Execution Cost + IPC Cost.
t1 0 6 4 0 0 12
t2 6 0 8 12 3 0
t3 4 8 0 0 11 0
t4 0 12 0 0 5 0
t5 0 3 11 5 0 0
t6 12 0 0 0 0 0
📌 IMPORTANT
IPC cost is incurred ONLY when two communicating tasks are on DIFFERENT nodes. If on the same node
→ IPC cost = 0 (communication is local, no network involved).
t1 n1 5
t2 n1 (forced) 2
t3 n1 4
t4 n1 6
t5 n1 5
t6 n2 (forced) 4
Execution Cost: (t1+t2+t3 on n1) = 5+2+4 = 11. (t4+t5+t6 on n2) = 3+2+4 = 9. Total Exec = 20
IPC (cross-node pairs): t1↔t6=12, t2↔t4=12, t2↔t5=3, t3↔t5=11. Total IPC = 38
Total Optimal Cost = 20 + 38 = 58
📌 CUTSET CONCEPT
A "cutset" is the set of edges in the task communication graph between the n1-group and n2-group. IPC
cost = sum of communication costs along cutset edges. Optimal assignment minimizes: Total Execution
Cost + Sum of Cutset Edge Costs.
Load Balancing Approach
Load balancing tries to EQUALIZE the workload across ALL nodes by transparently transferring processes from
heavily loaded nodes to lightly loaded ones. Goals: (1) Optimize resource use, (2) Maximize throughput, (3)
Minimize response time, (4) Avoid overload of any single resource.
[ DIAGRAM: Load Balancing Algorithm Taxonomy Tree: Root: Load Balancing Algorithms ├── STATIC
(ignores current state) │ ├── Deterministic │ └── Probabilistic └── DYNAMIC (uses current state) ├──
Centralized └── Distributed ├── Cooperative └── Non-Cooperative ]
✏️ Draw this diagram in your exam answer
📌 EXAM TIP
These 6 policies are a very common 10-mark question. Cover all 6 with diagrams/examples.
Policy 1: Load Estimation Policy
Determines HOW to measure the workload of a node. Options:
● Total number of processes on the node (most common).
● Resource demands of running processes (CPU %, memory usage).
● Instruction mixes — types of instructions being executed.
● Architecture and speed of the node's processor.
● CPU Utilization: Set a timer to periodically check if CPU is idle or busy. Utilization = CPU cycles executed /
total real time.
Memoryless Method All processes assumed to have the When no history is available
same expected remaining service
time, regardless of time used so
far.
Past Repeats Method Remaining service time = time When patterns repeat (batch jobs)
already used (assumes behavior
repeats).
Distribution Method If service time distribution is When distribution is known a
known, uses expected remaining priori
time conditioned on time used.
Static Threshold Each node has a PREDEFINED fixed Cannot adapt to changing
threshold based on processing conditions.
capability.
Dynamic Threshold Threshold = Average workload of Higher overhead to compute.
all nodes × a predefined constant
(relative to node capability).
[ DIAGRAM: Single Threshold vs Double Threshold (High-Low Policy) Single Threshold: OVERLOADED
──────────── ← Threshold UNDERLOADED Problem: Node can rapidly flip between states →
THRASHING Double Threshold (High-Low): OVERLOADED → Send out local processes, reject incoming
remote processes ────────────── ← HIGH MARK NORMAL → Local processes run locally, reject
remote processes ────────────── ← LOW MARK UNDERLOADED → Local processes run locally,
ACCEPT remote processes Benefit: "Normal" buffer zone prevents instability ]
✏️ Draw this diagram in your exam answer
📌 KEY RULE
Single threshold → unstable (thrashing). Double threshold → stable (hysteresis buffer zone called
"Normal" region prevents rapid state flipping).
Threshold (Random Select a random node. If Simple to implement. May need many probes;
Probe) it can accept, transfer. If probe limit may be
rejected, try another. reached without finding
Continue until probe suitable node.
limit.
Shortest Method Choose m distinct Better accuracy than Higher overhead (m polls
random nodes, poll each random. needed).
for its load, send to the
one with MINIMUM
load. Stop early if a zero-
load node is found.
Bidding Method Nodes act as MANAGERS Full autonomy; best offer High communication
(senders) and selected. overhead; pricing policy
CONTRACTORS hard to define.
(receivers). Manager
broadcasts bid request;
contractors respond with
bids; manager picks best
offer.
Pairing Each node randomly Simple; reduces load Only pairwise balancing,
picks another to pair variance between pairs. not global.
with. Two nodes with
very different loads swap
processes. Pair breaks
when done.
Periodic Broadcast Each node broadcasts state info Heavy traffic; many messages are
after every T time units (fixed fruitless (state may not have
interval). changed).
Broadcast When State Changes Broadcast only when a process Better; still generates traffic if
ARRIVES or DEPARTS. Improved: processes arrive/depart
broadcast only when state crosses frequently.
a threshold boundary.
Policy Description Problem
Uncontrolled Policy Remote process arriving at a node Risk: Process thrashing — keeps
is treated exactly like a local migrating endlessly.
process. Can migrate unlimited
times.
Controlled Policy Migration count parameter limits Avoids instability. Short processes:
migration frequency. • Irrevocable k=1. Long processes: k>1.
Migration: count = 1 (migrate only
once). • For long-execution: count
= k (some limit k > 1).
📌 KEY DIFFERENCE
Load Balancing = Equalize workload on ALL nodes (complex, high overhead, impractical to perfect). Load
Sharing = Just ensure NO node is idle when others are busy (simpler, low overhead, achievable).
Process Migration
Process migration is the relocation of a process from its source node to another destination node. The most
common application is in computer clusters where processes are moved from machine to machine for load
balancing or fault tolerance.
Non-Preemptive (Eager) BEFORE execution starts LOW — no execution Only process code and
at source node. state to transfer. initial data.
Preemptive DURING execution HIGH — entire process Code + Data + Stack +
(process is running and environment must Execution State + Open
gets moved). transfer. Files + Register values.
📌 EXAM NOTE
Preemptive migration is MORE COSTLY because the process state (memory, stack, open file handles,
register state) becomes much more complex after execution begins. The full "process environment"
must accompany the process to the new node.
Steps in Process Migration
Step Responsibility Description
Step 1: Select process for Migration Policy Identify which process should be
migration migrated (based on load, type,
priority).
Step 2: Select destination node Migration Policy Find the best target node — least
loaded, sufficient resources.
Step 3: Transfer the process Migration Mechanism Actually move — freeze, transfer
address space, restart at
destination.
Code Migration
Code migration refers to the transfer of program code (not necessarily an entire running process) from one node
to another, with the intention to have that code executed at the target node.
Code Segment The actual set of instructions Python script, compiled Java
being executed — the program bytecode, binary executable.
code itself.
Resource Segment References to external resources Reference to TCP port 8080;
Segment Contents Example
What transfers? Code segment + initialized data Code + Execution segment (data,
only. stack, PC, registers).
Execution starts from? ALWAYS from beginning (fresh Exactly where it LEFT OFF at
start). source.
Execution state preserved? No. Yes.
Cost Low. High.
Example Java Applets (downloaded, run Process migration in HPC/cluster
fresh in browser). computing.
Heterogeneous system support Easy — just recompile code. Hard — must also migrate
execution stack.
Sender-Initiated Machine WHERE code Uploading a search Both strong and weak
currently resides initiates program to a DB server; mobility.
the transfer. uploading to a compute
server.
Receiver-Initiated TARGET machine takes Java applets downloaded Both strong and weak
the initiative to fetch the by web browser; mobility.
code. JavaScript fetched from
server.
📌 CAKE ANALOGY
Executing a task = Baking a cake. Code (Know-How) = Recipe. Movable Resources (RC) = Ingredients.
Non-movable Resources = Oven. Computational Component (CC) = Person to bake. All elements must
be co-located at the SAME site to bake the cake (execute the service).
[ DIAGRAM: Mobile Code Paradigms — What Moves?
┌─────────────────┬───────────────────────────────────────────────────┐ │ Client-Server │
NOTHING moves. ││ CS │ A: request ──────────────────────────────► B
││ │ A: result ◄────────────────────────────── B │
├─────────────────┼───────────────────────────────────────────────────┤ │ Remote Eval REV
│ CODE moves A → B. Server executes at B. ││ │ A: Code
──────────────────────────────────► B │ │ │ A: result
◄────────────────────────────── B │
├─────────────────┼───────────────────────────────────────────────────┤ │Code on Demand
│ CODE moves B → A. Client executes at A. ││ CoD │ A: request
──────────────────────────────► B │ │ │ A: code
◄───────────────────────────────── B │
├─────────────────┼───────────────────────────────────────────────────┤ │ Mobile Agent │
ENTIRE agent moves A → B → C. ││ MA │ [Code+Data+State] ─────────────────► B
────► C │ └─────────────────┴───────────────────────────────────────────────────┘ ]
✏️ Draw this diagram in your exam answer
Client-Server (CS) NOTHING moves. Client Request A→B, Result Traditional HTTP web
sends request, server B→A request/response.
executes, returns result.
Remote Evaluation (REV) Code (Recipe) moves Code A→B, executed at Client sends query
FROM client TO server. B program to DB server to
Server executes with its run there.
own resources.
Code on Demand (CoD) Code (Recipe) moves Code B→A, executed at Java Applets, JavaScript.
FROM server TO client. A
Client executes locally.
Mobile Agent (MA) ENTIRE agent (Code + Agent moves A→B→C Autonomous web
Data + Execution State) crawlers; search agents
moves from site to site that travel to data
autonomously. sources.
📌 KEY CHALLENGE
When code migrates, its resource segment contains references to external resources. These references
may no longer be valid at the new location. How to handle them depends on the TYPE of binding (by
identifier, by value, or by type).
file inode.
Binding by Value Only the CONTENT/VALUE Standard libraries (math, datetime
matters. Any resource providing in Python) — content matters, not
the same value works; location the exact file path.
can differ.
Binding by Type Only needs a resource of a References to local devices: needs
SPECIFIC TYPE — any instance of "a printer" (not a specific one);
that type at destination will do. needs "a display screen".
Legend: GR = Global Reference | MV = Move resource | CP = Copy resource | RB = Rebind to local resource
For n CPU types: Need n×(n−1) pieces of translation software to handle all source-destination pairs → O(n²)
complexity.
Solution — External Data Representation (XDR/ASN.1): Use a standard intermediate representation. Each node
converts TO and FROM the standard form. Reduces complexity from O(n²) to O(n) — only 2 conversion
programs per CPU type.
[ DIAGRAM: Translation without External Representation (n=4 CPU types): CPU1 ──► 3 conversions to
──► CPU2, CPU3, CPU4 CPU2 ──► 3 conversions to ──► CPU1, CPU3, CPU4 CPU3, CPU4 similarly Total
= 4×3 = 12 conversion programs Translation WITH External Representation (XDR): CPU1 ──► XDR format
──► CPU2, CPU3, CPU4 Each CPU needs only 2 programs: (to XDR) and (from XDR) Total = 4×2 = 8
programs (much less for large n) ]
✏️ Draw this diagram in your exam answer
Thread Models
Introduction to Deadlocks
A deadlock occurs when a set of processes are permanently blocked, each waiting for resources held by others,
and none can make progress.
📌 EXAM TIP
Deadlock occurs IF AND ONLY IF ALL FOUR conditions hold simultaneously. Breaking even ONE
condition prevents deadlock.
1. Mutual Exclusion Only ONE process can use a Allow resource sharing where
resource at a time. Resources possible.
cannot be shared concurrently.
2. Hold and Wait A process HOLDING resources is Require processes to request ALL
WAITING for additional resources resources at once before starting
currently held by others. (Collective Request).
3. No Preemption A resource can ONLY be released Allow preemption — forcibly take
VOLUNTARILY by the holding resources from blocked processes.
process after task completion.
4. Circular Wait A circular chain: P0 waits for P1, Impose total ordering —
P1 waits for P2, ..., Pn waits for P0. processes must request resources
in increasing order (Ordered
Request).
Resource Deadlock Two or more processes P1 holds R1, waits for R2. AND Model
wait PERMANENTLY for P2 holds R2, waits for R1.
resources held by each Both wait forever.
other. Each holds some
resources while waiting
for more.
Communication Processes wait for P1 waits for message OR Model
Deadlock messages from each from P2. P2 waits from
other but none can send P3. P3 waits from P1. All
because all are waiting. idle forever.
No messages are in
transit.
📌 AND Condition
A process can proceed ONLY when it has acquired ALL of its requested resources simultaneously. All
requests must be satisfied before the process can continue.
OR Model
📌 OR Condition
A process can proceed when it has acquired AT LEAST ONE of its requested resources. Any single
request being satisfied is enough for the process to continue.
📌 KNOT DEFINITION
A knot K is a set of nodes in the WFG such that: for EVERY node "a" in K, ALL nodes reachable from "a"
are EXACTLY the nodes in K and ONLY those nodes. Once inside a knot, you can NEVER ESCAPE — all
paths lead back into K with no exit to external nodes.
[ DIAGRAM: AND Model vs OR Model — Same WFG, Different Outcomes WFG: P11 ─► P21 ─► P24 ─►
P54 ▲ │ └──────────────────────┘ (cycle) P44 ─► P24 (depends on cycle member)
P33 ─► P32 (external to cycle) P32 ─► P11 (connects to cycle) AND Model Analysis: Cycle:
P11→P21→P24→P54→P11 → DEADLOCK (AND) P44 depends on P24 (deadlocked) → P44 is ALSO
deadlocked Even though P44 is not in the cycle! OR Model Analysis: Same cycle exists, but: P33 is NOT
in the cycle. When P33 finishes: → P32 gets unblocked (only ONE of its OR requests needs to be satisfied)
→ After P32 finishes, P11 can proceed (one request satisfied) → Cycle exists but NO DEADLOCK (escape
path through P33 exists) Therefore: cycle ≠ deadlock in OR model ]
✏️ Draw this diagram in your exam answer
Deadlock Handling Strategies
Strategy Core Idea Techniques
Key Terminologies
Term Definition
Data Structure
● Boolean array dependent_i[0..n-1] maintained by EACH SITE.
● Initially: dependent_i[j] = FALSE for all i and j.
● Meaning: dependent_i[j] = TRUE means process Pj is dependent on process Pi (according to information
available at Pi's home site).
Algorithm Steps
[ DIAGRAM: CMH Algorithm — Flowchart Step 1: INITIATION Blocked process Pi wants to check for
deadlock: FOR EACH process Pj that Pi is waiting for: SEND probe(i, i, j) to home site of Pj Step 2:
RECEIVING probe(i, j, k) at site of Pk IF (Pk is BLOCKED) AND (dependent_k[j] == FALSE): SET
dependent_k[j] = TRUE IF (k == i): ← PROBE RETURNED TO INITIATOR! → DEADLOCK
DETECTED! Pi declares itself deadlocked. ELSE: FOR EACH process Pm that Pk is waiting for:
SEND probe(i, k, m) to home site of Pm (If Pk is NOT blocked OR dependent_k[j] already TRUE: DISCARD
probe) ]
✏️ Draw this diagram in your exam answer
SOLVED EXAMPLE — CMH Algorithm (From Professor's Slides)
📌 SETUP
3 machines, 9 processes. Machine 0: P0, P4, P6. Machine 1: P1, P2, P3, P8. Machine 2: P5, P7. Wait
relationships: P0 waits for P4 AND P2 | P2 waits for P3 | P4 waits for P6 | P6 waits for P8 (cross-site) |
P8 waits for P0 (forms cycle back to initiator).
📌 DEADLOCK RESOLUTION
Strategy 1 (Naive): Initiating process (P0) commits suicide. Problem: Multiple processes might
simultaneously initiate probes → all commit suicide ("overkilling"). Strategy 2 (Better): Each process
APPENDS ITS OWN ID to the probe as it travels. When probe returns to initiator, it has IDs of ALL
processes in the cycle. Kill the process with the HIGHEST process ID. All concurrent probes will agree on
the SAME victim, so only ONE process is killed.
Simple probe message (just 3 integers) + small All sites may not be fully aware of which processes
boolean array. are involved.
Very little computation required at each site. Resolving the deadlock can be difficult (choosing
which process to kill).
Low communication overhead — only edge chasing. Correctness proof is mathematically complex.
No need to construct a global WFG.
Does NOT report phantom/false deadlocks (unlike
centralized).
No single point of failure — fully distributed.
Fast detection — O(n) delay.
QUICK REVISION TABLES
Goal Equalize workload on ALL nodes Prevent any node from being idle
Complexity High Low
Overhead High (extensive state info) Low (only busy/idle status)
Threshold High-Low double threshold Single threshold = 1 (all-or-
nothing)
Is perfect balance achievable? Theoretically yes, practically no No — just prevents idleness
Concept Type Dynamic Simpler dynamic
Condition to Unblock Needs ALL requested resources Needs ANY ONE requested
resource
Deadlock Condition CYCLE in WFG KNOT in WFG
Cycle → Deadlock? YES (necessary & sufficient) NO (necessary but not sufficient)
Knot → Deadlock? YES (knot implies cycle) YES (sufficient)
Type of Deadlock Resource Deadlock Communication Deadlock
What transfers? Code + initialized data only Code + Execution state (data,
stack, PC, registers)
Starts from? BEGINNING (fresh start) Exactly where it left off
Execution state? Not preserved Preserved
Cost Low High
Example Java Applets, JavaScript Process migration in clusters
4. Mobile Code Paradigms
Paradigm What Moves Direction Example
By Identifier MV or GR GR or MV GR
By Value CP or MV or GR GR or CP GR
By Type RB or GR or CP RB or GR or CP RB or GR
Legend: GR=Global Reference | MV=Move resource | CP=Copy resource | RB=Rebind to local resource