Unit V - New
Unit V - New
• Implementing a distributed system requires cost for hardware support and agreements
on service expectations. Optimizing tasks through proper scheduling helps reduce the
overall cost of computation.
• A task is a logical unit that makes progress toward a unified goal of a system. One
such set of tasks could be images that a distributed model is learning or predicting on.
• The process of managing task allocation, to where and to who, is the responsibility of
a scheduler. The scheduler of a distributed system performs akin to the process
scheduler on any operating system
Distributed Scheduling and Deadlock Distributed Scheduling
• Scheduling tasks from the primary to workers can occur at multiple stages. There can be
global scheduler that directs all tasks to all connected workers. There can also be local
schedulers that handle incoming and outgoing tasks/replies on both the primary and worker
nodes. Organizing this dynamic scale of events is a major component of the systems
efficiency.
• Scheduling tasks from the primary to workers can occur at multiple stages. There can be
global scheduler that directs all tasks to all connected workers. There can also be local
schedulers that handle incoming and outgoing tasks/replies on both the primary and worker
nodes. Organizing this dynamic scale of events is a major component of the systems
efficiency.
The techniques that are used for scheduling the processes in distributed systems are as follows:
1. Task Assignment Approach: In the Task Assignment Approach, the user-submitted process is
composed of multiple related tasks which are scheduled to appropriate nodes in a system to
improve the performance of a system.
2. Load Balancing Approach: In the Load Balancing Approach, as the name implies, the workload
is balanced among the nodes of the system.
3. Load Sharing Approach: In the Load Sharing Approach, it is assured that no node would be idle
while processes are waiting for their processing.
Characteristics of a Good Scheduling Algorithm:
The following are the required characteristics of a Good Scheduling Algorithm:
1. The scheduling algorithms that require prior knowledge about the properties and resource
requirements of a process submitted by a user put a burden on the user. Hence, a good
scheduling algorithm does not require prior specification regarding the user-submitted
process.
2. A good scheduling algorithm must exhibit the dynamic scheduling of processes as the
initial allocation of the process to a system might need to be changed with time to balance
the load of the system.
3. The algorithm must be flexible enough to process migration decisions when there is a
change in the system load.
4. The algorithm must possess stability so that processors can be utilized optimally. It is
possible only when thrashing overhead gets minimized and there should no wastage of
time in process migration.
Characteristics of a Good Scheduling Algorithm:
5. An algorithm with quick decision making is preferable such as heuristic methods that take
less time due to less computational work give near-optimal results in comparison to an
exhaustive search that provides an optimal solution but takes more time.
6. A good scheduling algorithm gives balanced system performance by maintaining minimum
global state information as global state information (CPU load) is directly proportional to
overhead. So, with the increase in global state information overhead also increases.
7. The algorithm should not be affected by the failure of one or more nodes of the system.
Furthermore, even if the link fails and nodes of a group get separated into two or more
groups then also it should not break down. So, the algorithm must possess decentralized
decision-making capability in which consideration is given only to the available nodes for
taking a decision and thus, providing fault tolerance.
Characteristics of a Good Scheduling Algorithm:
8. A good scheduling algorithm has the property of being scalable. It is flexible for scaling
when the number of nodes increases in a system. If an algorithm opts for a strategy in
which it inquires about the workload of all nodes and then selects the one with the least
load then it is not considered a good approach because it leads to poor scalability as it will
not work well for a system having many nodes. The reason is that the inquirer receives a lot
many replies almost simultaneously and the processing time spent for reply messages is too
long for a node selection with the increase in several nodes (N). A straightforward way is to
examine only m of N nodes.
9. A good scheduling algorithm must be having fairness of service because in an attempt to
balance the workload on all nodes of the system there might be a possibility that nodes with
more load get more benefit as compared to nodes with less load because they suffer from
poor response time than stand-alone systems. Hence, the solution lies in the concept of load
sharing in which a node can share some of its resources until the user is not affected.
Load Balancing in Distributed Systems:
The Load Balancing approach refers to the division of load among the processing elements of
a distributed system. The excess load of one processing element is distributed to other
processing elements that have less load according to the defined limits. In other words, the
load is maintained at each processing element in such a manner that neither it gets overloaded
nor idle during the execution of a program to maximize the system throughput which is the
ultimate goal of distributed systems. This approach makes all processing elements equally
busy thus speeding up the entire task leads to the completion of the task by all processors
approximately at the same time.
Types of Load Balancing Algorithms:
• Static Load Balancing Algorithm: In the Static Load Balancing Algorithm, while distributing
load the current state of the system is not taken into account. These algorithms are simpler in
comparison to dynamic load balancing algorithms. Types of Static Load Balancing Algorithms
are as follows:
• Deterministic: In Deterministic Algorithms, the properties of nodes and processes are taken
into account for the allocation of processes to nodes. Because of the deterministic
characteristic of the algorithm, it is difficult to optimize to give better results and also costs
more to implement.
• Probabilistic: Probabilistic Algorithms, Statistical attributes of the system are taken into
account such as several nodes, topology, etc. to make process placement rules. It does not
give better performance.
Types of Load Balancing Algorithms:
Dynamic Load Balancing Algorithm: Dynamic Load Balancing Algorithm takes into account the current
load of each node or computing unit in the system, allowing for faster processing by dynamically
redistributing workloads away from overloaded nodes and toward underloaded nodes. Dynamic
algorithms are significantly more difficult to design, but they can give superior results, especially when
execution durations for distinct jobs vary greatly. Furthermore, because dedicated nodes for task
distribution are not required, a dynamic load balancing architecture is frequently more modular. Types of
Dynamic Load Balancing Algorithms are as follows:
• Centralized: In Centralized Load Balancing Algorithms, the task of handling requests for process
scheduling is carried out by a centralized server node. The benefit of this approach is efficiency as all
the information is held at a single node but it suffers from the reliability problem because of the lower
fault tolerance. Moreover, there is another problem with the increasing number of requests.
• Distributed: In Distributed Load Balancing Algorithms, the decision task of assigning processes is
distributed physically to the individual nodes of the system. Unlike Centralized Load Balancing
Algorithms, there is no need to hold state information. Hence, speed is fast.
Types of Load Balancing Algorithms:
Cooperative In Cooperative Load Balancing Algorithms, as the name implies, scheduling
decisions are taken with the cooperation of entities in the system. The benefit lies in the stability
of this approach. The drawback is the complexity involved which leads to more overhead than
Non-cooperative algorithms.
2. Process Transfer Policies: Decides for the execution of process: local or remote.
3. State Information Exchange: Determination of strategy for exchanging system load information
among the nodes in a distributed system.
4. Location Policy: Determining the selection of destination nodes for the migration of the process.
5. Priority Assignment: Determines whether the priority is given to a local or a remote process on a
node for execution.
6. Migration limit policy: Determines the limit value for the migration of processes.
Gang scheduling
In computer science, gang scheduling is a scheduling algorithm for parallel systems that
schedules related threads or processes to run simultaneously on different processors.
A gang means a task. So, gang scheduling is the scheduling of gangs in an efficient
manner. The point which separates gang scheduling from other scheduling is that it
considers a gang (task) as a quantum and schedules them. A gang might require either
multiple processes or threads or a combination of both (threads and processes).
Gang scheduling uses an Out sterhout matrix as a data
structure to facilitate all the scheduling tasks. It is a
two-dimensional matrix where a row represents a time
slice and a column represents a process or a thread.
P1 P2 P3 P4 P5
Gang Time Slice 0 J1 J1 J1 J1 J1
Time Slice 1 J2 J2 J2 J2 J2
scheduling
Time Slice 2 J3 J3 J4 J4 J4
Each process executes on a single processor, and the processors do not share memory.
Each process pi in has a state si that, in general, it transforms as it executes. The process’s state
includes the values of all the variables within it. Its state may also include the values of any
objects in its local operating system environment that it affects, such as files. We assume that
processes cannot communicate with one another in any way except by sending messages through
the network.
We define an event to be the occurrence of a single action that a process carries out as it executes
– a communication action or a state-transforming action. The sequence of events within a single
process pi can be placed in a single, total ordering, which we denote by the relation i between the
events.
CLOCKS, EVENTS AND PROCESS STATES
we have assumed that the process executes on a single processor. Now we can define the
history of process pi to be the series of events that take place within it, ordered as we have
described by the relation Clocks • We have seen how to order the events at a process, but not
how to timestamp them – i.e., to assign to them a date and time of day. Computers each
contain their own physical clocks. These clocks are electronic devices that count oscillations
occurring in a crystal at a definite frequency, and typically divide this count and store the
result in a counter register. Clock devices can be programmed to generate interrupts at regular
intervals in order that, for example, time slicing can be implemented; however, we shall not
concern ourselves with this aspect of clock operation.
Logical time and logical clocks
Logical local time is used by the process to mark its own events, and logical global time
is the local information about global time. A special protocol is used to update logical
local time after each local event, and logical global time when processes exchange data.
List of Time Zones and Abbreviations
Name Description Relative to GMT
GMT Greenwich Mean Time GMT
UTC Universal Coordinated Time GMT
ECT European Central Time GMT+1:00
EET Eastern European Time GMT+2:00
ART (Arabic) Egypt Standard Time GMT+2:00
EAT Eastern African Time GMT+3:00
MET Middle East Time GMT+3:30
NET Near East Time GMT+4:00
PLT Pakistan Lahore Time GMT+5:00
IST India Standard Time GMT+5:30
BST Bangladesh Standard Time GMT+6:00
VST Vietnam Standard Time GMT+7:00
CTT China Taiwan Time GMT+8:00
JST Japan Standard Time GMT+9:00
ACT Australia Central Time GMT+9:30
AET Australia Eastern Time GMT+10:00
SST Solomon Standard Time GMT+11:00
Logical time and logical clocks
If we go outside then we have made a full plan that at which place we have to
go first, second and so on. We don’t go to second place at first and then the
first place. We always maintain the procedure or an organization that is
planned before. In a similar way, we should do the operations on our PCs one
by one in an organized way.
The global state of a distributed system is the set of local states of each
individual processes involved in the system plus the state of the
communication channels.
Agreement may be as simple as the goal of the distributed system, This is made more
complicated than it sounds, since all the processes must, not only agree, but be
confident that their peers agree.
Distributed mutual exclusion
Mutual exclusion is a concurrency control property which is introduced to prevent race
conditions. It is the requirement that a process can not enter its critical section while another
concurrent process is currently present or executing in its critical section i.e only one process
is allowed to execute the critical section at any given instance of time.
Mutual exclusion ensures that concurrent access of processes to a shared resource or data is
serialized, that is, executed in a mutually exclusive manner. Mutual exclusion in a distributed
system states that only one process is allowed to execute the critical section (CS) at any given
time.
Mutual exclusion in single computer
system Vs. distributed system:
In single computer system, memory and other resources are shared between different processes. The
status of shared resources and the status of users is easily available in the shared memory so with the
help of shared variable (For example: Semaphores) mutual exclusion problem can be easily solved.
In Distributed systems, we neither have shared memory nor a common physical clock and there for we
can not solve mutual exclusion problem using shared variables. To eliminate the mutual exclusion
problem in distributed system approach based on message passing is used.
Solution to distributed mutual exclusion
Token Based Algorithm
• If a site possesses the unique token, it is allowed to enter its critical section
• This approach uses sequence number to order requests for the critical section.
• Each requests for critical section contains a sequence number. This sequence number is used to
distinguish old and current requests.
• Instead of requesting permission to execute the critical section from all other sites,
Each site requests only a subset of sites which is called a quorum.
• Pre-acquisition of locks requires a long time for communication delays. This increases the time required for
transaction.
• In case of site or link failure, a transaction has to wait for a long time so that the sites recover. Meanwhile, in the
running sites, the items are locked. This may prevent other transactions from executing.
• If the controlling site fails, it cannot communicate with the other sites. These sites continue to keep the locked data
items in their locked state, thus resulting in blocking.
Distributed Deadlock Prevention
Collective Requests:
In this strategy, all the processes will declare the required resources for their execution
beforehand and will be allowed to execute only if there is the availability of all the
required resources. When the process ends up with processing then only resources will be
released. Hence, the hold and wait condition of deadlock will be prevented. But the issue
is initial resource requirements of a process before it starts are based on an assumption
and not because they will be required. So, resources will be unnecessarily occupied by a
process and prior allocation of resources also affects potential concurrency.
Distributed Deadlock Prevention
Ordered Requests:
• In this strategy, ordering is imposed on the resources and thus, process requests for resources in increasing order. Hence,
the circular wait condition of deadlock can be prevented.
• An ordering strictly indicates that a process never asks for a low resource while holding a high one.
• There are two more ways of dealing with global timing and transactions in distributed systems, both of which are based
on the principle of assigning a global timestamp to each transaction as soon as it begins.
• During the execution of a process, if a process seems to be blocked because of the resource acquired by another process
then the timestamp of the processes must be checked to identify the larger timestamp process. In this way, cycle waiting
can be prevented.
• It is better to give priority to the old processes because of their long existence and might be holding more resources.
• It also eliminates starvation issues as the younger transaction will eventually be out of the system
Distributed Deadlock Prevention
Ordered Requests:
• In this strategy, ordering is imposed on the resources and thus, process requests for resources in increasing order.
Hence, the circular wait condition of deadlock can be prevented.
• An ordering strictly indicates that a process never asks for a low resource while holding a high one.
• There are two more ways of dealing with global timing and transactions in distributed systems, both of which
are based on the principle of assigning a global timestamp to each transaction as soon as it begins.
• During the execution of a process, if a process seems to be blocked because of the resource acquired by another
process then the timestamp of the processes must be checked to identify the larger timestamp process. In this
way, cycle waiting can be prevented.
• It is better to give priority to the old processes because of their long existence and might be holding more
resources.
• It also eliminates starvation issues as the younger transaction will eventually be out of the system
Distributed Deadlock Prevention
Preemption: