please i am a biginner on tihs domain how can i convert a classical example FIFO written in systemC code to PROMELA language with properties in LTL satisfy the following three properties:
Mutual exclusion: The producer and consumer processes never access the shared buffer simultaneously.
Non-starvation: The consumer accesses the buffer infinitely often. (You may assume that the producer never runs out of data to supply, and the consumer never stops attempting to read new data.)
Producer-consumer: The producer never overwrites the data buffer unless the consumer has already read the current data The consumer never reads the data buffer unless it contains new data. The usual algorithm for producer-consumer uses a single flag bit. The flag bit is set by the producer when data ready to be read, and unset by the consumer once it has read the data. For the sake of this assignment, we only need to model whether the data buffer has been read, rather than modeling the contents of the data. We will use a single bit for this.
Your task is to model this algorithm in Promela, and then verify the above properties about it. It will help to remember that (1) and (3) are safety properties, but (2) is a liveness property. You may use both LTL and in-line assertions where appropriate.
This is my first attempt at solving this problem:
#define NUMCHAN 4
chan channels[NUMCHAN];
chan full[0];
init
{
chan ch1 = [1] of { byte };
chan ch2 = [1] of { byte };
chan ch3 = [1] of { byte };
chan ch4 = [1] of { byte };
channels[0] = ch1;
channels[1] = ch2;
channels[2] = ch3;
channels[3] = ch4;
// Add further channels above, in accordance with NUMCHAN
// First let the producer write something, then start the consumer
run producer();
atomic {
_nr_pr == 1 -> run consumer();
}
}
proctype read()
{
byte var, i;
chan theChan;
do
:: fread?1 ->
if readptr == writeptr -> empty ! 1
fi
read ! 0
readptr = readptr+1 mod NUMCHAN
ack ?1
od
ack!1
i = 0;
do
:: i == NUMCHAN -> break
:: else -> theChan = channels[i];
if
:: skip // non-deterministic skip
:: nempty(theChan) ->
theChan ? var;
printf("Read value %d from channel %d\n", var, i+1)
fi;
i++
od
}
proctype consumer()
{
do // empty
if
empty ? 0 // read // data
theChan ? data
:: fread!1 -> ack ?1
od
}
I created two fundamental processes, a producer and a consumer.
The producer is bound to another process called write by a channel fwrite and the consumer is bound to another process called read by a channel fread. Here, read and write contain read and write pointers.
The consumer is incomplete, I have only sketched the idea I have. I would like to have the reading to happen after the total writing of the channels or the table of the FIFO and that the producer can write N number of information without being satisfied with the size of the FIFO.