troubleshooting Question

Please explain what this program does

Avatar of gogori
gogori asked on
Programming
4 Comments1 Solution244 ViewsLast Modified:
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);
}

Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros