跪求大神帮忙编个程序
IntroductionYou should use FDR in carrying out this assignment. Any scripts which
cannot be parsed by FDR or ProBE will normally score 0 for that
question.
You will write your own CSP scripts for this assignment. Create a separate
le for each exercise and label them accordingly. You can include comments
as lines beginning with -- . At the top of each le, insert a comment with
your marking ID. You can nd nd out what your marking ID is by logging
onto zeno and typing getmarkingid. Store your answers for each question in
a separate sub-directory and label the directories Q1, Q2 and Q3. Remember
that all events you wish to use in your process description must be declared
as channels. Use the process names and alphabets dened in the questions.
Failing to do this will lose marks.
Submitting
You will submit your work electronically by means of the submission script
submitCoursework which can be found on zeno. You may resubmit your
work any number of times, though only the last submission will be kept.
The submission will occur on zeno and the protocol is
submitCoursework <your CSP directory>
For example, assuming the directory with my solutions is assignment2 then
I would submit by typing in the following command from zeno:
submitCoursework assignment2 ,
and then follow the instructions accordingly (select Assignment2).
The les you submit cannot be overwritten by anyone else, and they cannot
be read by any other student. You can, however, overwrite your submission
as often as you like, by resubmitting, though only the last version submitted
will be kept. Submission after the deadline will be accepted but it will
automatically be recorderd as being late and is subject to College Regulations
on late submissions. Please note that all your submissions will be graded
anonymously.
NOTE: All the work you submit should be solely your own work.
Coursework submissions are routinely checked for this.
1 Food Hygiene
A system has alphabet aF = fraw; cooked;washg which represents the han-
dling of raw food, the handling of cooked food, and washing hands. The
preparation of the food is unhygienic if one handles cooked food directly af-
ter handling raw food, namely if there is a raw event directly followed by a
cooked event (put another way, that there must be at least one wash event
between any given raw event followed at some point by a cooked event).
Dene a specication process SAFEFOODSPEC which checks if pro-
cesses are \hygienic" (i.e. always ensuring a wash event is between a raw
and cooked event).
Check if the processes S1-S5 are renements of SAFEFOODSPEC.
1. S1 = raw ! wash ! cooked ! S1
2. S2 = raw ! cooked ! S2
3. S3 = cooked ! raw ! Stop
4. S4 = cooked ! raw ! S4
5. S5 = RAW fraw;washgkfwash;cookedg COOKED
where RAW = raw ! wash ! RAW and COOKED =
wash ! cooked ! COOKED.
For those of S1 to S5 that are not renements, give a trace (provided
as a comment in your solution script) which violates the specication.
2 Microwave
A microwave oven has a number of possible actions: one can open or close
the microwave door, the microwave oven can either be generating microwaves
(on) or not (off), the time the microwave runs can be increased by one
minute by pressing the increaseTime button and the generation of mi-
crowaves can be stopped by pressing the cancel button. The corresponding
CSP events are those (respectively) in the set
aM = f open; close; on; off; increaseT ime; cancel g
For each of the following informal specications, dene the processes
SPEC1, SPEC2, SPEC3 and SPEC4, which expresses the specication
in CSP. Make sure that each of the formal specications do not unnecessar-
ily restrict any events which are not mentioned in the specication. Do not
introduce any further events than those dened in aM. Each specication is
be treated to be independent of each other.
1. SPEC1: The events open and close alternate, starting with open; the
events on and off alternate, starting with on.
2. SPEC2: There must always be at least one increaseTime event be-
tween any two on events. At the start of the process , before any on
event occurs, there must be at least one increaseTime event.
3. SPEC3: While the microwave is on, no other actions can occur until it
switches o, unless the door is opened or the cancel button is pressed,
in which case the microwave must switch o immediately.
4. SPEC4: The microwave cannot run for a period longer than than 2
minutes. Pressing the cancel button sets the time the microwave runs
to zero.
Which of the specications SPEC1-SPEC4 is rened by the following
process ?
MWAV E = open ! increaseTime ! increaseTime ! close ! on ! open
! off ! close ! increaseTime ! on ! cancel ! off ! MWAV E
Which of the specications SPEC1-SPEC4 is rened by the following
alternative process ?
MWAV E2 = open ! ((close ! increaseTime ! on ! open !
(cancel ! off ! close ! MWAV E2
@ off ! close ! MWAV E2))
@ increaseTime ! cancel ! increaseTime !
on ! off ! close ! MWAV E2)
For those specications that are not renements ofMWAV E andMWAV E2,
give a trace (provided as a comment in your solution script) which violates
the specication.
3 Traces
The processes P, Q and R share the same alphabet fa; b; cg. They are dened
as:
P = a ! R
@ b ! a ! P
@ c ! b ! Q
Q = a ! Q
@ c ! P
R = a ! c ! a ! P
@ c ! b ! P
The process T is dened as T = PjjQjjR.
1. List all the traces up to (and including) length 4 of T (you can list this
as a comment in your script).
2. List all traces that end in a deadlocked state (you can list this as a
comment in your script).
3. Dene a process U and its alphabet aU such that TjjU is deadlock-free.
--------------------编程问答-------------------- --------------------编程问答-------------------- You should do by yourself --------------------编程问答--------------------
做不来啊。。
看不懂啊。。 --------------------编程问答--------------------
你先把英语翻译成汉语再说吧,那样也许有人会做
起码我会尝试 --------------------编程问答--------------------
好嘞。。
补充:Java , Java EE