UNIVERSITY OF BAHRAIN

advertisement
UNIVERSITY OF BAHRAIN
COLLEGE OF INFORMATION TECHNOLOGY
DEPARTMENT OF COMPUTER SCIENCE
ITCS 322 – Operating Systems
FINAL EXAM
Semester I, 2005-2006
Time Allowed: 2 Hours
Student Name
Student I.D.
[1]
[2]
Section
Please tick one
Question 1
30
Question 2
10
Question 3
05
Question 4
10
Question 5
05
TOTAL
60
Notes:
 Please make sure that you write your FULL NAME, ID and Section number before you
start the paper.
 Write your answers in the space provided for the purpose.
 Answers for Question1 should be written on page 2.
 You must switch off your mobile before starting the examination.
1/10
Question 1 [30 points]
Write the correct answers for question 1 in the table below.
Q#
Correct choice
(a, b, c, or d)
Q#
1
15
2
16
3
17
4
18
5
19
6
20
7
21
8
22
9
23
10
24
11
25
12
26
13
27
Correct choice
(a,b,c, or d)
14
2/10
Select the best answer for the following and write your answers on the table given on the
previous page (don’t tick here).
1. Total number of frames currently allocated to a process may increase or decrease
when a fault happens and a
a. Global replacement strategy is used
b. Local replacement strategy is used
c. First-come-first out is used
d. Least recently used strategy is used
2. Which of the following is not correct about Copy on Write?
a. In copy on write, when a process is created then both the parent and child
processes share all the pages
b. A copy of a page is made when a process updates a page
c. The amount of memory allocated to the child process when it is created is
less than the memory allocated to the parent process.
d. The newly created process shares all the pages, stack, data, and PCB with
the parent process.
3. Which
a.
b.
c.
d.
of the following is not correct about the use of virtual memory?
The program that are larger than physical memory can run
Virtual memory allows higher multiprogramming level than pure paging
The program turn around time increases as compared to pure paging
It is difficult to share pages as compared to pure paging
4. Assume a system has a total 250 frames. There are three processes having sizes
P1=150 pages, P2=175 pages, and P3=80 pages. If process P2 is allocated 108 pages,
then which technique is used to decide how many frames/memory should be
allocated to each process?
a. Proportional memory allocation
b. Fixed memory allocation
c. Equal memory allocation
d. Priority-based memory allocation
5. Which of the following page replacement algorithm gives minimum number of page
faults?
a. Optimal allocation
b. Least-recently Used
c. First-in-First-Out
d. All of the above
6. According to the Belady’s Anomaly, increasing the number of frames may
a. Increase the number of page faults
b. Decrease the number of page faults
c. Not decrease the number of page faults
d. Not increase the number of page faults
7. To implement virtual memory, we need to associated a valid-invalid bit with every
a. Entry of the page table
b. Entry of frames
c. Every page-map table
d. Every page of a process that is partially loaded into the memory.
3/10
8. Virtual memory can be implemented with
a. Reference memory
b. Demand paging
c. Demand page table
d. Demand segment table
9. Which of the following types of loader is required for loading a code that relative
addresses?
a. Absolute loader
b. Dynamic loader
c. Relative loader
d. None the above
10. A relocatable code and data is bound to memory at
a. Load time
b. Compile time
c. Both (a) and (b)
d. None of the above
11. Which
a.
b.
c.
d.
of the following is not a contiguous memory allocation technique?
MVT
Fixed size multiple partition scheme
Paging
Compaction
12. Which of the following technique(s) can be used to solve the problem of external
fragmentation?
a. Compaction
b. Paging
c. Segmentation
d. All of the above
13. Compaction is possible only if relocation is static, and is done at execution time.
a. True
b. False
14. The two memory access problem can be used by using
a. Cache memory
b. Page table
c. Segment table
d. None of the above
15. Which
a.
b.
c.
d.
of the following is a shared resource?
Printer
File
CPU
All of the above
16. In deadlock avoidance techniques, a request for a resource is immediately granted
by the operating system if that resource is free.
a. True
b. False
4/10
17. We have a system that has two processing running and there is one reusable
resource and one consumable resource. Can this enter into a deadlock?
a. Yes
b. No
18. According to the non-preemption condition (for deadlock)
a. Only one process can use the a resource at a time
b. A process requests can request for a resource if it already allocated one or
more resources
c. A resource is released by a process voluntarily
d. None of the above
19. Which of the following algorithm can be used to deny hold-and-wait condition to
prevent a deadlock to happen?
a. A process should request all the resources it needs at the start
b. A process that requests for a resource if it already hold some resources then
all the resources it already holds are taken back
c. If a process requests for additional resources which are not free, then the
required resources are taken back from the other process and given to the
requesting process
d. None of the above
20. Which
a.
b.
c.
of the following is TRUE?
First come first serve is not a fair disk scheduling algorithm.
SSTF may cause starvation
In C-SCAN scheduling, the disk arm serves the requests both from left-to
right and right-to-left movement
d. All of the above
21. In which of the following disk scheduling algorithms, head/arm moves as far as the
last request in each direction and then reverses the direction immediately?
a. Scan
b. C-Scan
c. C-Look
d. First come first serve
22. Consider an algorithm that allows processes to enter their critical section in a predefined order. Which of the following requirements for a critical-section problem
could be violated?
a. Mutual exclusion
b. Bounded wait
c. Circular wait
d. Progress
23. Consider we have the following holes: hole1: 15 KB, hole 2: 17KB, hole 3: 25 KB,
and hole 4: 27 KB. A new process having a size of 26 KB is to be loaded using the
First fit algorithm. Which hole will be allocated to this process?
a. Hole 1
b. Hole 2
c. Hole 3
d. Hole 4
5/10
24. Does the following algorithm have busy-wait?
Do {
flag[i]=true;
while(falg[j]) block;
Critical section
flag[i]=false
wakup;
Remainder section
} while(1);
a. Yes
b. No
25. If a logical address has 20 bits and the page size is 512 bytes, then what can be the
maximum number of pages a process can have?
[2 points]
a. 512 pages
b. 2048 pages
c. 1024 pages
d. None of the above
26. Consider a system uses 16-bit logical address with a page size of 1024 bytes. If the
logical address is 0000110000000011, what will be the physical address if the
page table for the process is given below
[2 points]
11
02
21
15
16
a.
b.
c.
d.
15363
1027
21507
None of above
27. Consider the following segment table for a process:
Base
1400
6400
9000
1000
[2 points]
Limit
1400
1024
128
128
What will be the physical address if the logical address is (2,130)?
a. 9130
b. 1130
c. 6530
d. None of above
6/10
Question 2 [10 points]
Consider an operating system uses a multi-level scheduling algorithm. The working of the
algorithm is as follows:
There are total 3 queues (Q0, Q1, and Q2). A new process is added to a queue based on its
type. An operating system processes goes to queue 0 (Q0). A process run by interactive
users (interactive process) goes to queue 1 (Q1) and all other processes go to queue 2 (Q2).
Queue 0 uses a round-robin algorithm with a time quantum 10 ms. Queue 1 uses a rounrobin algorithm with time quantum 15 ms. Queue 2 uses a non-preemptive priority
scheduling algorithm. The operating system executes a process from Q0. If Q0 is empty
then a process is selected from Q1. If both Q0 and Q1 are empty them a process is
executed from Q2. If a new process arrives in a high level queue while a process from a
low level queue is executing, then the currently running processes is immediately stopped
and put back in the same queue (i.e. at the end of the same queue).
Consider the following processes with their priorities, arrival time, and CPU bursts:
Process
Arrival time
P1
P2
P3
P4
P5
P6
0
7
18
20
21
27
CPU burst
(ms)
15
20
13
8
12
19
Process type
OS
Interactive
OS
Interactive
Background
Background
priority
10
8
Draw a Gantt chart showing the execution of each process.
7/10
Question 3. [5 point]
Consider we have two cooperating processes. These processes share variable x, y, and z.
One of the processes (only pseudo code) is given below.
int main(){
int m,n,i;
printf(“Enter the value of m,n”);
scanf(“%d %d”,&n, &m);
x=m;
y=n;
i=0;
Printf(“Entering the loop now:\n”);
while(i<n) {
z=x+y+i;
x++;
y++;
i++;
printf(“Going top of the loop again\n”);
}
Printf(“The job is done!!!!”);
}
Write the above program using algorithm 2 for mutual exclusion. To get the credit, you
MUST use the logic of algorithm 2 that the most suitable positions in your code. You should
also declare any variable that is required by your algorithm.
Your answer goes here
8/10
Question 4 [10 points]
Assume that we have five processes P1 through P4 and resource types R1 (5 instances), R2
(5 instances), and R3 (6 instances). State snapshot at time T0 is as follows:
Process
P1
P2
P3
P4
P5
Allocation
R1 R2 R3
2 0 2
1 1 1
0 1 0
1 1 1
0 1 0
Max
R1
2
2
3
2
2
R2
0
2
2
1
1
R3
2
2
3
2
0
Available
R1 R2 R3
1. What is the need matrix? Write your answer in the table below.
Process
Need
R1 R2 R3
P1
P2
P3
P4
P5
2. It is known that the above state is a safe state. A request P1(1,0,0) is
received. Use the Banker’s to decide whether this request should be
granted? You MUST use and SHOW all the steps of the Banker’s algorithm.
The steps of the safety algorithm used by the Banker’s algorithm MUST be
shown in the space provided above in the given tables.
9/10
Question 5 [5 points]
Assume a virtual memory system. There are total 3 frames. The reference string is as
follows:
1, 2, 3, 1, 5, 3, 5, 6, 1, 2, 3, 6, 3
Determine the number of page faults using OPT strategy. Show graphically the page
replacement process, step by step.
1
2
0
1
2
10/10
Download