Docsity

computer science operating system, Summaries of Computer Science

Toggle sidebar
bg1
Université d’Ottawa
Faculté de genie
École d’ingénierie et
de technologie de l’information
University of Ottawa
Faculty of Engineering
School of Information
Technology and Engineering
CSI 3131
Operating Systems
FINAL EXAM
Solution
Length of Examination: 3 hours April 29, 2010, 14:00
Professor: Gilbert Arbez
Name: _________________________________________________
Student Number: ___________
Closed book, no scientific calculators or other electronic devices (except simple calculators) are
allowed.
If you do not understand a question, clearly state an assumption and proceed.
At the end of the exam, when time is up:
- Stop working and turn your exam upside down.
- Remain silent.
- Do not move or speak until all exams have been picked up, and a TA or the Professor gives
the go-ahead to leave.
The exam consists of three (3) parts
Part 1 Short Answer Questions 10 points
Part 2 Theory Questions 20 points
Part 3 Problem Solving Questions 30 points
Total 60 points
Number of pages: 12
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download computer science operating system and more Summaries Computer Science in PDF only on Docsity!

Université d’Ottawa Faculté de genie

École d’ingénierie et de technologie de l’information

University of Ottawa Faculty of Engineering

School of Information Technology and Engineering

CSI 3131

Operating Systems

FINAL EXAM

Solution

Length of Examination: 3 hours April 29, 2010, 14:

Professor: Gilbert Arbez

Name: _________________________________________________

Student Number: ___________

Closed book, no scientific calculators or other electronic devices (except simple calculators) are allowed.

If you do not understand a question, clearly state an assumption and proceed. At the end of the exam, when time is up:

  • Stop working and turn your exam upside down.
  • Remain silent.
  • Do not move or speak until all exams have been picked up, and a TA or the Professor gives the go-ahead to leave.

The exam consists of three (3) parts

Part 1 Short Answer Questions 10 points Part 2 Theory Questions 20 points Part 3 Problem Solving Questions 30 points Total 60 points

Number of pages: 12

Short Answer Questions – (5 X 2 points = 10 points total)

Answer the following questions in the provided space. Answer with a few words or a single phrase.

  1. What type of variable are used in "monitors" to support synchronization of processes/threads?

Conditional variables.

  1. What file allocation method is used in the FAT file system?

Linked allocation.

  1. Name at least 2 areas in the OS where FCFS (first come first served) algorithm is available:

CPU scheduling, Disk Scheduling, Page Replament

  1. Give at least one advantage of virtual memory management over previous memory management schemes?

Process memory space can be larger than physical space. More processes can be loaded into physical memory – increase in multi-programming.

  1. How does a UNIX operating system allow communication between two processes running on different systems?

Sockets.

Part 3 – Problem solving questions (30 points)

Question 1 - Deadlock Avoidance (5 points)

The following system is a snapshot of 5 processes (P0 to P4) sharing 3 resources (R0 to R2).

Max =

P

P

P

P

P

0 1 2 0 0 1 2 7 5 6 6 5 4 3 5 0 6 5

R R R ⎧ ⎫ ⎪ ⎪ ⎪⎪ ⎪⎪ ⎨ ⎬ ⎪ ⎪ ⎪ ⎪ ⎪⎩ ⎪⎭

Allocated =

Available = { 2, 1, 0}

a. What is the total number of instances for each type of resource? R1 = 6 R2 = 7 R3 = 12

b. Complete the Needs matrix (i.e. show the amount of resources each process might need). Simply Max – Allocated:

Need =

c. Show that the system is in a safe state by completing the following table.

Process Need Allocated Work Finished

{2, 1, 0} {F, F, F, F,F}

P0 {0, 0, 0} {0, 0, 1} {2,1,1} {T, F, F, F, F}

P3 {2, 0, 0} {2, 3, 5} {4, 4, 6} {T, F, F, T, F}

P4 {0, 3, 2} {0, 3, 3} {4, 7, 9} {T, F, F, T, T}

P1 {0, 7, 5} {2, 0, 0} {6, 7, 9} {T, T, F, T, T}

P2 {6, 6, 2} {0, 0, 3} {6, 7, 12} {T, T, T, T, T}

d. If a request from P2 for the resources (0, 1, 0) arrives, can it be granted? Show how you arrived at your answer by updating the state of the system, and completing the table below. Indicate how the OS will treat the requesting process P2.

(0,1,0)< Need[2] = (6,6,2)

(0,1,0) < Availble = (2,1,0)

If request is accepted, are we in a safe state, apply safety algorithm:

Available = { 2, 0, 0 }

Max =

P

P

P

P

P

0 1 2 0 0 1 2 7 5 6 6 5 4 3 5 0 6 5

R R R ⎧ ⎫ ⎪ ⎪ ⎪⎪ ⎪⎪ ⎨ ⎬ ⎪ ⎪ ⎪ ⎪ ⎪⎩ ⎪⎭

