Escolar Documentos
Profissional Documentos
Cultura Documentos
Event Ordering
■ Associate a timestamp with each system event. Require that for every pair of
events A and B, if A → B, then the timestamp of A is less than the timestamp of B.
■ Within each process Pi a logical clock, LCi is associated. The logical clock can be
implemented as a simple counter that is incremented between any two successive
events executed within a process.
■ A process advances its logical clock when it receives a message whose timestamp
is greater than the current value of its logical clock.
■ If the timestamps of two events A and B are the same, then the events are
concurrent. We may use the process identity numbers to break ties and to create a
total ordering.
2.Distributed Mutual Exclusion (DME)
■ Assumptions
✦ The system consists of n processes; each process Pi resides at a different
processor.
✦ Each process has a critical section that requires mutual exclusion.
■ Requirement
✦ If Pi is executing in its critical section, then no other process Pj is executing in
its critical section.
■ We present two algorithms to ensure the mutual exclusion execution of processes
in their critical sections.
DME: Centralized Approach
■ One of the processes in the system is chosen to coordinate the entry to the critical
section.
■ A process that wants to enter its critical section sends a request message to the
coordinator.
■ The coordinator decides which process can enter the critical section next, and its
sends that process a reply message.
■ When the process receives a reply message from the coordinator, it enters its
critical section.
■ After exiting its critical section, the process sends a release message to the
coordinator and proceeds with its execution.
■ This scheme requires three messages per critical-section entry:
✦ Request
✦ reply
✦ release
■ Ifone of the processes fails, then the entire scheme collapses. This can be dealt
with by continuously monitoring the state of all the processes in the system.
■ Processes that have not entered their critical section must pause frequently to
assure other processes that they intend to enter the critical section. This protocol
is therefore suited for small, stable sets of cooperating processes.
Token-Passing Approach
■ Another method of providing mutual exclusion is to circulate a token among the
processes in the system.
■ A token is a special type of message that is passed around the system.
■ Possession of the token entitles the holder to enter the critical section.
■ Since there is only a single token, only one process can be in its critical section
at a time.
3.Concurrency Control
■ Modify the centralized concurrency schemes to accommodate the distribution of
transactions.
■ Transaction manager coordinates execution of transactions (or subtransactions)
that access data at local sites.
■ Local transaction only executes at that site.
■ Global transaction executes at several sites.
Locking Protocols
■ several
possible schemes. The first deals with the case where no data replication is
allowed. The others deals with where data can be replicated in several sites.
Nonreplicated Scheme
✦ Each site maintains a local lock manager whose function is to administer the lock
and unlock requests.
✦ When a transaction wishes to lock data item Q at site Si, it simply sends a
message to the lock manager at site S; requesting a lock
✦ Once it has been determined that the lock request can be granted, the lock
manager sends a message back to the initiator indicating that the lock request has
been granted.
✦ Simple implementation involves two message transfers for handling lock
requests, and one message transfer for handling unlock requests.
✦ Deadlock handling is more complex.
Single-Coordinator Approach
✦ the system maintains a single lock manager that resides in a single chosen site, S.
✦ All lock and unlock requests are made at site S,.
✦ When a transaction needs to lock a dataitem, it sends a lock request to S.
✦ The lock manager determines whether the lock can be granted immediately. If so,
it sends a message to the site at which the lock request was initiated.
✦ Otherwise, the request is delayed until it can be granted;
✦ The transaction can read the data item from any one of the sites at which a replica
of the data item resides.
✦ In the case of a write operation, all the sites where a replica of the data item
resides must be involved in the writing.
advantages:
o Simple implementation. requires two messages for handling lock requests and
one message for handling unlock requests.
o Simple deadlock handling. Since all lock and unlock requests are made at one
site, the deadlock-handling algorithms can be applied directly to this
environment.
The disadvantages
o Bottleneck. The site S, becomes a bottleneck, since all requests must be
processed there.
o Vulnerability. If the site S, fails, the concurrency controller is lost.
Multiple-coordinator approach distributes lock-manager function over several
sites.
Majority Protocol
■ The system maintains a lock manager at each site.
■ Eachmanager controls the locks for all the data or replicas of data stored at that
site.
■ When a transaction wishes to lock a data item Q that is replicated in n different
sites, it must send a lock request to more than one-half of the n sites in which Q is
stored.
■ Each lock manager determines whether the lock can be granted immediately. the
response is delayed until the request can be granted.
■ The transaction does not operate on Q until it has successfully obtained a lock on
a majority of the replicas
■ Disadvantages:
o Implementation. more complicated to implement .It requires 2(n/2 + 1)
messages for handling lock requests and (n/2 + 1) messages for handling
unlock requests.
o Deadlock-handling algorithms must be modified; possible for deadlock to
occur in locking only one data item.
Biased Protocol
■ Similar to majority protocol, but requests for shared locks prioritized over
requests for exclusive locks.
■ The system maintains a lock manager at each site. Each manager manages the locks for
all the data items stored at that site.
■ Shared and exclusive locks are handled differently.
■ Shared locks. When a transaction needs to lock data item Q, it simply requests a lock on
Q from the lock manager at one site containing a replica
■ Exclusive locks. When a transaction needs to lock data item Q, it requests a lock on Q
from the lock manager at each site containing a replica of
■ Lessoverhead on read operations than in majority protocol; but has additional
overhead on writes.
■ Like majority protocol, deadlock handling is complex.
Primary Copy
■ One of the sites at which a replica resides is designated as the primary site.
Request to lock a data item is made at the primary site of that data item.
■ Simple implementation, but if primary site fails, the data item is unavailable, even
though other sites may have a replica.
Timestamping
■ Two primary methods are used to generate unique timestamps; one is centralized,
and one is distributed.
■ Generate unique timestamps in distributed scheme:
✦ Each site generates a unique local timestamp.
✦ The global unique timestamp is obtained by concatenation of the unique local
timestamp with the unique site identifier
✦ Use a logical clock defined within each site to ensure the fair generation of
timestamps.