CPS590_old_exam.pdf
CPS590_old_exam.pdf
NOTE: Actual test questions can differ significantly in content, scope, difficulty, number per chapter, choice type, etc.
Youmay also choose “E. None of these” for any question
1. The situationin which a runnable process is overlooked indefinitely by the scheduler, although it is able to proceed,
is:
A. mutual exclusion B. deadlock [C. starvation D. livelock
3. This relationship allows multiple server processes to provide concurrent service to various clients.
many-to-many B. one-to-many C. many-to-one D. one-to-one
4. Asemaphore for which processes are removed from the queue in FIFO order, is known as:
A. weak B. counting é strong D. binary
S. Inthe following description of the compare&swap instruction, what code should replace XX?
A. cldval=newval B. *word=newval
@oldval=*word D. *word=oldval
int compare_and
swap (int *word, int testval, int newval) ({
int oldval;
XX;
if (oldval == testval) *word = newval;
return oldval;
6. This is a memory word that is used as a synchronization mechanism. The application may check one or multiple bits
of the word:
A a monit(@an event flag C. abinary semaphore D.allofA,B,C
7. A monitor supports synchronization by the use of that are contained within the monitor and accessible
only within the monitor.
A.Vonditionvariables B.eventflags C.semaphores D. messages
8. Which of the following are potential issues when processes exhibit the relationship of cooperation by sharing (e.g., a
shared object):
A. deadlock B. starvation C. mutualexclusion@ all of A,B,Care potential issues
11. Resources may be classified as reusable or consumable. Consider the following 5 resources.
I. informationin /O buffers Il. signals
11l. main and secondary memory IV. devices V. processors
Which is the set of consumable resources?
@l, I B.LILIE Co LV DU IV, V
12. The following Claim matrix, Allocation matrix and Resource vector describe the state of a system consisting of 4
processes and 3 resources. The corresponding Available vector, Vis:
R1 R2 R3 R1 R2 R3 € R1 R2 R3 R1 R2 R3
Afo
1 [1] 8[7 276 ] 0o [1]o]
o [7 ]2]7 |
R1 R2 R3 R1 R2 R3
P11 0 0 P1 |1 0 0
P23 [1 |1 P23 [1 |1 R1 R2 R3
P31 |3 (3 [1 |2 (7 3 |6 |
P4 |0 0 3 P4 |0 0 3
Claim matrix C Allocation matrix A Resource vector R
13. With , only one process may use a resource at a time and no process may access a resource unit that has
been allocated to another process.
A. holdand wait@ mutual exclusion C. no pre-emption D. circular wait
14. The condition can be prevented by requiring that a process request all of its required resources at one
time and blocking the process until all requests can be granted simultaneously.
A. mutual exclusion @old and wait C. circular wait D. no pre-emption
15. The condition can be prevented by defining a linear ordering of resource types.
A. hold and wait B. no pre-emption C. mutual exclusion ircular wait
16. Consider the following statements about using shared memory for user-level interprocess communication (IPC) in
Linux.
I. shared memory is faster than pthread semaphores
I1. the programmer must provide mutual exclusion
I1l. more than one process can access the shared memory
Which of these statements are true?
A. none are true @l,u,m C.onlyl, I D.onlyll
DO THIS LATER
17. Consider the following statements about a named semaphore ona CS moon:
I. the semaphore name is found in directory /dev/shm/
Il. the semaphore can be deleted with the Linux “rm” command
I1l. the semaphore can be deleted with the C sem_unlink function
Which of these statements are true?
A. onlylll LILIE C.onlyl, Il D.onlyll
22. The page placement strategy which scans memory from the location of the last placement, and chooses the first
subsequent block that is large enough to satisfy the request is called:
A.last-fit B.best-fit @ next-fit D. first-fit
23. Suppose 1024=2*° KB of memory is to be partitioned using the Buddy System, with the smallest allocable block being
of size 128=27 KB. Suppose the first request is for 512=2° KB. After the request is filled, how many total blocks of
memory exist (both allocated and unallocated)?
2 B. 3 C. 4 D.5
24. A pthread mutex, M, is properly initialized to unlocked by this code:
C?p pthread_mutex_t M = PTHREAD_MUTEX_INITIALIZER;
. pthread_mutex_t M; pthread_mutex_init (M);
C. pthread_mutex_t M = pthread_mutex_init(1);
D. pthread_mutex_tM =INIT_MUTEX_LOCKED;
26. What does this statement do, and where would it occur?: pipe(fd)
A. creates anunnamed pipe from the bash shell creates anunnamed pipe froma C program
C. creates a pipe named fd from the bash shell D. creates a pipe named fd froma C program
28. Linux provides an implementation of semaphores available only within the kernel. They:
A. are more efficient than user-space semaphores B. are implemented as functions within the kernel
C. include reader-writer semaphores @all of A,B,C
29. Your text includes a solution to the Readers/Writers Problem. It is shown below in 2 columns, but it is one whole
(pseudocode) program. Lines P,Q,R,S should be:
A.) P: readcount++; Q: if (readcount==1) R: readcount--; S: if (readcount==0)
B. P:if (readcount==1) Q: readcount++; R: if (readcount==0) S: readcount--;
C. P: readcount--; Q: if (readcount==0) R: readcount++; S: if (readcount==1)
D. P:if (readcount==0) Q: readcount++; R: if (readcount==1) S: readcount--;