Daa Unit-Vi
Daa Unit-Vi
Case Studies
Outline
Distributed Operating System
Things(IOT)
Software Engineering
Distributed Operating Systems
Bully Algorithms
Process Termination(Diskstra
Scolten)
Election Algorithms
5
The Bully Algorithm
8
Distributed Operating Systems
Bully Algorithms
Process Termination(Diskstra
Scolten)
All Pair shortest path Algorithm
Algorithm All Pair shortest path (W,A)
{
for i= 1 to n do { for j= 1 to n do {
A[i,j] =W[i,j] }
For k=1 to n do{ For i= 1 to n do{
for j= 1 to n do{
A[i,j]=min (A[i,j],A[i,k]+A[k,j]);
}
}
}
}
Example
2
4 D(0) W
3
0 31 8 ∞2 -4
1
8
1 3 2
∞ 0 ∞ 13 7
4
2
3 ∞ 4 0 ∞5 ∞
-4
1 -5 4 2 ∞ -5 0 ∞
7 5 ∞ ∞ ∞ 6 0
5 4
6
Example
2
4 D(1)
3
0 31 8 ∞2 -4
1
8
1 3 2
∞ 0 ∞ 13 7
2 4
3 ∞ 4 0 ∞5 ∞
-4
1 -5 4 2 5 -5 0 -2
7 5 ∞ ∞ ∞ 6 0
5 4
6
Example
2
4 D(2)
3 1 2 3 4 5
0 3 8 4 -4
1
1 8
3 2
∞ 0 ∞ 1 7
2
3 ∞ 4 0 5 11
-4
1 -5 4 2 5 -5 0 -2
7 5 ∞ ∞ ∞ 6 0
5 4
6
Example
2
4 D(3)
3 1 2 3 4 5
0 3 8 4 -4
1
1 8
3 2
∞ 0 ∞ 1 7
2
3 ∞ 4 0 5 11
-4
1 -5 4 2 -1 -5 0 -2
7 5 ∞ ∞ ∞ 6 0
5 4
6
Example
2
4 D(4)
3 1 2 3 4 5
0 3 -1 4 -4
1
1 8
3 2
3 0 -4 1 -1
2
3 7 4 0 5 3
-4
1 -5 4 2 -1 -5 0 -2
7 5 8 5 1 6 0
5 4
6
Time complexity analysis
Bully Algorithms
Process
Termination(Diskstra
Scolten)
Distributed Process Termination-
Introduction
A fundamental problem: To determine if a
distributed computation has terminated.
A non-trivial task since no process has
complete knowledge of the global state, and
global time does not exist.
A distributed computation is globally
terminated if every process is locally terminated
and there is no message in transit between any
processes.
“Locally terminated” state is a state in which a
process has finished its computation and will not
restart any action unless it receives a message.
In the termination detection problem, a
particular process (or all of the processes) must
infer when the underlying computation has
terminated.
Distributed Process Termination-
System Model
At any given time, a process can be in only one of
the two states: active, where it is doing local
computation and idle, where the process has
(temporarily) finished the execution of its local
computation and will be reactivated only on the
receipt of a message from another process.
An active process can become idle at any time.
An idle process can become active only on the
receipt of
a message from another process.
Only active processes can send messages.
A message can be received by a process when the
process is in either of the two states, i.e., active or
idle. On the receipt of a message, an idle process
becomes active.
The sending of a message and the receipt of a
message occur as atomic actions.
Termination detection algorithm
[Dijkstra, Scholten]
Simple stable property detection problem.
Connected, undirected network graph G = (V,E).
Assume:
Algorithm A begins with all nodes quiescent (only inputs enabled).
An input arrives at exactly one node.
Starting node need not be predetermined.
From there, computation can “diffuse” throughout
the network, or a portion of the network.
• At some point, the entire system may become quiescent:
– No non-input actions enabled at any node.
– No messages in channels.
• Termination Detection problem:
– If A ever reaches a quiescent state then the starting node should
eventually output “done”.
– Otherwise, no one ever outputs “done”.
• To be solved by a monitoring algorithm Mon(A).
Dijkstra, Scholten Algorithm
Augment A with extra pieces that construct and maintain a tree, rooted
at the starting node, and including all the nodes currently active in A.
Grows, shrinks, grows,…as nodes become active, quiescent, active,…
Algorithm:
Execute A as usual, adding acks for all messages.
Messages of A treated like search messages in AsynchSpanningTree.
When a process receives an external input, it becomes the root, and begins
executing A.
When any non-root process receives its first A message, it designates the
sender as its parent in the tree, and begins participating in A.
Root process acks every message immediately.
Other processes ack all but the first message immediately.
Convergecast for termination:
If a non-root process finds its A-state quiescent and all its A-messages acked, then
it cleans up: acks the first A-message, deletes all info about the termination
protocol, becomes idle.
If it later receives another A message, it treats it like the first A message (defines a
new parent, etc.), and resumes participating in A.
If root process finds A-state quiescent and all A-messages acked, reports done.
Example
First, p1 gets awakened by an external A input, 1
becomes the root, sends A messages to p2 and
p4, p2 sends an A-message to p3, all set up
parent pointers and start executing A. 5 2
Next, p4 sends A message to p3, acked
immediately.
p4 sends A message to p1, acked immediately. 4 3
p1, p2, p3, and p4 send A messages to each other
for a while, everything gets acked immediately.
Tree remains unchanged. 1
Next, p2 and p3 quiesce locally; p3 cleans up,
sends ack to p2, p2 receives ack, p2 cleans up, 2
sends ack to p1. 5
Next, p4 sends A messages to p2, p3, and p5,
yielding a new tree:
Etc. 4 3
Complexity
Messages:
2m, where m is the number of messages sent in A.
Time from quiescence of A until output
“done”:
O( m d ), where d = upper bound on message
delay, ignore local processing time
Time to clean up the spanning tree.
Bounds are most interesting if m << n.
E.g., algorithms that involve only a limited
computation in a small portion of a large network.
Outline
Distributed Operating System
Things(IOT)
Software Engineering
Variable Size Partitions
Idea
Allocate memory in small units
Give each job as many units as it needs
A B C D E
Key Challenges
Keep track of free / allocated memory
regions
Allocation policy to assign free regions to
jobs 2
5
Malloc: Dynamic Allocation
Idea
Allocate memory in small units
Give each request as many units as it needs
A B C D E
Key Challenges
Keep track of free / allocated memory regions
Allocation policy to assign free regions to
objects
2
6
Storage Allocation Policies
First fit
Use first hole whose size is large enough
Rationale?
Best fit
Use first exact size or smallest hole that is
larger
Rationale?
Worst fit
Use the largest available hole
Rationale?
2
7
Storage Allocation Policies
Best fit
Produces the smallest leftover hole
Creates small holes that cannot be used
Worst Fit
Produces the largest leftover hole
Difficult to run large programs
First Fit
Creates average size holes
1
7
Fragmentation
Internal Fragmentation
Allocated memory may be larger than
requested memory
The extra memory is internal to a
1
9
Binary Buddy Allocator
2
2
Binary Buddy System
Approach
Minimum allocation size = smallest frame
Use a bitmap to monitor frame use
Maintain freelist for each possible frame
size
power of 2 frame sizes from min to max
Initially one block = entire buffer
If two neighboring frames (“buddies”) are
free, combine them and add to next
larger freelist 23
Buddy System Example
128 Free
2
4
Buddy System Example
Process A requests
16
128 Free
64 Free 64 Free
2
5
Buddy System Example
Process B requests 32
16 A 16 Free 3232Free
B Free 64 Free
128
2
6
Buddy System Example
Process C requests 8
16 A 8 8 32 B 64 Free
C
2
7
Buddy System Example
Process A
exits
16 Free 8 8 32 B 64 Free
C
2
8
Buddy System Example
Process C exits
16 Free 8 8 32 B 64 Free
32 Free 32 B 64 Free
2
9
Buddy System: Tradeoffs
Advantages
Very fast search for Best Fit allocation policy
Fast compaction
Minimizes external fragmentation
Disadvantage
Internal fragmentation when not 2^n request
3
0
Outline
Distributed Operating System
Embedded Systems
Internet Of Things(IOT)
Software Engineering
Embedded Systems
Introduction
Scheduling in Embedded
Systems
42
Definition Embedded system
An embedded system is a computer system
with a dedicated function within a larger
mechanical or electrical system, often with real-
time computing constraints.
It is embedded as part of a complete device
often including hardware and mechanical parts.
Embedded systems control many devices in
common use today.
What an embedded system is NOT.
Not a computer system that is used primarily for
processing.
Not a software system on a PC or Unix box.
Not a traditional business or scientific application.
44
Examples of Embedded Systems
Automotive systems:
Medical instrument‟s
electronic
controls:
dashboards, ABS brakes,
CAT scanners,
transmission controls.
implanted heart
monitors, etc.
46
Embedded Systems
Introduction
Scheduling in Embedded
Systems