0% found this document useful (0 votes)
3 views

CPS590_old_exam.pdf

The document contains sample questions for a CPS590 final exam, covering topics such as process scheduling, interprocess communication, synchronization mechanisms, and memory management. Each question presents multiple-choice answers related to computer science concepts, including deadlock, semaphores, and the producer/consumer problem. The questions are designed to test knowledge on concurrency, resource allocation, and system operations.

Uploaded by

momeni.golsa2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

CPS590_old_exam.pdf

The document contains sample questions for a CPS590 final exam, covering topics such as process scheduling, interprocess communication, synchronization mechanisms, and memory management. Each question presents multiple-choice answers related to computer science concepts, including deadlock, semaphores, and the producer/consumer problem. The questions are designed to test knowledge on concurrency, resource allocation, and system operations.

Uploaded by

momeni.golsa2002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

CPS590 Final Exam Sample Questions

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

2. A means fortwo processes to exchange information is with the use of:


A. spinlocks B. event flags C. conditionvariables( D). messages

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

9. Which of these are true about the producer/consumer problem:


I. is one of the most common problems in concurrent processing
1. is one of the most uncommon problems in concurrent processing
I11. has no solution using semaphores
IV. the consumer takes items out of the buffer one at a time
AL LIV B.11, 11,1V c.1, @, v
10. Consider the readers/writers problem. Which of the following conditions must be satisfied:
I. multiple readers may simultaneously read from the file
1. multiple writers may simultaneously write to the file
I11. if a reader is reading from the file, no other reader may read it
IV. if a writer is writing to the file, no other writer may write to it
V. if a writer is writing to the file, no reader may read it
A LILIV,V B. I, 1,V C.l, v, v @, v,V

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

18. Consider the following 3 statements about Linux atomic operations:


I. they may be used to avoid simple race conditions in the kernel
Il. they execute without interruption on a uniprocessor system
I1l. they are implemented on multiprocessor and uniprocessor systems
Which of the statements are true?
A.onlyland Il B. only ! and Il C.onlyllandIl @_I,Ilandlll

19. Consider the following requirements.


I. relocation Il protection I1l. scheduling
IV. sharing V. logical organization VI. deadlock prevention
The concept of Memory Management satisfies which of these requirements?
AL LIV I,II, v,V c.i,m,v D.IvV, Vv, VI

20. A process’ page table maintains:


A. the start of the process’ location in physical memory
® a table of the process’ frames, indexed by the process’ pages
C. atable of the process’ pages, indexed by the process’ frames
D. the start of the process’ location in virtual memory

21. Which of the following may cause process relocation:


A. swapping the process out and backin B. memory compacting
C. suspending and un-suspending the process any of A,B,C

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;

25. Consider the following functions:


I.msgsnd Il. msgrev 11l msg_init 1V. msgget V. msg_send VI. msg_receive VII. msginit
Which are used in Linux System V message queues?
A. MILIV B. I,V VI cC.v,vi D.1, 1, Vi

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

27. The following is the end of a C program. What does it print?


AA @B CC DD
P = (int*) shmat (shmid, 0, 0);
for (int i=0,ch='A';1<5;1i++) *p++=ch++;
printf("%c”,*(p-4)); )}

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--;

int readcount; void writer() {


semaphore x = 1,wsem = 1; while (true){
void reader() { semWait (wsem);
while (true){ WRITEUNIT();
semWait (x); semSignal (wsem);
P }
Q }
semWait (wsem);
semSignal (x); void main() {
READUNIT(); readcount = 0;
semWait (x); parbegin (reader,writerx);
R }
-
semSignal (wsem);
semSignal (x);
}
}

You might also like