Final Examination TDDB 63/12: Concurrent Programming and Operating Systems

advertisement
TDDB63/12
Concurrent Programming and Operating Systems
Final Examination
TDDB 63/12: Concurrent Programming and
Operating Systems
Wednesday, 20 October, 1999, Time: 9:00
Instructor: Nancy Reed
Aids
No aids (books, notes, calculators etc.), except English dictionaries, are allowed.
Writing
Please write or print clearly. We will not give credit for unreadable answers. You may write
answers in English or Swedish (or a combination of the two).
Results
The results will be posted by 1 November 1999.
Assessment
0
20
28
35
–
–
–
–
19
27
34
40
Fail
3 (Pass)
4
5
or (C programme)
0 – 19
20 – 31
32 – 40
Fail
G (Pass)
VG
In case of questions
Nancy Reed can be reached at 28 26 68 during the examination.
Final Examination
1(4)
Fall 1999
TDDB63/12
Concurrent Programming and Operating Systems
1. Operating System Structures (4 p)
a)
What are system calls and how are they used? Justify your answer with an example. (2 p)
b) What three major factors are used when configuring a computer system to determine the number of
and size of different types of storage? Justify your answer by comparing at least 4 commonly used
types of storage. (2 p)
2. Processes and threads (4 p)
a) What happens when a context switch occurs? Diagram your explanation showing what the CPU is
doing at each point in time and what each process is doing at each time. (2 p)
b) Describe the concept of a thread. What differences are there between user level threads and kernel
level threads? How do these differences affect performance (give an example). (2 p)
3. CPU Scheduling (6 p)
Consider the following set of processes with arrival times and CPU execution times given in
milliseconds. A process with a larger priority number has a higher priority. State any assumptions
that you make.
a) Draw and label Gantt charts illustrating the execution of these processes using:
i) RR scheduling with a time quantum of 4 msec. (1 p)
ii) nonpreemptive SJF scheduling. (1 p)
iii) immediately preemptive priority (use FCFS when priorities are equal). (1 p)
iv) (non-immediately preemptive) priority scheduling with a time quantum of 8 msec. (1 p)
Process
P1
P2
P3
P4
P5
Arrival time
0
5
8
11
15
Execution time
12
19
21
13
15
Priority
3
3
5
2
3
b) Calculate the average waiting times for schedules i and ii above, ignoring priority values. Which
method gives a better waiting time for this data? (1 p)
c) For schedules iii and iv above, use each job’s priority as its weight and calculate the weighted
average waiting time. Which method gives better weighted average performance for this data? (1
p)
Final Examination
2(4)
Fall 1999
TDDB63/12
Concurrent Programming and Operating Systems
4. Synchronization (5 p)
a) Describe the four constraints Dijkstra placed on solutions to the critical section problem and why
they are necessary. (2 p)
b) The wine-making club problem. (3 p) Consider a wine-making club with 8 members and a
warehouse of supplies. For a member to make wine, they need to use: 2 carboys (jugs), 1 yeast lock,
sweetened fruit juice, and wine-making yeast. The initial mixing process requires a mixing station, the
fermentation process requires 4 weeks to produce wine once all three ingredients have been properly
mixed together. The second carboy is needed only at the end of the process to decant the wine off the
dead yeast. The warehouse contains 2 mixing stations, 6 carboys (10 liter size), 7 yeast locks, 15
containers of (5 liter size) of sweetened fruit juice, and 20 packages of wine yeast (for 10 liters of wine
each). Once a member has finished his/her wine, they all taste the batch before that member starts a
new batch.
Write a program that simulates the members of the club making wine. Each member should be
represented by a process. Use semaphores for synchronization. Use pseudocode, C++, or Pascal
syntax in your solution. Your solution must be free from deadlock, but need not be free from
starvation.
5. Deadlocks (6 p)
a) A resource allocation grid shows illegal, safe, and unsafe states for a sequence of requests (REQ)
and releases (REL) of resources for 2 processes. Draw a resource allocation grid like the one below
and identify the illegal (forbidden), safe, and unsafe states (assume the Banker’s algorithm is used)
for 2 processes, P1 and P2, with the following list of requests. All resources are unshareable. State
any assumptions you make. (3 p)
P1: REQ{c,e}, REL{c}, REQ{b,d}, REL{e},REL{d}, REL{b}
P2: REQ{a,e} REL{e}, REQ{b}, REQ{c}, REL{a,b},REL{c}
P2
1
3
2
P1
b) Explain how and why you determined the states of squares 1, 2, and 3. (3 p)
Final Examination
3(4)
Fall 1999
TDDB63/12
Concurrent Programming and Operating Systems
6. Virtual Memory (6 p)
a) Show the sequence of frames put into main memory with following reference string. Which gives
the lowest fault rate on this string? Why? (4 pt)
5 4 8 2 7 4 5 9 1 8 7 4 5 2 7
i. Using 3 available frames and the OPT algorithm.
ii. Using 3 available frames and the FIFO algorithm.
iii. Using 4 available frames and LRU.
iv. Using 5 available frames and FIFO.
b) What is meant by the term thrashing in a virtual memory system? Describe at least two ways to
detect and stop thrashing if it occurs. (2 pt)
7. File Systems (6 p)
a) What is a file? How does a computer identify the type of contents that are in a file? Describe at
least two methods used on typical Unix systems and one method used on DOS systems. (3 p)
b) Consider a file currently consisting of 50 blocks of information. Assume that the file control block
(and index block, in the case of indexed allocation) is already in memory. Calculate the number of
disk I/O operations required for contiguous, linked, and indexed allocation strategies to make the
following changes to the file. In the contiguous case, you may assume there is no space to grow in
the beginning, but there is room to grow at the end. Assume that the new information to be added
to the file is stored in memory. (3 p)
i) Add a block at the beginning of the file.
ii) Add a block at the end of the file.
iii) Remove a block from the middle of the file.
8. Protection and security (3 p)
a) What is authentication? Describe two fundamentally different schemes that can be used for
authentication. (2 p)
b) What is a computer virus and how are they spread? What is different about macro viruses
compared to other viruses?(1 p)
Final Examination
4(4)
Spring 1999
Download