Mod 4: Monitors and condition synchronization Flashcards

1
Q

What is a monitor?

A

(1) Class, object or module providing more structure than a semaphore does
(2) Structured way of combining data and synchronization
(3) Provides all benefits of encapsulation of data
(4) Synchronization technique

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What do a monitor do?

A

(1) Guarantes ME,
(2) encapsulate data and operations
(3) encapsulate thread synchronization using conditional synchronization

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Using which methods is conditional syncrhonization achieved? (in Java)

A

(1) Wait( )
(2) Notify( )
(3) NotifyAll( )

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does all monitors have?

A

(1) Lock object (Mutex)
(2) condition variable

Every monitor also have a waiting thread (blocked threads)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the two types of synchronization, and which does a monitor supports?

A

(1) Mutual Exclusion,
(2) Condition Synchronization

Monitor supports both type.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does a monitor support conditional synchronization?

A

Explicitly via condition variables

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a monitor support mutual exclusion?

A

A single global lock (on of the items associated with a monitor) ensure mutex for all operations in the monitor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How do you create a monitor in java?

A

Using the synchronized key word the region (eg method) becomes a monitor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are the steps when a thread uses a monitor?

A

(1) Enter the monitor, waiting for access
(2) Aquire monitor
(3) Owning monitor (locks door)
(4) Release monitor (unlock door)
(5) Exit the monitor

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is a suspended thread?

A

A thread waiting for a condition to be true / to be allowed to continue its path of execution

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

For what does a monitor use a conditional variable?

A

To suspend and wake up threads

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between a condition variable and a condition synchronization?

A

A condition variable is synchronization mechanisms that allow a thread to wait for a specific condition to become true, while condition synchronization refers to the coordination of threads based on some condition

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the methods each condition variable often have?

A

(1) Wait ( )
(2) Signal ( ) or notify
(3) SignalAll ( ) or notifyAll

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How can a thread block itself and why would it want to?

A

By calling wait( ), in order to wait for a specific condition to become true

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the difference between a mutex (or binary semaphore) and conditional variable?

A

Mutex / BS implements synchronization by controlling
thread access TO data, condition variable allows threads to synchronize based on the actual value of the data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is passive vs active objects?

A

Active - objects that initiate actions
Passive - objects that reponds to action

17
Q

What type of object is threads?

A

Active objects, objects that initiate actions

18
Q

What type of objects is monitors?

A

Passive objects, objects that respond to actions