Geschreven door studenten die geslaagd zijn Direct beschikbaar na je betaling Online lezen of als PDF Verkeerd document? Gratis ruilen 4,6 TrustPilot
logo-home
Tentamen (uitwerkingen)

CS 143A - EXERCISES + SOLUTIONS - University of California, Irvine CS 143A

Beoordeling
-
Verkocht
-
Pagina's
28
Cijfer
A+
Geüpload op
11-02-2023
Geschreven in
2022/2023

CS 143A : EXCERCISES Exercise 2.3.1: Creation hierarchy without linked lists. Processes 0-4 are related as follows: 1, 2, 3 are children of 0, and 4 is a child of 2. PCBs are implemented as an array indexed by the process number. Each PCB has the links: parent (p), first child (c), younger sibling (ys), and older sibling (os). (a) Complete the PCB array to show the values of the 4 links (p, c, ys, os) for all processes, to reflect the parent-child hierarchy. Solution The parent of process 0 is unknown (?). A dash means no index. Ex: Process 1 has no child (c) and no older siblings (os). Adarsh B Shankar COMPSCI 143A SS2 UCI ID: (b) Modify the array to reflect the creation of a new child, 5, of process 2. Solution The new child is created at index 5. Note that the parent process (2) is not modified in any way. Exercise 2.3.2: RL without linked lists. The RL can be implemented without dynamically managed linked lists by creating a new field, next, in each PCB, which points to the next PCB on the same list. Each entry of the RL then points to the first PCB on the list. (a) Assume that RL contains 3 processes at level 5 and 1 process at level 0. Draw a diagram showing the RL and the modified PCBs. Adarsh B Shankar COMPSCI 143A SS2 UCI ID: Exercise 2.3.3: A modified implementation of PCBs. Implementing the PCBs as an array is more efficient than using dynamic memory allocation. The drawback is that the array size must be kept relatively small. To overcome this drawback, the PCBs are implemented as fixed size array, PCB[n], where n is large enough most of the time. In the case where more processes need to be created, the array size n is temporarily extended to accommodate the spike. The extension is removed when the number of elements falls again below n. To compare the effectiveness of this scheme with a dynamic linked list implementation, assume the following values:  s is the time to perform one insert or remove operation in a linked list  r is the time to perform one insert or remove operation in the array  o is the over

Meer zien Lees minder
Instelling
Vak

Voorbeeld van de inhoud

Adarsh B Shankar COMPSCI 143A SS2
UCI ID: 11972805




CS 143A : EXCERCISES
Exercise 2.3.1: Creation hierarchy without linked lists.
Processes 0-4 are related as follows: 1, 2, 3 are children of 0, and 4 is a child
of 2. PCBs are implemented as an array indexed by the process number.
Each PCB has the links: parent (p), first child (c), younger sibling (ys), and
older sibling (os).
(a)
Complete the PCB array to show the values of the 4 links (p, c, ys, os) for all
processes, to reflect the parent-child hierarchy.




Solution
The parent of process 0 is unknown (?).
A dash means no index. Ex: Process 1 has no child (c) and no older siblings
(os).

,Adarsh B Shankar COMPSCI 143A SS2
UCI ID: 11972805

(b)
Modify the array to reflect the creation of a new child, 5, of process 2.
Solution
The new child is created at index 5.
Note that the parent process (2) is not modified in any way.




Exercise 2.3.2: RL without linked lists.
The RL can be implemented without dynamically managed linked lists by
creating a new field, next, in each PCB, which points to the next PCB on the
same list. Each entry of the RL then points to the first PCB on the list.
(a)
Assume that RL contains 3 processes at level 5 and 1 process at level 0.
Draw a diagram showing the RL and the modified PCBs.

, Adarsh B Shankar COMPSCI 143A SS2
UCI ID: 11972805

Exercise 2.3.3: A modified implementation of PCBs.
Implementing the PCBs as an array is more efficient than using dynamic
memory allocation. The drawback is that the array size must be kept relatively
small. To overcome this drawback, the PCBs are implemented as fixed size
array, PCB[n], where n is large enough most of the time. In the case where
more processes need to be created, the array size n is temporarily extended
to accommodate the spike. The extension is removed when the number of
elements falls again below n. To compare the effectiveness of this scheme
with a dynamic linked list implementation, assume the following values:

 s is the time to perform one insert or remove operation in a linked list
 r is the time to perform one insert or remove operation in the array
 o is the overhead time to temporarily extend the array
 p is the probability that any given insert operation will overrun the
normal array size n

(a)
Derive a formula for computing the value of p, below which the proposed
scheme will outperform the linked list implementation.
Solution

 With the linked list implementation, each insert or remove takes s
ms.
 With the array implementation, a remove takes r ms and each
insert takes r + o*p ms since the overhead of extending the array
occurs with probability p.
 Since half of all operations are inserts and half are removes, the
time for one operation is (r + r + o*p)/2.
 The break-even point is when the time for the implementations is
equal: s = (r + r + o*p)/2.
 Solving for p yields the probability p = (2s - 2r)/o

(b)
Compute the value of p when s = 10r and o = 100r.
Solution
p = (2*10r - 2r)100r = 18/100 = 0.18

Geschreven voor

Vak

Documentinformatie

Geüpload op
11 februari 2023
Aantal pagina's
28
Geschreven in
2022/2023
Type
Tentamen (uitwerkingen)
Bevat
Vragen en antwoorden

Onderwerpen

$11.99
Krijg toegang tot het volledige document:

Verkeerd document? Gratis ruilen Binnen 14 dagen na aankoop en voor het downloaden kun je een ander document kiezen. Je kunt het bedrag gewoon opnieuw besteden.
Geschreven door studenten die geslaagd zijn
Direct beschikbaar na je betaling
Online lezen of als PDF

Maak kennis met de verkoper

Seller avatar
De reputatie van een verkoper is gebaseerd op het aantal documenten dat iemand tegen betaling verkocht heeft en de beoordelingen die voor die items ontvangen zijn. Er zijn drie niveau’s te onderscheiden: brons, zilver en goud. Hoe beter de reputatie, hoe meer de kwaliteit van zijn of haar werk te vertrouwen is.
ExamsConnoisseur Self
Volgen Je moet ingelogd zijn om studenten of vakken te kunnen volgen
Verkocht
587
Lid sinds
3 jaar
Aantal volgers
344
Documenten
1492
Laatst verkocht
3 weken geleden

4.2

68 beoordelingen

5
40
4
11
3
13
2
1
1
3

Recent door jou bekeken

Waarom studenten kiezen voor Stuvia

Gemaakt door medestudenten, geverifieerd door reviews

Kwaliteit die je kunt vertrouwen: geschreven door studenten die slaagden en beoordeeld door anderen die dit document gebruikten.

Niet tevreden? Kies een ander document

Geen zorgen! Je kunt voor hetzelfde geld direct een ander document kiezen dat beter past bij wat je zoekt.

Betaal zoals je wilt, start meteen met leren

Geen abonnement, geen verplichtingen. Betaal zoals je gewend bent via iDeal of creditcard en download je PDF-document meteen.

Student with book image

“Gekocht, gedownload en geslaagd. Zo makkelijk kan het dus zijn.”

Alisha Student

Bezig met je bronvermelding?

Maak nauwkeurige citaten in APA, MLA en Harvard met onze gratis bronnengenerator.

Bezig met je bronvermelding?

Veelgestelde vragen