Submitted:
03 April 2024
Posted:
05 April 2024
You are already at the latest version
Abstract
Keywords:
1. Introduction
- The modelling and verification method is completely re-designed and its semantics and transformation on to the Timed Automata of Uppaal clarified.
- The novel approach is applied to several ME algorithms proposed in the literature, thus retrieving known results and properties but also, sometimes, discovering new features about specific ME solutions.
- Both exhaustive model checking (MC) and statistical model checking (SMC) [14,15] can be exploited for property checking. Although SMC is based on simulations, properties of an ME algorithm for N ﹥ 5 processes can be extrapolated by estimations and probability, thus furnishing further arguments to the indications emerged by the exhaustive verification work accomplished until N = 5 processes.
2. An Overview of Uppaal Timed Automata Modelling
3. A Modelling Method for Mutual Exclusion Algorithms
| Algorithm 1. General code structure of a process involved with mutual exclusion. |
|
global shared communication variables Process(i): local variables of the process loop NCS //Non Critical Section Entry CS //Critical Section Exit end-loop |
- (safety) Absence of deadlocks in the processes attempting to use the shared resource.
- (safety) At any time, only one process should be allowed to enter its critical section.
- (bounded liveness) A competing process eventually enters its critical section. In other terms, the waiting time for a competing process should be finite and hopefully small. Equivalently, the number of by-passes or the overtaking factor which a waiting process experiments from other competing processes should be bounded. This property also expresses, for a competing process, the absence of starvation.
- (liveness) A process in its non-critical section should never impede a competing process to enter its critical section.
3.1. Uppaal Modelling Method
3.2. Predicting the Overtaking Factor
3.3. Model Checking and TCTL Queries
3.4. Statistical Model Checking and MITL Queries
4. Modelling and Analysis of Mutual Exclusion Algorithms
4.1. Solutions for Two Processes
4.1.1. The Dekker’s Algorithm
| Algorithm 2. Dekker’s Process(i). |
| Process(i): local constant: int j=3-i; while(true){ NCS; flag[i]=true; while( flag[j] ){ if( turn==j ){ flag[i]=false; wait-until( turn==i ); flag[i]=true; } } CS; turn=j; flag[i]=false; } |
4.1.2. The Peterson’s Algorithm for Two Processes
| Algorithm 3. Peterson’s Process(i). |
| Process(i): local constant: int j=3-i; while(true){ NCS; flag[i]=true; turn=j; wait-until(!flag[j] || turn==i); CS; flag[i]=false; } |
4.2. Solutions for
4.2.1. The Dijkstra’s Algorithm
| Algorithm 4. The E.W. Dijkstra algorithm for the processes |
| Process(i): local int j; LiO: b[i] := false; Lil: if k # i then Li2: begin c[i] := true; Li3 if b[k] then k:=i; go to Lil end else Li4: begin c[i] := false; for j := 1 step 1 until N do if j # i and not c[j] then go to Lil end; critical section; c[i] := true; bill := true; remainder of the cycle in which stopping is allowed; go to LiO |
| Algorithm 5. try() function of Figure 5. |
| bool try(){ |
| int j; |
| if( k!=i ){ |
| return false; |
| } |
| else{ |
| for( j=1; j<=N; ++j ) |
| if( j!=i && !c[j] ) |
| return false; |
| } |
| return true; |
| }//try |
4.2.2. The Knuth’s Algorithm
| Algorithm 6. The Knuth’s algorithm for processes |
| Process(i): begin int j; L0: control[i]=1; L1: for j=k step -1 until 1, N step -1 until 1 do begin if j==i then go to L2; if control[j]!=0 then go to L1; end; L2: control[i]=2; for j=N step -1 until 1 do if j!=i && (control[j]==2) then go to L0; L3: k=i; critical_section; k=if i==1 then N else i-1; L4: control[i]=0; remainder of the cycle in which stopping is allowed; go to L0; end |
| Algorithm 7. The try() and dec() functions of the Uppaal model in Figure 6. |
| bool try(){ int j; if(k>=i && i>=1){ for(j=k; j>i; --j) if(control[j]!=0) return false; } else{ //k<i<=N for(j=N; j>i; --j) if(control[j]!=0) return false; } for(j=N; j>=1; --j) if(j!=i && control[j]==2) return false; return true; }//try int dec(int j){ if(k>0) return (j==1)?N:j-1; return j-1; }//dec |
4.2.3. The de Bruijn’s Algorithm
4.2.4. The Eisenberg & McGuire Algorithm
| Algorithm 8. The Eisenberg & McGuire’s algorithm for processes. |
| Process(i): begin int j; L0: control[i]=1; L1: for j=k step 1 until N, 1 step 1 until k do begin if j==i then go to L2; if control[j]!=0 then go to L1; end; L2: control[i]=2; for j=1 step 1 until N do if j!=i && (control[j]==2) then go to L0; L3: if control[k]!=0 && k!=i then go to L0; L4: k=i; critical_section; L5: for j=k step 1 until N, 1 step 1 until k do if j!=k and control[j]!=0 then begin k=j; go to L6; end; L6: control[i]=0; remainder of the cycle; go to L0; end |
4.2.5. The Generalized Peterson’s Algorithm
| Algorithm 9. The Peterson’s solution for processes. |
| Process(i): local int j; while(true){ NCS; for j=1 step 1 until N-1 do begin q[i]=j; turn[j]=i; wait-until( k!=i, q[k]<j) or (turn[j]!=i)); end; CS; q[i]=0; } |
4.2.6. The Block & Woo Algorithm
| Algorithm 10. The Block & Woo algorithm for processes. |
| Process i: int j; while(true){ NCS; j = 0; q[i] =1; repeat j = j+1 turn[j] =i; wait-until (turn[j]!=i) or () until (turn[j]==i) CS; q[i] =0; } |
4.2.7. The Aravind & Hesselink Algorithm
| Algorithm 11. The Aravind & Hesselink algorithm for mutual exclusion. |
| Process(i): local variables: int[0,N-1] level; bool bb; pid q; int[0,N-1] card; while(true){ NCS; act[i]=true; level=N-1; while(level>0){ card=N-1-|{q,1<=q<=N : !act[q]}|; //number of not CS interested processes if(card<level){ level=card; bb=false; } else if(!bb){ turn[level]=i; bb=true; card=|{q,1<=q<=N, q!=i && act[q]}|; } else if(turn[level]!=i){ level--; bb=false; } } CS; act[i]=false; } |
4.2.8. Solutions under the Weak Memory Model
5. Conclusions
References
- Lamport, L. The mutual exclusion problem: part I---a theory of interprocess communication. In Concurrency: the Works of Leslie Lamport; 2019, pp. 227–245.
- Raynal, M. Algorithms for mutual exclusion, 1986, MIT Press.
- Dijkstra, E.W. Co-operating sequential processes. In Programming languages: NATO Advanced Study Institute: lectures given at a three weeks Summer School held in Villard-le-Lans, 1966, ed. by F. Genuys, pp. 43–112, Academic Press Inc.
- Raynal, M. Concurrent programming: algorithms, principles, and foundations 2012, Springer Science & Business Media.
- Misra, J. A foundation of parallel programming. In Constructive Methods in Computing Science: International Summer School directed by FL Bauer, M. Broy, EW Dijkstra, CAR Hoare, 1989, pp. 397–445, Springer Berlin Heidelberg.
- Lamport, L. On interprocess communication. Distributed Computing 1986, 1, 77–101. [Google Scholar] [CrossRef]
- Nigro, L.; Cicirelli, F. Formal modeling and verification of embedded real-time systems: An approach and practical tool based on Constraint Time Petri Nets. Mathematics 2024, 12, 812. [Google Scholar] [CrossRef]
- Silbershatz, A.; Galvin, P.B.; Gagne, G. Operating System Concepts, 2018, 10th Edition, Wiley.
- Aravind, A.A.; Hesselink, W.H. A queue based mutual exclusion algorithm. Acta Informatica 2009, 46, 73–86. [Google Scholar] [CrossRef]
- Alur, R.; Dill, D.L. A theory of timed automata. Theoretical Computer Science 1994, 126, 183–235. [Google Scholar] [CrossRef]
- Behrmann, G.; David, A. , Larsen, K.G. A tutorial on UPPAAL. In: M. Bernardo, F. Corradini (Eds.), Formal Methods for the Design of Real-Time Systems 2004, LNCS 3185, Springer, pp. 200–236.
- Cicirelli, F.; Nigro, L. Modelling and verification of mutual exclusion algorithms. IEEE/ACM 20th International Symposium on Distributed Simulation and Real Time Applications (DS-RT), IEEE, 2016, pp. 136–144.
- Cicirelli, F.; Nigro, L.; Sciammarella, P.F. Model checking mutual exclusion algorithms using Uppaal. In Proc. of 5th Computer Science On-Line Conference, 2016, Springer.
- Agha, G.; Palmskog, K. A Survey of Statistical Model Checking. ACM Trans. Model. Comput. Simul. 2018, 28, 6:1–6:39. [Google Scholar] [CrossRef]
- David, A.; Larsen, K.G.; Legay, A.; Mikucionis, M.; Poulsen, D.B. Uppaal SMC tutorial. Int. J. Softw. Tools Technol. Transf. 2015, 17, 397–415. [Google Scholar] [CrossRef]
- Bowman, H.; Gomez, R.; Su, L. A tool for the syntactic detection of zeno-timelocks in Timed Automata. Electron. Notes Theor. Comput. Sci. 2005, 139, 25–47. [Google Scholar] [CrossRef]
- Lee, E.A. Modeling in engineering and science. Communications of the ACM 2018, 62, 35–36. [Google Scholar] [CrossRef]
- Dijkstra, E.W. Solution of a problem in concurrent programming control. Communications of the ACM 1965, 8, 569. [Google Scholar] [CrossRef]
- Peterson, G.L. Myths about the mutual exclusion problem. Information Processing Letters 1981, 12, 115–116. [Google Scholar] [CrossRef]
- Knuth, D.E. Additional comments on a problem in concurrent programming control. Communications of the ACM 1966, 9, 321–322. [Google Scholar] [CrossRef]
- de Bruijn, N.G. Additional comments on a problem in concurrent programming control. Communications of the ACM 1967, 10, 137–138. [Google Scholar] [CrossRef]
- Eisenberg, M.A.; McGuire, M.R. Further comments on Dijkstra’s concurrent programming control problem. Communications of the ACM 1972, 15, 999. [Google Scholar] [CrossRef]
- Kowalttowski, T.; Palma, A. Another solution of the mutual exclusion problem. Information Processing Letters 1984, 19, 145–146. [Google Scholar] [CrossRef]
- Hofri, M. Proof of a mutual exclusion algorithm – A ‘Class’ic example. ACM SIGOPS OSR 1990, 24, 18–22. [Google Scholar] [CrossRef]
- Block, K.; Woo, T.K. A more efficient generalization of Peterson’s mutual exclusion algorithm. Information Processing Letters 1990, 35, 219–222. [Google Scholar] [CrossRef]
- Frenzel, L.E. Dual-port SRAM accelerates smart-phone development. Electronic Design 2004.
- Lamport, L. A new solution of Dijkstra’s concurrent programming problem. Comm. of ACM 1974, 17, 453–455. [Google Scholar] [CrossRef]
- Nigro, L. Parallel Theatre: An actor framework in Java for high performance computing. Simulation Modelling Practice and Theory 2021, 106, 102189. [Google Scholar] [CrossRef]













| # | TCTL query | Property |
| 1 | A[] !deadlock | Absence of deadlocks. |
| 2 | A[] (sum(i:pid)Process(i).CS)<=1 | At most one process can be in its critical section (CS). |
| 3 | Process(tp).BWProcess(tp).CS | A process in BW eventually enters the critical section. |
| 4 | E<> Process(1).NCS && Process(2).CS | A process in NCS does not forbid another process from entering the CS. |
| 5 | sup{ Process(tp).BW } : x[tp] | The suprema value of the overtaking factor. |
| # | MITL query | Property |
| 1 | Pr[<=10000](<>(sum(i:pid)Process(i).CS)>1) | Probability that more than one process can be in CS. |
| 2 | simulate[<=100]{sum(i:pid)Process(i).CS} | Monitoring the number of processes simultaneously in CS in a simulation of 100 time units. |
| 3 | Pr[<=1000](<>Process(tp).CS) | Probability that a process can actually enter its CS. |
| 4 | Pr[<=10000](<>Process(tp).BW && x[tp]>expected-value) |
Probability that the overtaking factor (x[tp]) can be found greater than the expected-value. |
| 5 | Pr[<=10000]([] Process(tp).NCS || x[tp]<=expected-value) |
Probability that x[tp] is always found less than or equal its expected-value. |
| N | ov |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| N | ov |
| 2 | 1 |
| 3 | 3 |
| 4 | 5 |
| 5 | 7 |
| N | ov |
| 2 | 1 |
| 3 | 2 |
| 4 | 3 |
| 5 | 4 |
| N | ov |
| 2 | 1 |
| 3 | 3 |
| 4 | 6 |
| 5 | 10 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2024 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).