wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Process Synchronization Sec 05

Total questions: 32

Worksheet time: 16mins

Name
Class
Date
1.

For cooperating process, _________ process produces information that is consumed by a ___________ process.

a)

consumer, producer

b)

producer, consumer

c)

independent, consumer

d)

cooperating, consumer

2.
Process synchronization can be done on

a)
 hardware level
b)
software level

c)
both hardware and software level

d)
none of the mentioned
3.
When several processes access the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called

a)
dynamic condition
b)
race condition

c)
essential condition

d)
critical condition
4.
Which process can be affected by other processes executing in the system?

a)
 cooperating process
b)
child process
c)
parent process
d)
init process
5.
Which one of the following is a synchronization tool?

a)
thread
b)
pipe
c)
semaphore

d)
socket
6.
If a process is executing in its critical section, then no other processes can be executing in their critical section. This condition is called
a)
mutual exclusion

b)
critical exclusion

c)
synchronous exclusion

d)
asynchronous exclusion
7.

When two process executing ___________ and trying to access the _______ global variable, this is a __________.

a)

simultaneously, same, race condition

b)

simultaneously, different, race condition

c)

concurrently, same, producer-consumer problem

d)

concurrently, different, producer-consumer problem

8.

A web server provides HTML files which is received by the client web browser requesting the resource. Here, __________ is the producer and _________ is the consumer.

a)

HTML file, web server

b)

web server, HTML files

c)

web browser, web server

d)

web server, web browser

9.

To enable producer and consumer to execute concurrently, a buffer must be used. What is the buffer for?

a)

For producer to put data while consumer access it

b)

For consumer to put data while producer access it

c)

For producer to run data while consumer retrieve it

d)

For consumer to run data while producer retrieve it

10.

Buffer works as a shared memory, and counter keeps track of the number of full buffers. Counter is ________ by the ________ after it produces a new buffer, and is ________ by the ________ after it consumes a buffer.

a)

decremented, producer, incremented, consumer

b)

decremented, consumer, incremented, producer

c)

incremented, producer, decremented, consumer

d)

incremented, consumer, decremented, producer

11.

Producer puts data in one slot while consumer retrieve data from another slot. Producer and consumer need to be synchronized so that _________.

a)

producer will not retrieve data after consumer puts the data into the buffer

b)

producer will not retrieve data before consumer puts the data into the buffer

c)

consumer will not retrieve data after producer puts the data into the buffer

d)

consumer will not retrieve data before producer puts the data into the buffer

12.

Based on the figure above, if producer and consumer are properly synchronized, what is the value of counter?

a)

2

b)

3

c)

4

d)

5

13.

Which statement(s) is TRUE in explaining race condition problem?

a)

A situation whereby at least two processes perform some operations on shared data and the outcome depends on the order of data access

b)

A situation whereby multiple threads access a data item without coordination in a multithreaded application

c)

Coordinating the activities of two or more processes is the solution to race condition

d)

The process of coordinating the activities of two or more processes is called process coordination

14.

Each process must ask permission to enter critical section in _______ code; it then executes in the _______; once it finishes executing, it enters the _______ code. The process then enters the ________ code

a)

entry section, critical section, exit section, remainder section

b)

entry section, exit section, critical section, remainder section

c)

critical section, entry section, exit section, remainder section

d)

critical section, entry section, remainder section, exit section

15.

Entry section to cs is to __________ and exit section is to ___________.

a)

enable interrupts, disable interrupts

b)

enable interrupts, progress interrupts

c)

disable interrupts, enable interrupts

d)

progress interrupts, enable interrupts

16.

The figure illustrates the process structure of critical section. At t2, in the blank box, what happen to B?

a)

B is enabling an interrupt to cs

b)

B is attempting to enter cs

c)

B is disabling an interrupt to cs

d)

B is attempting to preempt A

17.

In order to solve cs problem, an algorithm must satisfy the three essential criteria. What are they?

a)