Allocated =

Need =

Process Need Allocated Work Finished

{2, 0, 0} {F, F, F, F,F}

P0 {0, 0, 0} {0, 0, 1} {2,0,1} {T, F, F, F, F}

P3 {2, 0, 0} {2, 3, 5} {4, 3, 6} {T, F, F, T, F}

P4 {0, 3, 2} {0, 3, 3} {4, 6, 9} {T, F, F, T, T}

Not in a safe state: neither P1 nor P2 can now be satisfied, the request should not be granted. The process should be placed in the waiting state until a safe state can be entered.

(b) Virtual Memory Management (5 points) The following table shows how 4 physical frames allocated to a process have been loaded with its logical pages (at time 164). All values are numbered using decimal values and starting at 0. All timing values correspond to the number of clock ticks from the start of the process execution. The U bit is the use bit that is set whenever the loaded page is referenced.

Page Frame Number

Virtual Page Number

Time loaded Time Referenced U Bit

0 2 60 161 0 1 1 130 160 1 2 0 26 162 1 3 3 20 163 1

For each page replacement algorithm below, circle the virtual page numbers that cause a page fault in the given sequence of virtual page accesses. Under the page number that causes the page fault, show the page replacement by giving the new list of loaded virtual pages (i.e. the contents from the first column of the above table). It is not necessary to show the contents of the list for the virtual pages that do not cause a page fault.

Optimal 4 0 0 0 2 4 2 1 0 3 2

(among the virtual pages 2,1,0,3, 3 is the furthest in the future. At the end, we do not have enough information about the future to decide, we just know that 2 will not be replaced)

Clock 4 0 0 0 2 4 2 1 0 3 2

Assume that a pointer is initially set to Page Frame 2.

LRU 4 0 0 0 2 4 2 1 0 3 2

Question 3 - Semaphores (5 points)

Using semaphores simulate a unisex washroom with the following rules:

  1. Men and women cannot be in the washroom at the same time.
  2. At most 3 people can be in the washroom (either 3 men or 3 women).
  3. The method useWashroom()simulates a person using the washroom and called when the person has the right to enter and use the washroom according to rules 1 and 2.
  4. The method maleUse() is called by male "threads" to use the washroom; complete this method. (The method femaleUse() will be used by female "threads" and has the same logic.)
  5. In the method, use the following semaphores and variable; give initial values for them in the declarations below. a. Variable maleNum to denote the number of males that are allowed to use the washroom (either waiting for it because it is full, or already inside). b. Semaphore maleAccess and to control access to the variable (male threads will block on this Semaphore when women are in the washroom). c. Semaphore maleEnter and for controlling the number of males entering the washroom (men will block on this Semaphore when 3 men are in the washroom). d. Semaphore empty for gaining access to the washroom when the washroom is empty (this semaphore is used by both men and women threads) (Note, the method femaleUse() would used the variable femaleNum, semaphores femaleAccess and femaleEnter; and also the semaphore empty).
  6. Your solution must not deadlock, but do not worry about starvation.

// Semaphores/variable declarations: Show initial values

int maleNum = 0

Semaphore maleAccess= 1 , maleEnter= 3 , empty= 1

maleUse() {

maleAccess.wait()

maleNum++

if(maleNum == 1) empty.wait();

mailAccess.signal();

maleEnter.wait(); // only 3 at a time

useWashroom();

maleEnter.signal();

maleAccess.wait()

numMale--

if(numMale == 1) empty.signal();

mailAccess.signal();

}

MINIX File System

MINIX Inode Table inode # i_mode i_uid i_size i_time i_gid i_nlinks i_zone[0..8]

128 2 524

2 0100 000111 101 101^224 5

3 0100 000111 101 101^128 2

4 0100 000111 101 101^192 3

5 0100 000111 101 101^128 2

6 0100 000111 101 101^128 2

7 0100 000111 101 101^128 2

8 1000 000110 100 100^2496 1 564, 565, 566

9 1000 000110 100 100^5120 1 556, 557, 558, 559, 560

10 1000 000110 100 100^5120 1 544, 545, 546, 547, 548

11 1000 000110 100 100^2496 4 561, 562, 563

12 1000 000110 100 100^16640 1 569, 570, 595, 596, 597, 598,599, 600

13 1000 000110 100 100^448 1

14 1000 000110 100 100^448 1

15 1000 000110 100 100^5120 1 567,568,577,578, 579

16 1000 000110 100 100^1664 1 614, 615

17 1000 000110 100 100^5120 1 588, 610, 611, 612, 613

MINIX Directory Tables

Directory: root

Ino Name

3 bohr

2 plank

Directory: bohr Directory:plank

Ino Name Ino Name

8 atom 10 blackbody

9 hydrogen 11 constant

5 deBroglie

6 einstein

4 schrodinger

Directory: deBroglie Directory:einstein

Ino Name Ino Name

13 duality 12 photon

11 planksConstant 11 plConstant