2002년 1학기 기말고사.

1. race condition 에 대해 설명하시오.

2. Java 를 이용하여 다음 class를 완성하시오.
3. 다음 코드를 수행시 나타날 수 있는 문제점에 대해 자유롭게 기술하시오.
~cpp 
class Mutex
{  }

class A extends Thread
{
	private Mutex first, second;

	public A(Mutex f, Mutex s) {
		first = f;
		second = s;
	}

	public void run () {
		synchronized (first) {
			// do something
			try {
				Thread.sleep(( (int)(3*Math.random()) )*1000);
			}
			catch (InterruptedException e) { }
			System.out.println("threadA got first mutex");
			synchronized (second) {
				// do something
				System.out.println ("threadA got second mutex");
			}
		}
	}
}

class B extends Thread
{
	private Mutex first, second;

	public B(Mutex f, Mutex s) {
		first = f;
		second = s;
	}

	public void run () {
		synchronized (second) {
		// do something
		try {
			Thread.sleep(( (int)(3*Math.random()) )*1000);
		}
		catch (InterruptedException e) {} 
		System.out.println ("threadB got second mutex");
		synchronized (first) {
			// do something
			System.out.println ("threadB got first mutex");
		}
	}
}

public class TestProgram
{
	public static void main (String[] args) {
		Mutex mutexX = new Mutex ();
		Mutex mutexY = new mutex ();

		A threadA = new A(mutexX, mutexY);
		B threadB = new B(mutexX, mutexY);

		threadA.start ();
		threadB.start ();
	}
}

4. Consider a paging system with the page table stored in memory.
5. Consider the following page reference string:
1, 2, 3, 4, 2, 1, 5, 6, 2, 1, 2, 3, 7, 6, 3, 2, 1, 2, 3, 6

How many page faults would occur for the following replacement algorithm, assuming one, three, five, seven frames? Remember all frames are initially empty, so your first unique pages will all cost one fault each.
6. Consider a file currently consisting of 100 blocks. Assume that the file control block(and the index block, in the case of indexed allocation) is already in memory, Calculate how many disk I/O operations are required for contiguous, linked and indexed (single-level) allocation strategies, if for one block, the following conditions hold. In the contiguous allocation case, assume that there is no room to grow in the beginning, but there is room to grow in the end. Assume that the block information to be added in stored in memory.

7. Suppose that a disk drive has 5000 cylinders, numbered 0 to 4999. The drive is currently serving a request at cylinder 143, and the previous requrest was at cylinder 125. The queue of pending requests, in FIFO order, is

86, 1470, 913, 1774, 948, 1509, 1022, 1750, 130

Starting from the current head position, what is the total distance (in cylinders) that the disk arm moves to satisfy all the pending requrests, for each of the following disk scheduling algorithms?

Retrieved from http://wiki.zeropage.org/wiki.php/OperatingSystemClass/Exam2002_2
last modified 2021-02-07 05:23:56