WorksheetsProcess Synchronization Sec 05
Total questions: 32
Worksheet time: 16mins
For cooperating process, _________ process produces information that is consumed by a ___________ process.
consumer, producer
producer, consumer
independent, consumer
cooperating, consumer
When two process executing ___________ and trying to access the _______ global variable, this is a __________.
simultaneously, same, race condition
simultaneously, different, race condition
concurrently, same, producer-consumer problem
concurrently, different, producer-consumer problem
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.
HTML file, web server
web server, HTML files
web browser, web server
web server, web browser
To enable producer and consumer to execute concurrently, a buffer must be used. What is the buffer for?
For producer to put data while consumer access it
For consumer to put data while producer access it
For producer to run data while consumer retrieve it
For consumer to run data while producer retrieve it
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.
decremented, producer, incremented, consumer
decremented, consumer, incremented, producer
incremented, producer, decremented, consumer
incremented, consumer, decremented, producer
Producer puts data in one slot while consumer retrieve data from another slot. Producer and consumer need to be synchronized so that _________.
producer will not retrieve data after consumer puts the data into the buffer
producer will not retrieve data before consumer puts the data into the buffer
consumer will not retrieve data after producer puts the data into the buffer
consumer will not retrieve data before producer puts the data into the buffer
Based on the figure above, if producer and consumer are properly synchronized, what is the value of counter?
2
3
4
5
Which statement(s) is TRUE in explaining race condition problem?
A situation whereby at least two processes perform some operations on shared data and the outcome depends on the order of data access
A situation whereby multiple threads access a data item without coordination in a multithreaded application
Coordinating the activities of two or more processes is the solution to race condition
The process of coordinating the activities of two or more processes is called process coordination
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
entry section, critical section, exit section, remainder section
entry section, exit section, critical section, remainder section
critical section, entry section, exit section, remainder section
critical section, entry section, remainder section, exit section
Entry section to cs is to __________ and exit section is to ___________.
enable interrupts, disable interrupts
enable interrupts, progress interrupts
disable interrupts, enable interrupts
progress interrupts, enable interrupts
The figure illustrates the process structure of critical section. At t2, in the blank box, what happen to B?
B is enabling an interrupt to cs
B is attempting to enter cs
B is disabling an interrupt to cs
B is attempting to preempt A
In order to solve cs problem, an algorithm must satisfy the three essential criteria. What are they?
mutual exclusion, no preemption, bounded waiting
mutual exclusion, progress, hold and wait
mutual exclusion, progress, bounded waiting
mutual exclusion, no preemption, progress
What are the 4 types of locking mechanism to solve cs problem?
software defined, hardware support, support from os, support from programming language
software defined, resource support, support from hardware, support from programming language
software defined, resource support, support from memory, support from programming language
software defined, software support, support from resource, support from programming language
From the figure above, at which line of code does P0 performs busy waiting?
flag[0] = TRUE
turn = 1
while (flag[1] && turm == 1);
flag[0] = FALSE
In Peterson's algorithm, two processes share two variables which are turn and flag. What does variable turn do?
to indicate if a process is ready to enter the cs
to indicate if a process is doing busy waiting
to indicate whose turn is it to wait
to indicate whose turn it is to enter the cs
The table above shows a process that can enter its cs for different values of flag[ ] and turn. Define a), b), c) and d)
false, false, P0, true
false, false, P1, true
true, false, P0, true
true, false, P1, false
Which one of the cs requirement that Peterson's algorithm are met?
mutual exclusion, bounded waiting
progress, bounded waiting
mutual exclusion, progress
mutual exclusion, progress, bounded waiting
Modern machines provide special atomic hardware instructions to implement locks. What does it mean by atomic?
non-interruptible
preemption
concurrent
preserved
The code segment above is Test and Set algorithm. Lock is set to false at initial. What does this mean?
there is a process in the cs
there is no process in the cs
there is a process doing busy waiting
there is a process entering the cs
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.
false, exit, false
true, exit, true
true, exit, false
false, exit, true
Which one of the cs requirement that test and set algorithm met?
mutual exclusion and progress
mutual exclusion and bounded waiting
progress and bounded waiting
mutual exclusion, progress and bounded waiting
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?
2 1 2 1 2 1 2 1 2 1
1 2 1 2 1 2 1 2 1 2
1 1 1 1 1 1 1 1 1 1
2 2 2 2 2 2 2 2 2 2
Semaphore has two different operations; ________ to _________ the value of semaphore by 1 and _________ to _________ the value of semaphore by 1.
wait(), increment, signal(), decrement
wait(), decrement, signal(), increment
wakeup(), increment, block(), decrement
block(), increment, wakeup(), decrement
Semaphore can only have non negative values. At start, semaphore is always initialised to ____. When semaphore is ____, this implies that ________________.
0, 1, there is no process in cs
1, 0, there is no process in cs
1, 0, there is a process in cs
0, 1, there is a process in cs
When semaphore s = 0, process must constantly check to see if semaphore is not zero so that it can enters cs. This is ______.
mutual exclusion
bounded waiting
progress
busy waiting
Based on the figure above, determine a), b), c) and d)
5, 6, 1, 1
4, 5, 1, 1
5, 5, 1, 0
4, 6, 1, 1
Incorrect use of semaphore can lead to _______ and _________.
starvation, busy waiting
deadlock, busy waiting
deadlock, starvation
bounded waiting, starvation
