• Shuffle
    Toggle On
    Toggle Off
  • Alphabetize
    Toggle On
    Toggle Off
  • Front First
    Toggle On
    Toggle Off
  • Both Sides
    Toggle On
    Toggle Off
  • Read
    Toggle On
    Toggle Off
Reading...
Front

Card Range To Study

through

image

Play button

image

Play button

image

Progress

1/32

Click to flip

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;

32 Cards in this Set

  • Front
  • Back

Why allow cooperating processes/threads?

§ Speedup – overlap I/O and Computation, take
advantage of parallelism for multiprocessor systems
§ Modularity – divide and conquer

Why are cooperating processes important?

Need to ensure correct operation with concurrent processes/threads
§ If process/thread scheduler can schedule threads in any way, programs must work under all circumstances
§ Processes/threads can be run truly concurrently or interleaved in any manner

why can Cooperating processes affect each other’s execution?

They share a logical address space or share data through files and messages

Why can Concurrent access to shared data result in intermittent incorrect behavior?

Because the outcome may be affected by concurrency or interleaving of the execution

Scheduling order does not affect operation

Independent processes

Shared state between threads, scheduling order can affect operation without proper synchronization among processes/threads

Cooperating processes/threads

When several processes access and
manipulate the same data concurrently and the outcome of the execution depends on the order in which the access takes place

Race Condition

What should happen to ensure correct operation in certain code sequences?

They should be uninterruptable and/or should
not be executed at the same time in more than one process/thread (critical section)

Why are race conditions bad?

Race conditions lead to non-deterministic behavior

How can race conditions be avoided?

Ensure that only one of process
can manipulate shared data at a time

Ensuring that only one thread does a
particular thing at a time

Mutual Exclusion (One thread excludes the others while doing its task)

Piece of code that only one thread can
execute at once. Only one thread at a time will get into this section of code.

Critical Section (requires mutual exclusion )

What requirements should be satisfied by a solution to the critical section problem?

Mutual Exclusion


Progress


Bounded waiting

If no process is executing in its critical section and some processes wish to enter their critical sections, then only those processes that are looking to enter their critical sections decide
which process will enter its critical section next and this selection cannot be postponed indefinitely

Progress

There must exist a bound on the number of
times other processes are allowed to enter their critical section after a process has made a request to enter its critical section and
before it is allowed to

Bounded waiting (avoid starvation)

Use a turn variable to signal whose turn it is to enter the critical section as well as a flag per process that indicates whether a process wants to enter its critical section

Peterson’s Algorithm

Locking mechanism to
ensure mutual exclusion

Disabling Interrupts


/* disable interrupts */
/* critical section */


/* enable interrupts */

Problems with disabling interrupts

§ Does not guarantee mutual exclusion for multiprocessor systems (disabling interrupts across multiprocessors is expensive; message passing)
§ Limits the ability of the OS to provide timesharing
§ Could allow a process to monopolize the processor

Use a variable to lock access to critical section
Need hardware support to guarantee an update to a lock variable cannot be interrupted


(needs to be an atomic operation )

Lock Variables

Problems with Lock variables approach

•Busy waiting is employed
•Starvation is possible, because selection of next process to enter
critical section is arbitrary

Problems with Busy Waiting

• Very inefficient because waiting process
consumes CPU cycles (depends on time to unlock, if short then busy wait is preferable to waiting with a context switch)
• Waiting process may take cycles away from
process that is holding the lock

§ Priority Inversion for Strict Priority Scheduler

• If busy-waiting thread has higher priority than
thread holding lock ---> no progress
§ the high priority process that busy waits never lets lower priority process finish its critical section

Integer that is accessed through two
atomic operations

Semaphores

Problems with semaphores

§ A process will busy wait or spin waiting for the semaphore (this type of semaphore is also referred to as a spinlock)
§ Good when the wait time is short, context switch can be avoided
§ Bad when the wait time is long, waste CPU cycles constantly checking semaphore status

Binary semaphore

only two values (0, 1)

Used when there are a finite number of instances of some resource

Counting semaphore

Who and in which year were semaphores introduced?

Edsgar Dijkstra in the late 1960s

How can busy waiting be fixed?

changing implementation of
wait() to cause a process to block itself if the semaphore is not positive (• waiting process gets put on a waiting queue associated with the semaphore & • signal() is changed to wakeup the process at the head of the wait queue
for the semaphore)

Since processes are queued as they wait on a semaphore, name one
method to determine the next process that can be employed

Process Scheduling

• P0 executes wait(S) and acquires this semaphore
• P1 execute wait(Q) and acquires this semaphore
• P0 blocks on the call to wait(Q)
• P1 blocks on the call to wait(S)


Example of Deadlock since neither process will be receive the signal() they are waiting for

Allow a process to inherit
the priority of a higher priority process that is
waiting until this process complete is use of a
resource

Priority Inheritance

A lower priority process M, is able to affect the
performance of process H

Priority Inversion