Google Answers Logo
View Question
 
Q: Please explain what this program does ( No Answer,   0 Comments )
Question  
Subject: Please explain what this program does
Category: Computers > Programming
Asked by: pink_snickers-ga
List Price: $30.00
Posted: 18 Feb 2006 15:01 PST
Expires: 20 Feb 2006 09:01 PST
Question ID: 447417
Can someone please explain what this program generally does?

and especially, what is the connection between the array 'strarray' 
and value of 'rsult' upon termination?

Thanks :)

#define     MAXIMUM          6
#define MAXIMUMINDEX      MAXIMUM-1

bool rsult;
byte strarray[MAXIMUM];

proctype prducer( chan out )
{     int i;
     do
     :: (i <= MAXIMUMINDEX) -> out!strarray[i]; i++;
     :: (i > MAXIMUMINDEX) -> break;
     od;
}

proctype anonymous( chan in; chan out )
{     bit x,y;
     bool r;
     chan chld = [1] of { bit };
     chan c = [1] of { bool };

     out!1;
     if
     :: in?x -> out!1;
             run anonymous( chld, c );
             do
             :: in?y -> chld!y; c?r; out!(r && (x==y));
             :: timeout -> break;
             od
     :: timeout -> skip
     fi
}

proctype cnsumer ( chan in )
{      bool r;
     int i=0;
     do
     :: (i <= MAXIMUM) -> in?r; i++;
     :: (i > MAXIMUM) -> break;
     od;
     rsult = r;
}
     
init
{      
     /* array strarray */
     strarray[0] = 1;
     strarray[1] = 1;
     strarray[2] = 0;
     strarray[3] = 0;
     strarray[4] = 1;
     strarray[5] = 0;

     chan chld = [1] of { bit };
     chan c = [1] of { bool };

     run prducer(chld);
     run anonymous(chld, c);
     run cnsumer(c);
}

Request for Question Clarification by efn-ga on 18 Feb 2006 20:47 PST
In what language is the program written?  It looks like Promela, but
it would be helpful if you could confirm this.

Clarification of Question by pink_snickers-ga on 19 Feb 2006 00:05 PST
yes, it is Promela.
Sorry for forgetting to mention that and hope you can help out :)
Thanks
Answer  
There is no answer at this time.

Comments  
There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy