Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

單選題,共 14 題,一題 4 分。

1. Which of the following descriptions regarding the multithread models are


correct?
I. In One-to-One model, only one thread can access the kernel at a time on
multiprocessors.
II. In Many-to-One model, the entire process will block if a thread makes a
blocking system call.
III. In Many-to-Many model, the number of kernel threads can be specific to
either a particular application or a particular machine.
IV. In One-to-One model, developers can create as many user threads as
necessary.
V. The two-level model is a variation of the Many-to-Many model.
(A) II and III
(B) II, III, and IV
(C) I, II, IV, and V
(D) II, III, and V
(E) I, III, and V

2. One soft real-time system has five periodic tasks, with periods of 50, 100, 150,
200 and 300 msec each. Assume these tasks require 10, 25, 15, 40 and C mesc of
CPU time, respectively.
What is the largest value of C for the system to be schedulable?
(A) 65mesc(B) 70 mesc (C) 75 mesc (D) 80 mesc (E) 85 mesc

3. After executing the program shown below, what is the output on the screen?
main(){
int status;
printf(“A”);
if(fork()!=0){
waitpid(-1,&status,0);
printf(“B”);
}else{
printf(“C”);
}
printf(“D”)
}
(A) ABCDC (B)ACDBD (C)ABCCD (D)ACBDC
4. Which of the following was not given as a necessary condition for a deadlock to
occur?
(A) Avoidance
(B) Hold and Wait
(C) Mutual Exclusion
(D) Circular wait
5. Which of the following statement is true?
(A) Spinlocks are not appropriate for multi-core systems.
(B) Critical sections cannot be preserved by disabling kernel preemption.
(C) More than one process can be active within a monitor.
(D) Wait and signal of a counting semaphore cannot be implemented with
multiple binary semaphores.
(E) All of the above are incorrect.

6. Consider a two-processor system running three processes P1, P2 and P3. The
processes P1 and P2 run on the first CPU, while the process P3 runs on the
second CPU. All these three processes share one mutually exclusive resource.
Suppose that processes never migrate form a CPU to the other one. In terms of
CPU utilization and hardware cost, which one of the following design options is
improper?
(A) Using interrupt disabling to synchronize processes P1 and P2.
(B) Using interrupt disabling to synchronize processes P1 and P3.
(C) Using spin locks to synchronize processes P1 and P3.
(D) None of the above.

7. Which of the following statements is false?


(A) Working set theory can be used to control the level of multiprogramming.
(B) System calls are only executed with privileged instructions which are not
supposed to be used by user programs.
(C) The memory hierarchy does not always guarantee efficiency in information
retrieval.
(D) In practice, the SJF scheduling algorithm may not be optimal in average
waiting time.
(E) The technology of virtual memory system may fail for some specific CPU
instruction sets.
8. Which of the requirements for a solution to the critical-section problem are not
satisfied for the following program?
//lock is a shared data and initialized to 0
while(1){
key=1;
while(key){
atomic_swap(lock,key);
<Critical Section>
Lock=0;
<Remainder Section>
}
}
(A) Mutual Exclusion (B) Progress
(C) No preemption (D) Bounded Waiting

9. Consider the following snapshot of a system and use banker’s algorithm to


following questions.
Allocation Max Available
A B C D A B C D A B C D
P0 2 0 0 1 4 2 1 2 3 3 2 1
P1 3 1 2 1 5 2 5 2
P2 2 1 0 3 2 3 1 6
P3 1 3 1 2 1 4 2 4
P4 1 4 3 2 3 6 6 5
(1) If a request from process P1 arrives for (1, 1, 0, 0), can the request be
granted immediately?
(2) If a request from process p4 arrives for (0, 0, 2, 0), can the request be
granted immediately?
(A) a: yes, b: yes (B) a: yes, b: no
(C) a: no, b: yes (D) a: no, b: no

10. The banker’s algorithm is used for deadlock-avoidance. For a system with n
processes and m types of resources, what is the order of complexity of this
algorithm?
(A) m (B) n (C) mxn (D) m2xn (E) mxn2

11. Which of the following is not a necessary condition for the happening of a
deadlock?
(A) Mutual exclusion to resources
(B) Resources not released by a terminated process
(C) Resource hold and wait by processes
(D) Resource allocation without preemption
(E) Circular waiting in the resource allocation graph

12. Suppose that there is a machine with 32-bit addresses and a two-level page
table. Note that the first 10 bits of an address is an index into the first level page
table and the next 10 bits are an index into a second level page table. The page
tables are stored in memory and each entry in the page tables is 4 bytes. Suppose
the space allocated to a specific process is 64 Mbytes. How many pages are
occupied by this process?
(a) 226 pages
(b) 214 pages
(c) 212 pages
(d) 210 pages
(e) None of the above

13. Continued from the previous question.) How much space is occupied in memory
by the page tables for the specific process?
(a) 68 kbytes
(b) 64 kbytes
(c) 16 kbytes
(d) 4 kbytes
(e) None of the above