mutual exclusion, no preemption, bounded waiting

b)

mutual exclusion, progress, hold and wait

c)

mutual exclusion, progress, bounded waiting

d)

mutual exclusion, no preemption, progress

18.

What are the 4 types of locking mechanism to solve cs problem?

a)

software defined, hardware support, support from os, support from programming language

b)

software defined, resource support, support from hardware, support from programming language

c)

software defined, resource support, support from memory, support from programming language

d)

software defined, software support, support from resource, support from programming language

19.

From the figure above, at which line of code does P0 performs busy waiting?

a)

flag[0] = TRUE

b)

turn = 1

c)

while (flag[1] && turm == 1);

d)

flag[0] = FALSE

20.

In Peterson's algorithm, two processes share two variables which are turn and flag. What does variable turn do?

a)

to indicate if a process is ready to enter the cs

b)

to indicate if a process is doing busy waiting

c)

to indicate whose turn is it to wait

d)

to indicate whose turn it is to enter the cs

21.

The table above shows a process that can enter its cs for different values of flag[ ] and turn. Define a), b), c) and d)

a)

false, false, P0, true

b)

false, false, P1, true

c)

true, false, P0, true

d)

true, false, P1, false

22.

Which one of the cs requirement that Peterson's algorithm are met?

a)

mutual exclusion, bounded waiting

b)

progress, bounded waiting

c)

mutual exclusion, progress

d)

mutual exclusion, progress, bounded waiting

23.

Modern machines provide special atomic hardware instructions to implement locks. What does it mean by atomic?

a)

non-interruptible

b)

preemption

c)

concurrent

d)

preserved

24.

The code segment above is Test and Set algorithm. Lock is set to false at initial. What does this mean?

a)

there is a process in the cs

b)

there is no process in the cs

c)

there is a process doing busy waiting

d)

there is a process entering the cs

25.

Based on test and set algorithm above, when a process is allow to go into the cs, it would change the lock to ______. Later when the process ______ the cs, the lock is set to _____ to allow another process to enter its cs.

a)

false, exit, false

b)

true, exit, true

c)

true, exit, false

d)

false, exit, true

26.

Which one of the cs requirement that test and set algorithm met?

a)

mutual exclusion and progress

b)

mutual exclusion and bounded waiting

c)

progress and bounded waiting

d)

mutual exclusion, progress and bounded waiting

27.

Process 1 and Process 2 run concurrently using 2 semaphores. At start, both S1 and S2 are 0. What is the possible output from the cout statement?

a)

2 1 2 1 2 1 2 1 2 1

b)

1 2 1 2 1 2 1 2 1 2

c)

1 1 1 1 1 1 1 1 1 1

d)

2 2 2 2 2 2 2 2 2 2

28.

Semaphore has two different operations; ________ to _________ the value of semaphore by 1 and _________ to _________ the value of semaphore by 1.

a)

wait(), increment, signal(), decrement

b)

wait(), decrement, signal(), increment

c)

wakeup(), increment, block(), decrement

d)

block(), increment, wakeup(), decrement

29.

Semaphore can only have non negative values. At start, semaphore is always initialised to ____. When semaphore is ____, this implies that ________________.

a)

0, 1, there is no process in cs

b)

1, 0, there is no process in cs

c)

1, 0, there is a process in cs

d)

0, 1, there is a process in cs

30.

When semaphore s = 0, process must constantly check to see if semaphore is not zero so that it can enters cs. This is ______.

a)

mutual exclusion

b)

bounded waiting

c)

progress

d)

busy waiting

31.

Based on the figure above, determine a), b), c) and d)

a)

5, 6, 1, 1

b)

4, 5, 1, 1

c)

5, 5, 1, 0

d)

4, 6, 1, 1

32.

Incorrect use of semaphore can lead to _______ and _________.

a)

starvation, busy waiting

b)

deadlock, busy waiting

c)

deadlock, starvation

d)

bounded waiting, starvation