Exercises


  • 9.1 The cheese counter in a supermarket is continuously mobbed by hungry customers. There are two sorts of customer: bold customers who push their way to the front of the mob and demand service; and meek customers who wait patiently for service. Request for service is denoted by the action getcheese and service completion is signaled by the action cheese. Assuming that there is always cheese available, model the system for a fixed population of two bold customers and two meek customers. Show that meek customers may never be served when their requests to get cheese have lower priority than those of bold customers.

  • 9.2 To restore order, the management installs a ticket machine that issues tickets to customers. Tickets are numbered in the range 1..MT. When ticket MT has been issued, the next ticket to be issued is ticket number 1, i.e. the management install a new ticket roll. The cheese counter has a display that indicates the ticket number of the customer currently being served. The customer with the ticket with the same number as the counter display then goes to the counter and is served. When the service is finished, the number is incremented (modulo MT). Model this system and show that, even when their requests have low priority, meek customers are now served.

  • 9.3 Translate the model of the cheese counter from exercise 9.2 into a Java program. Each customer should be implemented by a dynamically created thread that obtains a ticket, is served cheese and then terminates.

  • 9.4 Extend the master–slave model of section 9.8 to cater for two slave processes. Now generalize this model to describe systems with N slave processes.

  • 9.5 Modify the demonstration applet of section 9.7 to create two slave processes.




Concurrency(c) State Models & Java Programs
Concurrency: State Models and Java Programs
ISBN: 0470093552
EAN: 2147483647
Year: 2004
Pages: 162

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net