14. Consider a tiny paging system that has 16 KB physical memory, and the frame size
is 1 KB. Let the logical address have 16 bits. The page table uses single-level direct
index. Which one of the following is not correct?
(a) The frame number has 4 bits
(b) The page number has 6 bits
(c) There are 16 entries in the page table.
(d) A page-table entry stores a frame number
(e) The page table requires 320 bits, including the valid-invalid bits.

多選題,共 7 題,一題 4 分,錯一個選項該題零分。


15. Which are correct for deadlocks?
(A) In general, we cannot prevent deadlocks by denying the mutual-exclusion
condition.
(B) To ensure that the hold-and-wait condition never occurs, the protocol
requiring each process to request and be allocated all its resources before it
begins execution can work.
(C) For the deadlock-avoidance scheme, if a process requests a resource that is
currently available, it should be allocated to the process.
(D) If a resource-allocation graph has a cycle, then the system must be in a
deadlocked state.
(E) None of the above.

16. Which of the following statements on the concept of deadlocks is not correct?
(a) If we use banker’s algorithm to control the resource request and allocation, and
when we find the system is unsafe, and still grant the resource request, the system
will enter the deadlock state.
(b) If a deadlock situation arises, the four conditions of mutual exclusion, hold and
wait, no preemption, and circular wait must hold simultaneously.
(c) If there is a cycle of resource allocation graph for a system with single instance
resource, it will be in a deadlock state.
(d) If a system is in the safe state, it will not be in a deadlock state.
(e) If there is a cycle of resource allocation graph for a system with resource of
multiple instances, it may not be in a deadlock state.

17. Assume that the memory access time is 200 ns, the average page-fault service
time including page-fault time and twice memory access time is 10 ms, and the
page fault ratio is 15%.
(a) The effective access time is 1500170 ns.
(b) The effective access time is 1500180 ns.
(c) If we want the effective memory time is less than 100 μs, the page fault ratio must
be less than 0.15%.
(d) If we want the effective memory time is less than 50 μs, the page fault ratio is less
than 0.60%.
(e) None of the above.

18. Which of the following statements are correct?


(a) Spinlocks are appropriate for uni-processor systems.
(b) The critical-section problem could be solved by disabling interrupts while
accessing a shared variable in a uni-processor environment.
(c) Priority inheritance protocols can resolve race conditions in real time systems.
(d) A nonpreemptive kernel is free from race conditions on kernel data structures.
(e) The current Linux kernel is a nonpreemptive kernel and a process running in a
kernel mode could not be preempted.

19. Consider the page replacement algorithms FIFO (first-in first-out), LRU (least-
recently used), and OPT (optimal). Which of the following cases are possible?
(a) FIFO outperforms LRU
(b) LRU outperforms FIFO
(c) FIFO, LRU and OPT have the same number of page faults
(d) LRU causes more page faults with a larger number of here frames
(e) Implementing OPT in real operating systems

20. Which of the following statements are correct?


(a) Deadlock condition refers to the situation where several processes are currently
blocked waiting for some resources to be released by some of them.
(b) The “hold and wait” and “circular wait” requirement conditions are redundant and
thus one of them can be removed.
(c) Preemptive kernel design cannot prevent the deadlock problem with kernel data
structures from occurring in the kernel.
(d) For the banker’s algorithm to work correctly, when a new process enters the
system, it must declare the maximum number of instances of each resource type
that it may need; otherwise, this algorithm will fail.
(e) None of the above.

題組,共 4 題,一題 4 分。
21. Suppose that two long running processes, P1 and P2, are running in a system for
different users, and there are no other processes in the system Process P1
consists of three threads and process P2 consists of two threads. Assume that the
threads never block and that the processes are entirely resident in primary
memory.
1. What percentage of CPU time will process P1 get if the threads of the
P1 and P2 are kernel threads entirely?
i. 40% (B) 50% (C)60% (D)70%
2. What percentage of CPU time will process P2 get if the threads of the
P1 and P2 are user threads entirely?
i. 40% (B) 50% (C)60% (D)70%

22. Consider the following processes:


代號 Process Arrival Time Burst Time
A P1 0 6
B P2 2 4
C P3 3 2
D P4 5 8
(2) Suppose we are using a non-preemptive Shortest-Job-First scheduler.
i. Write the execution order of these processes.
(A) ABCD (B)ABDC (C) ABDC (D)ACBD
ii. What is the average waiting time?
(A) 3 (B) 4 (C) 5 (D) 6
(3) Now suppose we are using a preemptive Round-Robbin scheduler with a
time quantum of 4 units.
i. Write the execution order of these processes.
(A) ABCD (B) ABCAD (C) ACDB (D)ACBDB
ii. What is the average waiting time?
(A) 3 (B) 4 (C)5 (D) 6

You might also like