Text Preview

Abstract

This paper problem and solution comparison is based on two journal paper in the area of computer science. The topic is about the problem of mutual-exclusion and the solutions given by Leslie Lamport and Gary L. Peterson. 1. Introduction

Leslie Lamport are responsible for many ground breaking result so mutual exclusion problem. Lamport was the first to notice the circular reasoning inherent in shared memory mutual exclusion algorithms that require atomic instruction. He shows that atomic reads and writes can be implemented from non-atomic reads and writes without mutual exclusion. Lamport also initiated the study of mutual exclusion algorithm that “fast” in the action of contention. He is also responsible for the first fully distributed solution for the mutual exclusion problem. The algorithm he used presented is a paper that also introduces logical clocks and state machines. Gary L. Peterson introduce the algorithm that much simpler than other algorithm. 2. Problem statement

Mutual exclusion algorithms are used to resolve conflicting accesses to shared resources by asynchronous, concurrent processes. A process accesses the resource to be managed by executing a “critical section” of code. Before and after executing its critical section, a process executes two other code fragments, called “entry" and “exit" sections, respectively. A process may stop within its non-critical section but not within its critical section. The objective is to design the entry and exit sections so that the following requirements hold. Exclusion; at most one process executes its critical section at any time. Starvation-freedom; if some process is in its entry section, then that process eventually executes its critical section. 3. Method used to solve problem

3.1 Leslie Lamport have introduces many works on mutual exclusion and has focused on “user-level” algorithm for shared memory based on either atomic or non-atomic reads or writes. He has introduces a more structured solution that is his famous bakery algorithm. The bakery algorithm has implications that stretch well beyond the mutual exclusion problem. The bakery algorithm is based upon a simple situation often used in bakery stores. A customer entering the bakery chooses a number; within the bakery, customers are served in order by their chosen numbers.

shared variable

Choosing: array [1..N] of 0..1 initially 0;

Number: array [1..N] of 0..∞ initially 0

process p: /* 1≤ p ≤ N */ private variable

q: 1..N

while true do

0: Noncritical Section;

1: Choosing[p] := 1;

Door 2: Number[p] := 1 +max {Number[1], . . . , Number[N}; Way 3: Choosing[p] := 0;

4: for q := 1 to N skip p do

5: await Choosing[q] = 0; /*busy wait*/ Bakery 6: await Number[q]=0 V (Number[p];p) < (Number[q];q) od;

7: Critical Section;

8: Number[p] := 0

od

In the bakery algorithm, process p’s number is given by Number[p]. The shared variable Choosing [p] is updated before and after p chooses its number (line 1 and 3), to allow other processes to know when p sis in the process of choosing. P choosing its number in line 2 by reading each process’s number, taking the maximum value, and adding one. Before p can enter critical section, it must check the status of each other process q(line 5 and 6). If p detects that q is in the process of choosing its number, then p busy-wait until q is finished choosing in line 5. P then busy-waits by repeatedly reading Number[q] until it finds either Number[q] =0 or (Number[p];p)<(Number[q];q). To establish the Exclusion property for this program, we define a process to be “in the doorway" if executing within lines 1-3, and “in the bakery" if executing within lines 4-7. If process p...