SE3BB4: Softwre Design III Conurrent System Design Winter 2011 Smple Solutions to Assignment 1 Eh question is worth 10pts. Totl of this ssignment is 70pts. Eh ssignment is worth 9%. If you think your solution hs been mrked wrongly, write short memo stting where mrking is wrong nd wht you think is right, nd resubmit to me during lss, offie hours, or just slip under the door to my offie. The dedline for omplint is 2 weeks fter the ssignment is mrked nd returned. / Question 1 (i ) : The following proess models simple method for getting trough ny mze with no islnds. Briefly, if you ple your right hnd in the right hnd wll whenever you enter mze, you will lwys find wy out by following the pth desribed by tht wll. Moving left imples tht you re now lost in the mze nd tht you re stuk. Out signifies tht you re out of the mze / MAZE = ( enter ( right MAZE left STOP out STOP ) ). / Question 1 (ii ) : The following proess models simple ( forwrding) hnnel. Tht is hnnel tht outputs the sme entered vlue. / ÓÒ ØN = 3 CHANNEL = ( in [i: 1..N] out [i] CHANNEL ). 1
/ Question 2: The following proess models the behvior of vrible. The llowed opertions on vrible re either to red the vlue stored in tht vrible or to write vlue in it. The proper behvior of vrible entils tht the only vlue tht n be red from it is the lst vlue written. A vrible is modeled s proess in prtiulr stte, i.e., the stte denoting the urrent vlue held in the vrible. Writing vlue into the vrible is modeled s n tion tht modifies the its stte, while the reding its vlue is modeled s n tion tht leves its ste unhnged. It is ssumed here tht in order to red vlue from vrible first some vlue hs to be written. / ÓÒ ØN = 4 ÖÒVlue = 0..N VARIABLE = ( write [i: Vlue ] STATE [i] ), STATE [i: Vlue ] = ( write [j: Vlue ] STATE [j] red [i] STATE [i] ). 2
/ Question 3: The following proess models the behvior of sensor of mesuring the level of wter in tnk. The level of wter in the tnk is mesured in units in the within theöòr. The level of wter in the tnk is initilly 5. The sensor outputs signl low if the wter level is less thn 2, signl high if the wter level is more thn 8, otherwise it outputs norml. / ÓÒ ØLow = 2 ÓÒ ØHigh = 8 ÖÒR = 0.. 9 SENSOR = SENSOR [ 5 ], SENSOR [l: R ] = ( level [: R ] SENSOR [] Low ) low SENSOR [l] ÛÒ(Low < l && l < High ) norml SENSOR [l] High ) high SENSOR [l] ). ÛÒ(l ÛÒ(l 3
/ Question 4: The following proess models miniture portble Fm rdio. The behvior of the rdio is desribed s : (i) tion on turns the rdio on t the top frequeny of the FM bnd (108 MHz ). (ii) tion off turns the rdio off. ( iii) tion s n moves the tunning knob downwrds one frequeny t the time. Snning is only llowed s long s the botton frequeny (88 MHz) is not rehed. (iv) tion end signls tht the end frequeny hs been rehed. (v) tion lok loks the tunning knob nd stops snning. (vi) tion reset tunes the rdio to the top frequeny of the FM bnd (108 MHz ). In ddition, snning strts from the frequeny the rdio is urrently t. It is ssumed thtûòthe rdio is snning new frequeny no other tion thn lok is llowed. / ÓÒ ØTop = 108 ÓÒ ØBot = 88 ÖÒBnd = Bot.. Top RADIO = ( on RADIO [Top ] ), RADIO [frequeny: Bnd ] = ( off RADIO reset RADIO [Top ] ÛÒfrequeny > Bot sn [frequeny] SCANING [frequeny 1] ), SCANING [frequeny: Bnd ] = ( ÛÒfrequeny > Bot sn [frequeny] SCANING [frequeny 1] ÛÒfrequeny == Bot end SCANING [Bot ] lok [frequeny] RADIO [frequeny] ). 4
Question 5: Here, there is no dnger in using n isomorphism between lbeled trnsition systems to prove tht the behvior of these proess is equivlent. Thene, it is neessry to prove tht: (i) The lphbet of S1 is equl to the lphbet of S2 Proof Let α(p) denote the lphbet of proess P, then it is neessry to show tht α(s1) = α(s2) = { definition of the lphbet of both proesses } {, b, } = {, b, } = { logi } True (ii) The lbeled trnsition system for S1 is isomprhi to the lbeled trnsition system for S2 Proof () By definition, the LTS for S1 is 0 1 2 3 b (b) By definition, the minimized LTS for S2 is 0 1 2 3 b Clerly, both LTS re isomorphi. From (i) nd (ii) it follows tht S1 exhibits the sme behvior s S2. 5
/ Question 6: / ÓÒ ØN = 2 ÖÒClients = 0..N CLIENT = ( ll wit ontinue CLIENT ). / Proess SERVER models the behvior of server pble of ttending requests ( mutully exlusive) of severl lients. The behvior of the server is simply desribed s follows : (i) tion request [ ] models request from lient. (ii) tion servie models n internl omputtion on the server. (iii) tion reply [ ] models reply to request from lient. Clerly the server will reply request from lient provided lient hs pled request. / SERVER = ( request [: Clients ] servie reply [] SERVER ). / The following proess models severl lients running in prllel / CLIENTS = ( forll [i: Clients ] lient [i ] : CLIENT ). / The relbeling prt in the omposed proess models the synhroniztion between the lls mde by the lients nd the requests epted by the server s well s their respetive responses. / CLIENTS_SERVER = ( CLIENTS server : SERVER ) /{ lient [: Clients ]. ll/server.request [], server.reply [: Clients ]/lient [ ]. wit }. 6
/ Question 7 / / The following proesses model the behvior of roller oster. / / Proess turnstile models the rrivl of pssengers to the roller oster. / TURNSTILE = ( pssenger TURNSTILE ). / Proess ontrol models ontrol system for the roller oster. The ide is tht ontrol will keep trk of the number of pssengers in the roller oster r. Its behvior is desribed s follows : (i) tion rrive initilizes to 0 the internl ounter for ontrol. Intuitively it models the rrivl of n empty r to the pltform. (ii) tion pssenger signls pssenger jumping into the r. (iii) tion deprt signls the deprture of the roller oster r is. The ondition on this tions implies tht the r will deprt onlyûòfull. / ÓÒ ØN = 3 CONTROL = CONTROL [ 0 ], CONTROL [n: 0..N ] = ( ÛÒn < N pssenger CONTROL [n+1] N deprt CONTROL [n] rrive CONTROL ). ÛÒn == / Proess r models the behvior of roller oster r. (i) tion deprts signls the deprture of the r from the pltform nd the begining of the ride. (ii) tion ride models the roller osters trip. (iii) tion rrive signls the rrivl of the r to the pltform. / CAR = ( deprt ride rrive CAR ). / It is ssumed tht there is only one r in the roller oster. Moreover, it is ssumed tht intilly there is r witing for pssengers nd redy to strt the ride. Pssengers getting off the roller oster r is modeled s single tion. / ROLLER_COASTER = ( TURNSTILE CONTROL CAR ). 7