Demo entry 6647400

test

   

Submitted by anonymous on Oct 20, 2017 at 02:06
Language: C. Code size: 421 Bytes.

#define N 10

bool print[N];

chan lock = [0] of {pid};
chan free = [0] of {pid};

active [N] proctype printer() {
    do
    :: lock!_pid;
    :: print[_pid] == 1 ->
	if
	:: printf("Printing...") ->
	   print[_pid] = 0;
	   free!_pid;
	fi;     
    od;	
}

active proctype scheduler() {
    pid process_id;

    do
    :: lock?process_id ->
	print[process_id] = 1;
	free?process_id;
    od;	
}

This snippet took 0.01 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).