The Send and Receive constructs will be supported as follows.


Every Process will communicate through channels or signals. These Channels or signals are identified by the signal or channel identifiers which are defined in the system scope. Signals are defined as follows:

SIGNAL <List of Comma Separated Signal Identifiers>;

Where SIGNAL is the keyword.


The process will communicate through SEND/RECEIVE primitives which are defined as follows. We will assume that the processes will send/receive one-byte through the Channels.


For example a SEND primitve will look like:


SEND(sig_id,'a') or SEND(sig_id,v)


where sig_id signifies the signal/channel it is going to use. 'a' is a byte – constant which is sent through the pipe. v is a character variable declared as char v; in the process space.


An Example:


Here the equivalent description is as follows:


SYSTEM mystem1;

SIGNAL S1;


PROCESS P1,P2;


PROCESSDEF P1

START


BLOCK blockid1 BEGIN

START

int i=0;

GOTO mydec1

END


DECISION mydec1

IF i<10

THEN

GOTO comid1

ELSE

GOTO blockid2


BLOCK blockid2 BEGIN

START

printf(“Done”);

END



BLOCK blockid3 BEGIN

START

i++;

GOTO mydec1

END


COMM comid1

SEND(S1,'a');

GOTO blockid3


END


PROCESSDEF P2

START


BLOCK blockid4 BEGIN

START

int i=0;

char v;

GOTO mydec2

END


DECISION mydec2

IF i<10

THEN

GOTO comid2

ELSE

GOTO blockid4


BLOCK blockid4 BEGIN

START

printf(“Done”);

END



BLOCK blockid5 BEGIN

START

i++;

printf(“%c”,v);

GOTO mydec2

END


COMM comid2

RECV(S1,v);

GOTO blockid5


END




A communication block is specified as follows:


A SEND block looks like:

COMM Commblock_Identifier

SEND(signal_identifier,Character_Constant_or_Variable);

GOTO Next_Control_Flow_Node_Identifier


A Recv block looks like:

COMM Commblock_Identifier

SEND(signal_identifier,Character_Variable);

GOTO Next_Control_Flow_Node_Identifier


- Hint for code Generation

main( )

{

//Signal – Name

//Mnamed Pipes etc to be defined here


for(i=0;i<number_of_defined_process;i++){

if(fork( ) == 0){

//Call the function to be executed for the process

}else break;

}

}

You may have to use sleep function for some sort of synchroization.



Sample testcase