You are on page 1of 6

8/1/2023

INDIAN INSTITUTE OF TECHNOLOGY ROORKEE

Advanced Operating System


CSN-502

Time in Distributed System

Multiprocessor OS

o Design Issues
 Process synchronization
 Processor scheduling
 Memory management
 Reliability and fault tolerance

1
8/1/2023

The Critical Section Problem

• Software solutions
• Hardware support

Semaphores

P(S): If S >= 1 then S = S – 1


else block the process on the semaphore queue

V(S): If some processes are blocked on the semaphore S


then unblock a process
else S = S + 1

The Critical Section Problem

The Test-and-set instruction


function Test-and-set(var m: Boolean): Boolean;
begin
Test-and-set = m;
m = true;
end;

• P(S): while Test-and-set(S) do nothing


• V(S): S = false
4

2
8/1/2023

The Critical Section Problem


The Swap instruction
procedure swap(var x, y: boolean);
var temp: boolean;
begin
temp = x;
x = y;
y = temp;
end;

• P(S): p = true; repeat swap(S, p) until p = false;


• V(S): S = false;
5

The Critical Section Problem


The Fetch-and-Add instruction
function Fetch-and-Add(m: integer; c: integer);
var temp: integer;
begin
temp = m; m = m + c;
return (temp);
end;

• P(S): while (Fetch-and-Add(S, -1) < 0) do


begin Fetch-and-Add(S, 1) ; while (S <= 0) do nothing; end;
• V(S): Fetch-and-Add(S, 1);
6

3
8/1/2023

Design Issues (Distributed OS)


Issue 1: Time in Distributed Systems

What is a distributed system?

A collection of computers that are spatially separated and


do not share a common memory
Singhal and Shivaratri

A distributed system is a collection of independent


computers that appears to its users as a single coherent
system
Andrew S Tanenbaum

4
8/1/2023

What is a distributed system?


A practical “distributed system” will probably have both
 Processes on different computers that communicate by
messages
 Processes/threads on a computer that communicate by
messages or shared memory

A very broad definition:


A set of autonomous processes communicating among
themselves to perform a task
Autonomous: able to act independently
Communication: shared memory or message passing

Advantages
 Resource Sharing
 Increased Performance/cost ratio
 Fault Tolerance / Improved availability
 Scalability

5
8/1/2023

Inherent limitations of distributed systems


 Lack of common memory
 Absence of a global (system wide) clock
 Unpredictable communication delays

The two-army problem

---------- msg1 ------------------


---------msg2 --------------------
-------------msg 3 -------------------
---------- msg 4 --------------------
.
.

You might also like