[SDU Logo]   Dept. of Mathematics and Computer Science
University of Southern Denmark Phone/Email Directory | Maps

   
 DM519 - 2012
Home
Schedule
Weekly Notes

 

Weekly Note 4

Hand-In #3, Tuesday May 8 at noon (12:00)

The newly opened IMADA barbershop consists of a waiting room with two seats and a barber room with one barber chair.

If there are no barber customers to be served, the barber simply goes to the nearby Carlsens kvarter to drink beer.

If a customer enters the barbershop and all chairs in the waiting room are occupied, the customer leaves the shop, otherwise the customer sits in one of the two waiting chairs.

A soon as the barber chair becomes empty, a customer can move to the barber chair and is ready to be cut.

If the barber is drinking beer, and a customer is ready to be cut, he automatically returns to the shop and starts cutting.

  1. Write the missing part(s) of the FSP model below. If your prefer, you are allowed to rewrite everything. Your report should clearly indicate which part of the model, you wrote yourself.
  2. Using the LSTA tool, ensure that your model does not have deadlock or liveness problems. (If this is the case, go back to Step 1 and rewrite your model).
  3. Implement your model in Java. Document your code and the model-implementation correspondence by adding the corresponding model snippets as comments into your Java code.
  4. Verify that your Java implementation works as expected.
Download: barber.fsp
// Number of seats and range of seats taken const Seats = 2 range SeatsTaken = 0..Seats // Possible states for the barber chair const BCEmpty = 0 const BCCouldCut = 1 // somebody is sitting waiting to be cut const BCCuttingDone = 2 // the person sitting in the chair has had his hair cut // and could go home range BCRange = BCEmpty..BCCuttingDone // Boolean for whether the barber is drinking beer const False = 0 const True = 1 range Bool = False..True // Number of customers (should be more than number of seats) const Customers = Seats+1 range CustomerRange = 1..Customers // // The barber // Barber = InShop, InShop = (cutHair -> InShop |goForBeer -> Carlsens), Carlsens = (beer -> Carlsens |fetchBarber -> InShop). // // A customer // Customer = AtHome, AtHome = (goShop -> AtShop), AtShop = (getWaitingChair -> getChair -> cutHair -> goHome -> AtHome |goDirectlyHome -> AtHome). // // The Shop // Shop = Shop[0][BCEmpty][False], Shop[w:SeatsTaken][bcState:BCRange][barberDrinkingBeer:Bool] = // ... ). // // Combine everything // ||EmptyBarberShop = (Barber || Shop). ||BarberShop = ([CustomerRange]:Customer || [CustomerRange]::EmptyBarberShop).

Discussion Section, Wednesday May 2 at 12:15 in U26

  1. [MK] 5.4
  2. In the following model, three processes alternately do stuff and synchronize their calculations with the other two processes. P = (doPStuff -> synchronize -> P). Q = (doQStuff -> synchronize -> Q). R = (doRStuff -> synchronize -> R). ||PQR = (P || Q || R). The synchronize action can be implemented using a barrier, as shown in the following interface public interface Barrier { /** * Create a barrier to be used by n threads. * * @param n number of threads */ // public Barrier(int n); /** * Enter this barrier and exit when in total exactly n threads * have done this. */ public void synchronize(); } Implement this in Java.
  3. [MK] 6.2 - 6.4
  4. [MK] 7.1, 7.2

Discussion Section, Thursday May 3 at 10:15 in U26

  1. Hand-in #2.
  2. [MK] 7.3, 7.6
  3. Properties P = (ready -> P1), P1 = (on -> off -> P1 |reset -> P1). Q = (initialize -> ready -> Q1), Q1 = (off -> on -> Q1 |timeout -> Q1). property S = (ready -> S1), S1 = (on -> S1). progress L = {timeout} progress M = {ready} Determine which of the following relationships about safety and liveness property satisfaction (involving processes P and Q) are true and which are not - and explain how you determined it.
    1. P |= S, i.e., does process P satisfy (safety) property S?
    2. Q |= S, i.e., does process Q satisfy (safety) property S?
    3. P |= L, i.e., does process P satisfy (liveness) property L?
    4. Q |= L, i.e., does process Q satisfy (liveness) property L?
    5. (P||Q) |= S, i.e., does process (P||Q) satisfy (safety) property L?
    6. (P||Q) |= L, i.e., does process (P||Q) satisfy (liveness) property L?
    7. (P||Q) |= M, i.e., does process (P||Q) satisfy (liveness) property M?
  4. Questions for Hand-in #3