Practice Exam 2 - Operating Systems | COP 4600, Exams of Operating Systems

Material Type: Exam; Class: OPERATING SYSTEMS; Subject: COMPUTER PROGRAMMING; University: University of Florida; Term: Unknown 1989;

Typology: Exams

Pre 2010

Uploaded on 03/10/2009

koofers-user-m94
koofers-user-m94 🇺🇸

5

(1)

9 documents

1 / 3

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
COP4600 Practice Exam 2
1. When calling a synchronized method, what is the method required to own and
how many threads can own it?
a. The lock and a single thread.
2. What are the two conditions for a lock being released?
a. When the holder exits the synchronized method
b. During a wait() call
3. Explain the major difference between notify() and notifyAll().
a. Notify() randomly selects a process on the wait set and moves it to the
entry set.
b. NotifyAll() moves all processes on the wait() set to the entry set.
4. What 3 criteria must be ensured in order to use notify() over notifyAll().
a. All threads in the wait set must be waiting on the same condition.
b. At least one thread must benefit from the condition being met.
c. All sub-classes of the waiting type must ensure that a and b are true.
5. Is this a good product class for testing the Producer-Consumer problem?
Class Item {
Static private into nextSerialNumber = 0;
Private int serialNumber;
Public Item() {
serialNumber = nextSerialNumber++;
}
public String toString() {
return “Item # “ + serialNumber;
}
}
a. not a good product class for testing because nextSerialNumber++ is not
atomic. It’s a read – change – store. Thus, nextSerialNumber++ takes 3
clock cycles and if it is interrupted after the first read problems will arise.
6. What are two types of Voluntary Rescheduling?
a. Yield()
b. Sleep()
7. Which code segment terminates naturally?
a. Public void start() {
setAlive(true);
for(int i = 2; i < 100; i++)
x = x * i;
setAlive(false);
{
pf3

Partial preview of the text

Download Practice Exam 2 - Operating Systems | COP 4600 and more Exams Operating Systems in PDF only on Docsity!

COP4600 Practice Exam 2

  1. When calling a synchronized method, what is the method required to own and how many threads can own it? a. The lock and a single thread.
  2. What are the two conditions for a lock being released? a. When the holder exits the synchronized method b. During a wait() call
  3. Explain the major difference between notify() and notifyAll(). a. Notify() randomly selects a process on the wait set and moves it to the entry set. b. NotifyAll() moves all processes on the wait() set to the entry set.
  4. What 3 criteria must be ensured in order to use notify() over notifyAll(). a. All threads in the wait set must be waiting on the same condition. b. At least one thread must benefit from the condition being met. c. All sub-classes of the waiting type must ensure that a and b are true.
  5. Is this a good product class for testing the Producer-Consumer problem? Class Item { Static private into nextSerialNumber = 0; Private int serialNumber; Public Item() { serialNumber = nextSerialNumber++; } public String toString() { return “Item # “ + serialNumber; } } a. not a good product class for testing because nextSerialNumber++ is not atomic. It’s a read – change – store. Thus, nextSerialNumber++ takes 3 clock cycles and if it is interrupted after the first read problems will arise.
  6. What are two types of Voluntary Rescheduling? a. Yield() b. Sleep()
  7. Which code segment terminates naturally? a. Public void start() { setAlive(true); for(int i = 2; i < 100; i++) x = x * i; setAlive(false); {

b. public void start() { while(true) { for(int i = 2; i < 100; i++) x = x * i; } }

a. a is the correct answer

  1. What two types of threads will an interrupt wake up? a. Sleeping thread b. Waiting thread
  2. What is a semaphore and what are the 2 types. a. Signaling mechanism that does not require busy waiting b. Counting – used to access a finite resource that has multiple instances. c. Binary – used to access a resource with a single instance.
  3. What must 2 process establish in order to communicate with each other? a. The exchange messages by sending/receiving across a link
  4. List the properties of a communication link of Direct Communication. a. The link is established automatically b. The link is associated with a single pair of processes c. Between each pair, there exists exactly one link d. Typically bidirectional
  5. In indirect communication, where are messages directed to and received from? a. A mailbox
  6. Can processes communicate if they do not share a mailbox? a. No
  7. What are the two types of Inter-Process Communication? a. Direct Communication establishes a link b. Indirect Communication establishes a mailbox
  8. Contrast some of the link properties between the two types of InterProcess Communication. a. DC the link is automatically established, it is associated with only a single pair of processes and it is typically bidirectional. b. IDC the mailbox must be established manually, may be associated with multiple processes, and it can be uni– or bi–directional.
  9. Interrupt wakes up which two kinds of threads? a. A sleep() thread and a wait() thread