Mutual Exclusion

Ace your homework & exams now with Quizwiz!

What are the six requirements for Mutual Exclusion?

1. Mutual exclusion: only one process is allowed into its critical section 2. A process that halts in its noncritical section must do so without interfering with other processes 3. It must not be possible for a process requiring access to a critical section to be delayed indefinitely: no deadlock or starvation. 4. When no process is in a critical section, any process that requests entry to its critical section must be permitted to enter without delay. 5. No assumptions are made about relative process speeds or number of processors. 6. A process remains inside its critical section for a finite time only.

What are the ways in which the requirements for mutual exclusion can be satisfied?

1. Software Approaches: to leave the responsibility with the processes that wish to execute concurrently. Processes, whether they are system programs or application programs, would be required to coordinate with one another to enforce mutual exclusion, with no support from the programming language or the OS. 2. second approach involves the use of special purpose machine instructions. These have the advantage of reducing overhead but nevertheless will be shown to be unattractive as a general-purpose solution 3. A third approach is to provide some level of support within the OS or a programming language. - best solution

What is a Deadlock?

A deadlock is where two situations are both waiting for the other to finish, and thus never does.

Mutex Variables

A mutex variable acts like a "lock" protecting access to a shared data resource. The basic concept of a mutex as used in Pthreads is that only one thread can lock (or own) a mutex variable at any given time .No other thread can own that mutex until the owning thread unlocks that mutex. Threads must "take turns" accessing protected data.

What is a Race Condition?

A situation in which multiple threads or processes read and write a shared data item and the final result depends on the relative timing of their execution.

Semaphore

For signaling, special variables called semaphores are used. To transmit a signal via semaphore s , a process executes the primitive semSignal(s) . To receive a signal via semaphore s , a process executes the primitive semWait(s) If the corresponding signal has not yet been transmitted, the process is suspended until the transmission takes place. A semaphore is a primitive integer value with three operations: 1. A semaphore may be initialized to a nonnegative integer value. 2. The semWait operation decrements the semaphore value. If the value becomes negative, then the process executing the semWait is blocked. Otherwise, the process continues execution. 3. The semSignal operation increments the semaphore value. If the resulting value is less than or equal to zero, then a process blocked by a semWait operation, if any, is unblocked. Other than these three operations, there is no way to inspect or manipulate semaphores.

What are the advantages and disadvantages of disabling interrupts for to enable mutual exclusion?

Interrupt disabling guarantees mutual exclusion. The disadvantage of this is that efficiency of execution could be noticeably downgraded. This approach also wouldn't work in a microprocessor architecture.

Compare and Swap

This version of the instruction checks a memory location ( *word ) against a test value ( testval ). If the memory location's current value is testval, it is replaced with newval ; otherwise it is left unchanged. The old memory value is always returned; thus, the memory location has been updated if the returned value is the same as the test value. This atomic instruction therefore has two parts: A compare is made between a memory value and a test value; if the values are the same, a swap occurs. The entire compare&swap function is carried out atomically—that is, it is not subject to interruption.

How does a semaphore operation correspond to the number of processes?

To begin, the semaphore has a zero or positive value. If the value is positive, that value equals the number of processes that can issue a wait and immediately continue to execute. If the value is zero, either by initialization or because a number of processes equal to the initial semaphore value have issued a wait, the next process to issue a wait is blocked, and the semaphore value goes negative. Each subsequent wait drives the semaphore value further into minus territory. The negative value equals the number of processes waiting to be unblocked. Each signal unblocks one of the waiting processes when the semaphore value is negative.

Monitor

programming-language construct that provides equivalent functionality to that of semaphores and that is easier to control. It guarantees that only one process can access critical section at a time. Monitors also provide the ability to block a process from entering the critical section until a condition becomes true


Related study sets

Entrepreneurial Small Business Chapter 3

View Set

Ch 14: information technology (IT) for business

View Set

Avian - mareks, myoplasma, and turkey bordatella

View Set

13. Central Nervous System Trauma

View Set

ch 4 adaptive quizzing womens health

View Set

El Día de Los Muertos Questions

View Set

Increased Intracranial Pressure (ICP) NCLEX Questions

View Set

Rad Review test questions, Pt 11, Pt 12

View Set

PRIVACY 2 Privacy for Customer Contact Personnel

View Set

Amoeba Sisters Video Recap: Photosynthesis and Cellular Respiration

View Set

Chapter 4 The Solar System AST 220

View Set

PNC 1: Legal, Ethics, Culture, Spirituality

View Set