Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
13 Cards in this Set
- Front
- Back
From an Operating System's perspective, what is the difference between a process and a thread?
|
A process is what owns the memory and is actually allocated process specific resources from the operating system. A thread is a trace through an application. Shares the memory of process with every other thread in a process
|
|
What are some of the benefits of threads?
|
faster to create and terminate
faster to switch between two threads more efficient communication between threads parellel processing |
|
What are two ways that a semaphore can be used? Give an example of each.
|
Mutex:
Condition Variable |
|
How do semaphores compare to mutexes?
|
A semaphore is a generalized version of a mutex. A semaphore can be used as a mutex, but it can also be used as a condition variables.
|
|
How do semaphores compare to condition variables?
|
A semaphore is a generalized version of a condition variable. A semaphore can be used as a condition variable, but it can also be used as a mutex variables.
|
|
What is the difference between a Hoare monitor and a Lampson Redell monitor?
|
A Hoare monitor uses c_signal and so only awakens one waiting process at a time. Does not require rechecking of conditions. A Lampson Redell Monitor uses c_signal and can allow a process to reawaken even though the condition may have changed. Requires the condition rechecking
|
|
Explain how can you emulate a monitor using semaphores.
|
You place all data as private members of a class. That class uses the a single semaphore, with the semaphores inside the methods not outside. Use while loops to recheck conditions and semaphores acting as condition variables to signify cwait and csignal
|
|
Explain how you could use a central mailbox to provide mutual exclusion among a set of dis-
tributed threads using message passing. |
Create one thread that is used by all threads. All threads pass messages to the mailbox and poll it to get responses. Use a null message as a key and block if the key isn't available
|
|
1st deadlock
|
Mutual exclusion: only one thread may use a resource at a time
|
|
2nd deadlock
|
hold and wait: a thread holds one resource while waiting for another
|
|
3rd deadlock
|
no preemption: a thread can't be forced to release a resource
|
|
4th deadlock
|
circular wait: a cycle of threads waiting for each other
|
|
2 ways to prevent a deadlock
|
prevent hold and wait: a thread can only hold one resource at a time
prevent circular wait: impose ordering on resources |