Exam 1
Section I
|
Process |
Burst Time |
Priority |
|
P1 |
8 |
3 |
|
P2 |
1 |
1 |
|
P3 |
2 |
3 |
|
P4 |
1 |
4 |
|
P5 |
7 |
2 |
The processes are assumed to have arrived in the order P1, P2, P3, P4, P5,all at time 0.
Gantt diagram FCFS:
|
P1 |
P2 |
P3 |
P4 |
P5 |
Gantt diagram SJF:
|
P2 |
P4 |
P3 |
P5 |
P1 |
Gantt diagram non-preemtive priority:
|
P2 |
P5 |
P1 |
P3 |
P4 |
Gantt diagram RR:
|
P1 |
P2 |
P3 |
P4 |
P5 |
P1 |
P3 |
P5 |
P1 |
P5 |
P1 |
P5 |
P1 |
P5 |
P1 |
P5 |
P1 |
P5 |
P1 |
Turnaround times:
|
FCFS |
SJF |
Priority |
RR |
||||||
|
P1 |
8 |
19 |
16 |
19 |
|||||
|
P2 |
9 |
1 |
1 |
2 |
|||||
|
P3 |
11 |
4 |
18 |
7 |
|||||
|
P4 |
12 |
2 |
19 |
4 |
|||||
|
P5 |
19 |
11 |
8 |
18 |
|||||
Waiting times:
|
FCFS |
SJF |
Priority |
RR |
||||||
|
P1 |
0 |
11 |
8 |
11 |
|||||
|
P2 |
8 |
0 |
0 |
1 |
|||||
|
P3 |
9 |
2 |
16 |
5 |
|||||
|
P4 |
11 |
1 |
18 |
3 |
|||||
|
P5 |
12 |
4 |
1 |
11 |
|||||
|
FCFS |
SJF |
Priority |
RR |
|
|
Average time |
8.0 |
3.6 |
8.6 |
6.2 |
The schedule with the minimum average waiting time is:
|
SJF (3.6) |
Section II
Answer for question 2:
The cache mechanism is a high speed buffer placed in-between two types of memory with different speed characteristics. Examples of cache: processor cache (in-between registers and RAM), disk cache (in-between RAM and disk), etc. Every time a piece of information is required from the slow memory, this piece of information will be stored in the cache memory as well. The idea is that next time the same piece of information will be needed, it will be available in cache and access to the slower memory will not be necessary.
Caches are useful because they can eliminate the need for access to a slower memory device and substitute that with an access to the high speed buffer which is the cache itself.
Caches are useful in practice because programs exhibit "locality" properties. In other words, when an instruction or data is needed, there is a good probability that another piece of information situated in the same memory area will be needed in the near future (keep in mind that most program instructions are executed sequentially i.e. one after another).
Caches allow a system formed with two types of memory (a slow, less expensive one and a fast, more expensive one) to exhibit performances which combine the good characteristics of the two types of memory. In other words, a system with cache will exibit a speed close to the speed of the faster device at a cost close to the cost of the less expensive one.
Coherency and consistency. The same piece of information can be stored in different places at the same time (disk, cache, memory, for instance). Care needs to be taken to make sure that when the information is changed in one place, the change is propagated through the system. More difficulties arise in a multiprocessor environment when many processors could be using the same information at the same time.
The device cannot be eliminated because the cache is volatile and expensive.
The main advantage of the cache is that it offers high speed access at low cost per byte. If we substitute the low cost device with high speed, high cost cache, this advantage is lost.
Solve ONE problem of your choice between 3 (bounded buffer) and 4 (sleeping barber). One problem is compulsory. If you solve BOTH correctly, you obtain extra credit.
Solution (bounded buffer):
Shared resources:
object item, buffer[N]
int in, out
semaphore full = 0, empty = n, mutex=1
Pseudo-code:
Producer:
repeat
produce next item
wait( empty )
wait( mutex )
buffer[ in ] = next item
index = in +1 mod n
signal( mutex )
signal( full )
until false
Consumer:
repeat
wait( full )
wait( mutex )
read buffer[ out ]
out = out + 1 mod n
signal( mutex )
signal( empty )
until false
Solution (sleeping barber):
Shared resources:
object chair[ N ],
int customer_counter = 0
semaphore mutex = 1, barber_asleep = 0
Pseudo-code:
Barber:
repeat
wait( barber_asleep ) /* wait if no customers */
wait( mutex ) /* wait if someone is modifying customer_counter */
customer_counter = customer_counter - 1 /* decrement the # of waiting people */
signal( mutex ) /* allow other people to modify customer_counter */
shave customer
until false
Customer
repeat
wait( mutex ) /* wait if someone is modifying customer_counter */
if( customer_counter == n ) then
signal(mutex)
exit
else
sit in chair[ customer_counter +1 mod d ] /* take a sit */
signal( mutex ) /* allow other people to modify customer_counter */
signal( barber_asleep ) /* wake up barber if sleeping */
until false
Section III - Multiple choice. Circle the correct answer. There is just one correct answer. If you circle more than one, you will not get any credit for that particular question.
1) A multiuser operating system is an operating system that:
2) A multitasking operating system is an operating system that:
3) A time sharing operating system is an operating system that:
4) The portability of an operating system means that:
5) A multiuser operating system has to be also:
6) A multitasking system has to be:
7) When talking about an operating system, the "kernel" is:
8) What is the relationship between files and directories:
9) An operating system is:
10) What are the similarities between a network of personal computers and a mini-computer using a multiuser operating system:
11) What are the differences between a network of personal computers and a mini-computer using a multiuser operating system:
Grading:
Problem 1: 100 points
Problem 2: 100 points
Problem 3: 100 points
Problem 4: 100 points
Multiple choice (16 questions): 100 points
Final grade: (P1+P2+P3+P4+P5)/4
Maximum obtainable (if you solve both problem 3 and 4): 125%
![]()