Operating Systems Mid-term Exam for CS 571 at George Mason University - Fall 1995, Exams of Operating Systems

The mid-term exam for the operating systems course (cs 571) at george mason university, which was held in fall 1995. The exam covers various topics related to operating systems, including mutexes, condition variables, process management, memory management, and file systems. Students are required to answer questions related to implementing solaris mutexes and condition variables using semaphores, the behavior of cond wait calls, process resource allocation, forking a process, and page replacement policies.

Typology: Exams

Pre 2010

Uploaded on 02/10/2009

koofers-user-783
koofers-user-783 🇺🇸

10 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
GEORGE MASON UNIVERSITY
Computer Science Department
CS 571 Operating Systems
Fall 1995
Mid-term Exam
DUE DATE Nov 15
1. (a) Writepseudo-code forimplementingSolaris mutexesandcondition variablesusingsemaphores.
Specifically, you have to describe (i) what data structures would used to implement condition
variables and mutexes (assuming the existence of a semaphore data structure) and (ii) how the
mutex lock,mutex unlock,cond wait and cond signal calls would be implemented. 10
(b) Why is a cond wait call in Solaris always embedded in a while loop in which the conditionthat
caused the wait is being tested? How and why is this different from the way wait operations on
condition variables in a monitor are used? Give an example whichillustratesthe problems that
can occur if the cond wait call is not embedded in a while loop. 5
2. Consider the following snapshot of a system with 6 instances of resource
R
1, 3 instances of resource
R
2, 4 instances of resource
R
3, and 2 instances of resource
R
4.
Allocation Need Available
R
1
R
2
R
3
R
4
R
1
R
2
R
3
R
4
R
1
R
2
R
3
R
4
P
03011 1100 1020
P
20100 0112
P
31110 3100
P
41101 0010
P
50000 2110
Here the
Allocation
matrix shows the number of instances of a resource type allocated to a particular
process. Similarly, the
Need
matrix shows the number of instances of a resource that could be
requested by a particular process (in addition to the resources are already allocated to it). The
Available
vector shows the number of instances of each resource type that are currently free.
(a) The system is currently in a safe state. Explain why.
(b) Suppose process
P
5now requests an instance of resource
R
1. If the system is using a deadlock
avoidance approach, should this request be granted? Explain why or why not. (5)
3. (a) How long does it take to fork off a child process under the following conditions: text size = 100
Kbytes, data size = 20 Kbytes, stack size = 10 Kbytes, process table structure = 1 Kbytes, user
structure = 5 Kbytes. Reading and writing a 32-bit word from memory take 200 nanoseconds
each, and a kernel trap and return take 1 ms each. Assume that text segments are shared, and
that any other operations that are required take negligible time. 4
(b) How would the vfork call reduce this time? What is the disadvantage of using vfork?3
(c) What is copy-on-write? How would it reduce the time for forking a process? 3
4. A pure paging system has a page size of 512 words, a virtual memory of 512 pages numbered 0
through 511, and a physical memory of 10 page frames numbered 0 through 9. The 18-bit virtual
1
pf3

Partial preview of the text

Download Operating Systems Mid-term Exam for CS 571 at George Mason University - Fall 1995 and more Exams Operating Systems in PDF only on Docsity!

GEORGE MASON UNIVERSITY

Computer Science Department

CS 571 – Operating Systems

Fall 1995

Mid-term Exam

DUE DATE – Nov 15

  1. (a) Write pseudo-code for implementing Solaris mutexes and condition variables using semaphores. Specifically, you have to describe (i) what data structures would used to implement condition variables and mutexes (assuming the existence of a semaphore data structure) and (ii) how the mutex lock, mutex unlock, cond wait and cond signal calls would be implemented. 10 (b) Why is a cond wait call in Solaris always embedded in a while loop in which the condition that caused the wait is being tested? How and why is this different from the way wait operations on condition variables in a monitor are used? Give an example which illustrates the problems that can occur if the cond wait call is not embedded in a while loop. 5
  2. Consider the following snapshot of a system with 6 instances of resource R 1 , 3 instances of resource R 2 , 4 instances of resource R 3 , and 2 instances of resource R 4.

Allocation Need Available

R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 R 1 R 2 R 3 R 4 P 0 3 0 1 1 1 1 0 0 1 0 2 0 P 2 0 1 0 0 0 1 1 2 P 3 1 1 1 0 3 1 0 0 P 4 1 1 0 1 0 0 1 0 P 5 0 0 0 0 2 1 1 0

Here the Al l ocation matrix shows the number of instances of a resource type allocated to a particular process. Similarly, the N eed matrix shows the number of instances of a resource that could be requested by a particular process (in addition to the resources are already allocated to it). The Av ail abl e vector shows the number of instances of each resource type that are currently free.

(a) The system is currently in a safe state. Explain why. (b) Suppose process P 5 now requests an instance of resource R 1. If the system is using a deadlock avoidance approach, should this request be granted? Explain why or why not. (5)

  1. (a) How long does it take to fork off a child process under the following conditions: text size = 100 Kbytes, data size = 20 Kbytes, stack size = 10 Kbytes, process table structure = 1 Kbytes, user structure = 5 Kbytes. Reading and writing a 32-bit word from memory take 200 nanoseconds each, and a kernel trap and return take 1 ms each. Assume that text segments are shared, and that any other operations that are required take negligible time. 4 (b) How would the vfork call reduce this time? What is the disadvantage of using vfork? 3 (c) What is copy-on-write? How would it reduce the time for forking a process? 3
  2. A pure paging system has a page size of 512 words, a virtual memory of 512 pages numbered 0 through 511, and a physical memory of 10 page frames numbered 0 through 9. The 18-bit virtual

address is split up into two fields: the highest 9 bits are used as an index into the page table, and the remaining 9 bits are used as an offset into a page.

The current content of physical memory is as follows:

.. ..

Process A, PAGE 3

Process B, PAGE 10

Process B, PAGE 65

Process B, PAGE 9

Process A, PAGE 9

Assume that the page table for process A is stored in physical memory starting at location 0, while the page table for process B is stored in physical memory starting at location 512. Assume that one of the hardware registers is used as a page table base register , and that the process currently being executed is process A.

a. ASSUMING THAT PAGE TABLES CONTAIN PAGE FRAME NUMBERS (RATHER THAN PHYSICAL MEMORY ADDRESSES), show the current contents of the page tables for process A and process B. b. Assuming that address translation was done using an inverted page table, what would be the current contents of the inverted page table (show only the entries corresponding to the contents of memory as shown in the figure). c. What are the current contents of the page table base register? What actions would be taken by the operating system on a context switch from process A to process B?

For your information: 1536 = 512  3; 2048 = 512  4; 3072 = 512  6; 3584 = 512  7; 4608 = 512  9; 5120 = 512  10; 17408 = 512  34; 33280 = 512  65; 2 3 = 8; 2 4 = 16; 2 5 = 32; 2 6 = 64; 2 7 = 128; 2 8 = 256; 2 9 = 512; (10)