1. Engineering
  2. Computer Science
  3. there are two kids a and b and there are...

Question: there are two kids a and b and there are...

Question details

There are two kids A and B and there are two apples c,d on the table. Each kid wants to pick up an apple from the table, holds it for a while, and puts it back to the table. Therefore, there are the following kinds of events:

  1. idles;
  2. idles;

A picks up c;

  1. picks up d;
  2. picks up c;

B picks up d;

A puts back c;

  1. puts back d;
  2. puts back c; B puts back d.

Notice that, as usual, we assume the interleaving model: at any moment there is at most one event is happending (e.g., A and B can not pick up apple at the same time – this is not possible in computer science).

Intially, A and B holds no apple and the two apples c and d are on the table. I want to regulate the event sequences so that at any time, any kid can not hold two apples. Obviously, you need additional control on how the kids are going to behave. Can you design such a control for the kids?

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution