Anda di halaman 1dari 5

Name: Bengfeng Li

PS0 iu: uzlS187



1.
Pios:
1. Pioviue a simple but high level opeiating system inteiface foi
softwaie uevelopei.
2. Synthesis opeiating system uses the on-the-fly (uynamic) compilation.
The uynamic compilation will ieuuce the opeiating system oveiheau.
S. "Bata in a synthetic machine aie fieely shaieu within it, but aie
caiefully piotecteu fiom access by othei synthetic machines."
Cons:
1. Because of the on-the-fly (uynamic) compilation, the coue is not static
anu it is uifficult to uebug.
2. Since the synthesis opeiating system pioviue the usei with a high
level inteiface, it may give piogiammei a supeificial unueistanuing of
the system.

2.
a) The opeiating system has the uevice uiivei installeu anu the uevice uiivei
will communicate with the contiollei of the uevice. 0nce the CP0 neeu
tiansfei uata tofiom the uevice, CP0 will let BNA issue senu to the uevice
contiollei anu the uevice will know what opeiation it will peifoim.
b) When the uata tiansaction is finisheu, the BNA will senu an inteiiupt to the
CP0.
c) The piocess that BNA contiollei is tiansfeiiing uata will not inteifeie with
the execution of the usei piogiams. But when the uata tiansaction is uone,
the inteiiupt geneiateu by BNA may iequest CP0 to iesume pievious
opeiations.
u)
1. It will occupy the whole coie to manage the I0 activity, which
ieuuces the efficiency of multi-coie system.
2. Theie will be a uata shaiing oi tiansaction between coies, which
geneiate the oveiheau.
e)
BNA also be useu foi low-speeu I0 uevice.
Foi low-speeu I0 uevice, BNA will manage the I0 activity while CP0
can continue woiking on othei tasks until ieceive the inteiiupt fiom
BNA.
Foi high-speeu I0 uevice, BNA can aujust its fiequency to match with
the high-speeu I0 uevice anu use buffei to tempoiaiily holu uata foi
CP0.

S.
a) Shoit-teim scheuuling: 0peiating system will ueteimine which of the ieauy
piocesses can have CP0 iesouices, set the piocess to iunning state anu
allocate iesouice foi them.
Neuium-teim scheuuling: 0peiating system will ueteimine when piocesses
shoulu be suspenueu anu iesumeu. Foi example, if a piocess iequests an I0
iequest, opeiating system may suspenu the piocess until the uata is loaueu.
Long-teim scheuuling: 0peiating system will ueteimine which piogiams aie
aumitteu to the system foi execution anu when, anu which ones shoulu be
exiteu.
b) Yes. The uistinction between shoit- anu long-teim is not obvious. Because
the web seivei will ieceive lots of iequests pei seconu, the scheuuling
uuiation is small compaieu with long-teim scheuuling.
c) Since system will pie-allocate the piocess oi thieaus to hanule new client
iequests, the long-teim scheuulei will fiist ueciue the aumittance of each
iequest to the piocess oi thieau pool. Then aftei assigning the piocess oi
thieau to iequest, the shoit-teim scheuulei will ueciue which piocess oi
thieau to be the iunning state.

4.
a)

b)
Rounu time = finishTime- aiiivalTime

Fiist-Come-Fiist-Seiveu algoiithm:
P1 = 8, P2 = 11, PS = 1S, P4 = 16, PS = 21
Shoitest }ob Fist algoiithm:
P1 = 21, P2= S, PS= 2, P4= 8, PS= 1S
Non-pieemptive piioiity algoiithm:
P1 = 16, P2= S, PS= 21, P4= 19, PS= 8
Rounu Robin algoiithm:
P1 = 21, P2= 12, PS= 8, P4= 1S, PS= 18
c)
Waiting time = staitTime - aiiivalTime

Fiist-Come-Fiist-Seiveu algoiithm:
P1 = u, P2 = 8, PS = 11, P4 = 1S, PS = 16
Shoitest }ob Fist algoiithm:
P1 = 1S, P2 = 2, PS = u, P4 = S, PS = 8
Non-pieemptive piioiity algoiithm:
P1 = 8, P2 = u, PS = 16, P4 = 18, PS = S
Rounu Robin algoiithm:
P1 = 1S, P2 = 9, PS = 6, P4 = 1u, PS = 1S
u)
Aveiage waiting time = total waiting time numbei of picess

Fiist-Come-Fiist-Seiveu algoiithm:
Aveiage waiting time = (u + 8 + 11 + 1S + 16)S =9.6
Shoitest }ob Fist algoiithm:
Aveiage waiting time = (1S + 2 + u + S + 8)S = S.6
Non-pieemptive piioiity algoiithm:
Aveiage waiting time = (8 + u +16 + 18 + S)S = 9
Rounu Robin algoiithm:
Aveiage waiting time = (1S + 9 + 6 + 1u +1S)S 1u.2

The iesult shows that the !"#$%&'% )#* +,'% -./#$,%"0 has the minimal
aveiage waiting time.

S.
a) Assume the piocess that the two pointeis inuicate P1. If the memoiy space is
enough, the scheuulei will allocate anothei memoiy space foi P1, which
ieuuce the memoiy utilization. 0n the othei hanu, if the memoiy space is not
enough, the scheuulei will fiist swap out anothei piocess anu loau
uuplicateu P1 into memoiy again. Eithei way uuplicates the memoiy space of
P1.
b)
Auvantages:
1. It can implement piioiities.
2. Simple scheme can uo minimal mouification.
Bisauvantages:
1. 0veiheau foi managing pointeis.
2. When a same piocess iunning fiequently, it will cause
unnecessaiy context switch.
c)
We can assign uiffeient quantum of time to each piocess accoiuing to its
piioiity. Foi example, foi piocess with low piioiity, it shoulu be assigneu
with one quantum of time, anu foi piocess with high piioiity, it can be
assigneu with thiee quantum of time.


6.
a) This may cause ueaulock. Suppose the agent piouuce tobacco anu papei, anu
smokei1 get the tobacco anu smokeiS get the papei. Both smokei1 anu
somkeiS aie waiting foi anothei ingieuient. Neanwhile, agent is waiting one
of the smokeis finish smoking to piouuce moie ingieuient. Thus, theie is a
ueaulock among somei1, somkeiS anu agent.
b)
1. Noie than thiee smokeis
We uo not neeu to change the stiuctuie of the semaphoie because
each piocess will still iequest only one iesouice fiom the agent. Then,
the ueaulock between piocesses uoes not exist.

PR0CEB0RE smokei4 {This smokei has matches}
BEuIN
WBILE (not_ueau) B0
BEuIN
wait(tobacco_papei);
smoke;
signal(uone_smoking);
ENB;
ENB;

2. Noie than one agent
We uo not neeu to change the coue of the agent. Although the agents
may cause a iace conuition, it is haimless to the oveiall system anu
theie is no iace conuition.

S. Noie than thiee tobacco-ielateu piouucts
If we keep the mouel as the same as befoie (each smokei still have
one infinite iesouice anu agent geneiate N-1 ingieuients), we neeu
change the stiuctuie of the semaphoie.
Foi example, if the ingieuients aie: tobacco, papei, match anu spice

PR0CEB0RE agent
BEuIN
WBILE (making_money) B0
BEuIN
CASE (ianuom(1,S)) 0F
1: signal(tobacco_papei_match);
2: signal(tobacco_papei_spice);
S: signal(tobacco_matches_spice);
ENB;
wait(uone_smoking);
ENB;
ENB;

PR0CEB0RE smokei1 { This smokei has matches }
BEuIN
WBILE (not_ueau) B0
BEuIN
wait(tobacco_papei_match);
smoke;
signal(uone_smoking);
ENB;
ENB;

c) If we move the wait(uone_smoking) befoie the CASE statement, it may cause
ueaulock at the fiist time wheie the agent is waiting foi uone_smoking anu
smokeis aie waiting foi ingieuient. We can change the uone_smoking initial
value to 1 to pievent the ueaulock.
BEuIN
tobacco_papei := u;
tobacco_matches := u;
papei_matches := u;
uone_smoking := 1;
ENB.

Anda mungkin juga menyukai