OS 5 - Process Synchronization

¡Supera tus tareas y exámenes ahora con Quizwiz!

Define Deadlock?

A situation where two or more processes are waiting indefinitely for an event that can be caused only by one of the waiting processes.

What is Peterson's Solution?

A software based solution to the critical-section problem. It is restricted to 2 processes that alternate execution between their critical and remainder sections. flag[i] : ready to execute.

What is transactional memory?

A technique of maintaining atomicity that derived from database theory. If a sequence of atomnic read-write operations is successful the memory transaction is committed. Otherwise the operations are aborted and must be rolled back.

What is a monitor?

An ADT. The monitor construct ensures that only one process at a time is active within the monitor. Consequently, the programmer does not need to code this synchronization constraint explicitly. It is used to help solve the issue of the fact semaphores can be broken easily in implementation. It is a place where functions can be declared that are under the control of the monitor. Variables can only be acted on by x.wait() and x.signal() methods.

Compare a counting semaphore to a binary semaphore?

Counting semaphores use an integer that can range over an unrestricted domain. Counting semaphores can be used to control access to a given resource consisting of a finite number of instances. The semaphore is initialized to the number of resources available. Binary semaphore can only be 0 or 1.

What are the components of a mutex lock?

acquire() acquires the lock, release() releases it. It involves busy waiting. (a spinlock)

How do you implement a critical-section?

have an entry section with the critical section that is exclusive access to variables in question, an exit section and the remainder section which is not in the critical-section.

What does directive dies OpenMP provide to maintain synchronization of data access?

#pragma omp critical, which identified critical sections in which only one thread can be active at a time.

What 4 conditions must be true for a deadlock to occur?

1. Mutual exclusion. At least one resource must be held in a nonsharable mode; that is, only one process at a time can use the resource. If another process requests that resource, the requesting process must be delayed until the resource has been released. 2. Hold and wait. A process must be holding at least one resource and waiting to acquire additional resources that are currently being held by other processes. 3. No preemption. Resources cannot be preempted; that is, a resource can be released only voluntarily by the process holding it, after that process has completed its task. 4. Circular wait. A set {P0, P1, ..., Pn} of waiting processes must exist such that P0 is waiting for a resource held by P1, P1 is waiting for a resource held by P2, ..., Pn−1 is waiting for a resource held by Pn, and Pn is waiting for a resource held by P0.

What three requirements must be satisfied to solve the critical section problem?

1. Mutual exclusion. If process Pi is executing in its critical section, then no other processes can be executing in their critical sections. 2. Progress. If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are not executing in their remainder sections can participate in deciding which will enter its critical section next, and this selection cannot be postponed indefinitely. 3. Bounded waiting. There exists a bound, or limit, on the number of times that other processes are allowed to enter their critical sections after a process has made a request to enter its critical section and before that request is granted.

What is an atomic integer?

A Linux opaque data type that forces only atomic operations. atomic_t

Give an example of a potential deadlock using a system resource-allocation diagram?

But remember: If each resource type has several instances, then a cycle does not necessarily imply that a deadlock has occurred. In this case, a cycle in the graph is a necessary but not a sufficient condition for the existence of deadlock.

How do functional languages solve the synchronization problem?

Since they do not maintain state this is not an issue. Once a variable is assigned a value it is immutable. This lack of mutability negates race conditions and deadlocks.

How does Pthreads differ from other synchronization methods discussed in the text?

The Pthreads API is available for programmers at the user level and is not part of any particular kernel

What is the readers-writers problem?

The issue where as many readers may access the data at once, but only one writer can have mutex access at a time.

Whne implementing a conditional wait in a moniutor what is c in x.wait(c0?

The priority number. When resuming the process with the smallest priority number is executed first.

Describe a system resource-allocation graph?

This shows the relationship between processes and resources. It can be used to demonstrate potential deadlock cycles. RESOURCE:RECTANGLE PROCESS:CIRCLE Dots in the R's represent instances of a resource Request edge vs. assignment edge

How you you combat the issue of Priority Inversion? (L<M<H) Resource R being used by L, needed by H, gets preempted by M, thus ultimately resulting in a lower level process delaying a higher level process.

Use a priority-inheritance protocol where all processes that are accessing resources needed by a higher-priority process inherit that higher priority for the duration of the access.

What is a race condition?

Where several processes access and manipulate the same data concurrently and the outcome of the execution depends on the particular order in which the access takes place, is called a race condition.

What can a waiting semaphore do instead of busy waiting?

block(), placing itself in the waiting queue. use wakeup() to leave waiting state to ready state.

What monitor like concurrency mechanism does Java supply?

declare a method using the synchronized keyword. Every object in Java has associated with it a single lock. When a method is declared to be synchronized, calling the method requires owning the lock for the object. We declare a synchronized method by placing the synchronized keyword in the method definition. java also provides the wait() and notify() (signal) methods.

In POSIX what are the 2 types of semaphores used?

named: has an actual name in the file system and can be shared by multiple unrelated processes. unnamed:can only be used by threads of the same process.

Which type of kernel is free from race conditions, preemptive or non-preemptive?

non-preemptive, since only one process is active in the kernel at a time.

What is a semaphore?

semaphore s is an integer variable, that is only accessed (atomically) through wait() and signal(). A (non-negative) integer representing the quantity of a resource available

In C &variable returns what?

the address of the pointer.

In C *variable returns what?

the value of the pointer.

How does Windows control process synchronization?

using dispatcher objects witch employ several different mechanisms, including mutex locks, semaphores, events, and timers. An object in a signaled state is available and will not block when acquiring the object. An object in a non-signaled state is not available and will block.


Conjuntos de estudio relacionados

BIO 225 - Ch. 3 (Bacteria and Archaea)

View Set

Private - Task E: Airspace Systems

View Set

MIST 5750 Quiz #1, MIST 5750 Quiz 2, MIST 5750 Quiz #3

View Set

Direct Objects, Indirect Objects, and Compound Objects

View Set

Pharmacology - Upper Respiratory Tract Infection Treatment

View Set