2002λ
1νκΈ° κΈ°λ§κ³ μ¬.
1. race condition μ λν΄ μ€λͺ
νμμ€.
2. Java λ₯Ό μ΄μ©νμ¬ λ€μ classλ₯Ό μμ±νμμ€.
- countable semaphore class λ₯Ό ꡬν. λ¨, default μμ±μμμ μΈλ§ν¬μ΄ κ°μ 0μΌλ‘ μ€μ .
- μμμ μμ±λ classλ₯Ό μμλ°μμ binary semaphore class λ₯Ό ꡬν.
~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.
- If a memory reference takes 200 nanoseconds, how long does a paged memory reference take?
- If we add associative registers and 75 percent of all page-table references are found in the associative regsters, what is the effective memory time? (Assume that finding a page-table entry in the associative registers takes zero time, if the entry is there)
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.- LRU replacement
- FIFO replacement
- Optimal replacement
- The block is added at the beginning.
- The block is added in the middle.
- The block is added at the end.
- The block is removed from the beginning.
- The block is removed from the middle.
- The block is removed from the end.
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?
- FCFS
- SSTF
- SCAN
- LOCK
- C-SCAN