Mobile Computing Report
Mobile Computing Report
UNIVERSITY
1
Mutual Exclusion
• No Deadlock : Two or more site should not endlessly wait for any message
that will never arrive.
• No Starvation : Every site who wants to execute critical section should get
an opportunity to execute it in finite time. Any site should not wait
indefinitely to execute critical section while other site are repeatedly
executing critical section
• Fairness : Each site should get a fair chance to execute critical section. Any
request to execute critical section must be executed in the order they are
made i.e. Critical section execution requests should be executed in the order
of their arrival in the system.
2
Solution to distributed mutual Exclusion
As we know shared variables or a local kernel can not be used to implement
mutual exclusion in distributed systems. Message passing is a way to implement
mutual exclusion. Below are the three approaches based on message passing to
implement mutual exclusion in distributed systems:
• 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.
• When ever a site make request for critical section, it gets a timestamp.
Timestamp is also used to resolve any conflict between critical section
requests.
3
• All algorithm which follows non-token based approach maintains a logical
clock. Logical clocks get updated according to Lamport’s scheme
In this algorithm:
• A site send a REQUEST message to all other site to get their permission
to enter critical section.
4
• A site send a REPLY message to requesting site to give its permission to
enter the critical section.
• A site send a RELEASE message to all other site upon exiting the critical
section.
• Every site Si, keeps a queue to store critical section requests ordered by
their timestamps. request_queuei denotes the queue of site Si
Algorithm:
To enter Critical section
• When a site Sj receives the request message REQUEST(tsi, i) from site Si,
it returns a timestamped REPLY message to site S i and places the request
of site Si on request_queuej
5
• When a site Sj receives the timestamped RELEASE message from site Si,
it removes the request of Si from its request queue
Message Complexity
Lamport’s Algorithm requires invocation of 3(N – 1) messages per critical
section execution. These 3(N – 1) messages involves
• (N – 1) request messages
• (N – 1) reply messages
• (N – 1) release messages
Performance:
• Synchronization delay is equal to maximum message transmission time
• It requires 3(N – 1) messages per CS execution.
• Algorithm can be optimized to 2(N – 1) messages by omitting
the REPLY message in some situations.