CMSC 412 Midterm #1 (Spring 2004)

 

 

 

 


Name _________________________

Signature ________________________


 

 

 

 

(1)  This exam is closed book, closed notes, and closed neighbor. No calculators are permitted. Violation of any of these rules will be considered academic dishonestly.

 

(2)  You have 70 minutes to complete this exam.  If you finish early, you may turn in your exam at the front of the room and leave.  However if you finish during the last ten minutes of the exam please remain seated until the end of the exam so you don't disturb others. Failure to follow this direction will result in points being deducted from your exam.

 

(3)  Write all answers on the exam.  If you need additional paper, I will provide it. Make sure your name is on any additional sheets.

 

(4)     Partial credit will be given for most questions assuming I can figure out what you were doing.

 

(5)     Please write neatly. Print your answers if your handwriting is hard to read.  If you write something, and wish to cross it out, simply put an X through it.  Please indicate if your answer continues onto another page.

 

 

 

 

 

 

Question

Possible

Score

1

20

 

2

20

 

3

20

 

4

20

 

5

20

 

Total

100

 

 

 


1.)                 (20 points) Define and explain the following terms:

a)                   interrupt

 

 

 

 

b)                   context switch

 

 

 

 

 

c)                   processor protection

 

 

 

 

 

d)                   bakery algorithm


2.)                 (20 points) Synchronization: Given an implementation of counting semaphores, implement binary semaphores (i.e. a V operation on a binary semaphore with a value of 1 does not change the value of the semaphore).  Show any variables or semaphores you use and their initial values.

Semaphore and variable declarations:

 

 

 

P():

 

 

 

 

 

 

 

 

 

V():

 

 


3.)                  (20 Points) A process may read/write share none, some, or all of its data (not instruction) memory with other processes. 

a)                   Give an example of why you might want each of these modes.

 

 

 

 

 

 

 

b)                   Even if a group of processes share their entire data segment, at least one region of memory needs to be unique to each process. What region and Why?

 

 

 

 

 

 

 

 

 


4.)                 (20 points) Message Passing

a)                   When identifying the destination for a message, one approach is to name the process explicitly suing a process id, another is to use an abstraction such as a mailbox or a named pipe.  Give one advantage of each approach.

 

 

 

 

 

b)                   When a send call returns, give two possible guarantees the operating system might make about where the message is.

 

 

 

 

 

 

c)                   Why might you want receive to have an optional timeout if no data is received in a designated period of time?


5.)                 (20 points) Project

a)                   Why did you have to make Print a system call in project #2 rather than simply calling the existing Print function defined in screen.c?

 

 

 

 

b)                   The project used Spawn_Program(<program name>) to implement process creation.  What would you have to change in the system to support UNIX style process creation with two system calls: Fork() followed by Exec(<program name>)?

 

 

 

 

 

 

c)                   When creating the initial stack frame for a new user mode process, you had to push Error Code (0) and Interrupt Number (0) onto the stack.  Why were these required?

 

 

Web Accessibility