Question: I need a promela (SPIN) program that will Parallel Swap. Consider a shared memory program with N processes that have access to an array A[]
I need a promela (SPIN) program that will Parallel Swap.
Consider a shared memory program with N processes that have access to an array A[] of integers of size N. The array A[] is initialized with distinct non-negative integer values. Each process can read and write to any array cell.
Specifications: Each process Pi should randomly pick a value j modulo N and then swap A[i] with A[j]. After the swap, Pi terminates.
The safety and liveness requirements of the program are as follows:
Liveness: All processes must eventually terminate.
Safety: After the termination of all processes, the array A[] must contain a permutation of its initial values. Notice that, A[] must not contain duplicate, nor should there be a missing value in A[] after termination. In order to guarantee that, you should ensure data race-freedom. That is, no two processes should simultaneously access the same array cell where one of them performs a write operation. In this problem, data race-freedom would imply no duplicate/missing values.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
