[理工] 一些OS題目
一些題目不會寫也不知從何找解答
只好來請教大家
1. List four situations in which CPU scheduling decisions may take place.
2. What is the reason, from the perspective of system security that OS should
not allow a process to simply disable/enable interrupt to achieve the mutual
exclusion of the critical section problem?
3.
3.1 Why a non-preemptive OS cannot assign the CPU occupied by a
busy-waiting process to another process?
3.2 Please use atomic operation Swap() to implement binary semaphore’s
two operations (Busy-waiting is fine).
3.3 Please use block() and wakeup() to implement semaphore’s two
operations with no busy waiting.
4. Use multilevel queue to design a scheduler which can distinguish I/O-bound
programs from CPU-bound program. Please explain how it can achieve the goal.
5. The following code guarantees bounded-waiting mutual exclusion which is
done by adding the highlighted code. Please explain how these highlighted
codes may achieve bounded-waiting mutual exclusion.
do{
waiting[i] = TRUE;
key=TRUE;
while( waiting[i] && key )
key = TestAndSet( &lock );
waiting[i] = FALSE;
// critical section
j = ( i+1 ) % n;
While( ( j!=i ) && !waiting[j] )
j = ( j+1 ) % n;
if( j == i )
lock = FALSE;
else
waiting[j] = FALSE;
// remainder section
} while( TRUE );
6. Illustrate the priority inversion problem and its solution.
7. Write down a code in which a parent process (P0) will create two
child process ( P1 and P2 ) such that P0 can send data to P1 via a pipe, P1
can send data to P2 via a pipe, P2 can send data to P0 via a pipe.
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 218.161.96.202
推
11/11 23:10, , 1F
11/11 23:10, 1F
推
11/11 23:15, , 2F
11/11 23:15, 2F
→
11/11 23:16, , 3F
11/11 23:16, 3F
→
11/11 23:16, , 4F
11/11 23:16, 4F
→
11/11 23:19, , 5F
11/11 23:19, 5F
→
11/11 23:20, , 6F
11/11 23:20, 6F
→
11/11 23:21, , 7F
11/11 23:21, 7F
→
11/11 23:21, , 8F
11/11 23:21, 8F
→
11/11 23:23, , 9F
11/11 23:23, 9F
→
11/11 23:25, , 10F
11/11 23:25, 10F
→
11/11 23:25, , 11F
11/11 23:25, 11F
→
11/11 23:28, , 12F
11/11 23:28, 12F
→
11/11 23:29, , 13F
11/11 23:29, 13F
→
11/11 23:29, , 14F
11/11 23:29, 14F
→
11/12 00:44, , 15F
11/12 00:44, 15F
→
11/12 00:45, , 16F
11/12 00:45, 16F
→
11/12 00:48, , 17F
11/12 00:48, 17F