Mutual Exclusion Protocol Implementation and Verification in Promela
30 likes | 143 Vues
This document outlines the implementation of a mutual exclusion protocol using Promela for two processes. The specification ensures that no atomic operation is permitted, and details the processes for mutual exclusion, deadlock-freedom, and starvation-freedom. It includes essential constructs such as a global lock and a priority mechanism using a turn variable. The model’s correctness is verified through LTL properties using Spin. Additionally, it explains potential counterexamples to illustrate scenarios where the protocol might fail to meet the specified properties.
Mutual Exclusion Protocol Implementation and Verification in Promela
E N D
Presentation Transcript
HW6: Due Dec 21 th23:59 • /* Assume that there are two processes */ • char count=0,x=0,y=0,z=0; • void process() { • char me=_pid +1; /* me is 1 or 2*/ • Try: • x= me; • If (y ==0 || y== me) ; • Else goto again; • Z =me; • If (x == me) ; • Else goto again; • Y=me; • If(z==me); • Else goto again; • /* enter a critical section */ • Count++; • InCritSec: … • Count --; • /* leaving a critical section */ • Gotoagain; • } • To specify a corresponding Promela specification • Note that no atomic allowed • To specify the following properties in LTL • Note that procname[pid]@label returns a nonzero value only if a statement at the corresponding label is executable now • Mutual exclusion • Deadlock-freedom • Starvation-freedom • Check whether your Promela spec satisfies the above three properties by using Spin. Also explain the counter examples.
2. Build the following mutual exclusion protocol in Promela. - Your Promela spec should contain 2 processes. - You should use a global lock with atomic keyword to check entrance to the critical section. - Verify the following correctness properties of your Promela model • Mutual exclusion • Liveness mtype ={n,t,c} byte lock=0; active [2] proctype process() { byte status=n; … }
2. Build the following mutual exclusion protocol in Promela. And verify the correctness of your Promela model • Mutual exclusion • Liveness • You may use a global variable turn to indicate which process has a higher priority to enter critical section • Note that you can access a local variable of the other processes through remote reference procname[pid]:localvar mtype={n,t,c}; byte lock; byte turn=255; active [2] proctype process() { … }