• 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/47

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;

47 Cards in this Set

  • Front
  • Back

Thread

Basic unit of utilization

What does a thread contain?

stack


thread Id


program counter


register set

What do threads belonging to the same process share?

Code Section


Data Section


Other OS resources (such as open files and signals)

What is a thread library?

Provides the programmer with an API for creating and managing threads.

Three main thread libraries in use today?

POSIX Pthreads


Win32


Java

What manages java threads?

JVM

Java threads can be created by:

Extends Thread class and overwrites its run() function




Implementing the Runnable interface

Thread Cancellation
Asynchronous Cancellation
Terminates target thread immediately

Thread Cancellation


Deferred Cancellation

Allows the target thread to periodically check if it should be canceled.

What are Thread Pools?

Creating a number of threads in a pool where they await work.

Thread Pools Advantage

Usually slightly faster to service a request with an existing thread than creating a new thread.




Allows the number of threads in the application(s) to be bound to the size of the pool.

CPU - I/O Burst Cycle

Process execution consists of a cycle of CPU execution and I/O wait

How many CPU burst cycles does an I/O program usually have?

Many short bursts

How many CPU burst cycles does a CPU bound program have?

Few long burst cycles

CPU scheduler decisions take place when a process:

Switches from running to waiting state.
Switches from running to ready state.
Switches from waiting to ready state.
Terminates

Which two states are preemptive?

Switches from running to waiting state.
Switches from running to ready state.
Switches from waiting to ready state.
Terminates

Switches from running to ready state.


Switches from waiting to ready state.

Which two states are preemptive?




Switches from running to waiting state.


Switches from running to ready state.


Switches from waiting to ready state.


Terminates

Switches from running to waiting state.


Terminates

Dispatcher module

Gives control of the CPU to the process selected by the short-term scheduler.

Scheduling Criteria




CPU utilization





Keep the CPU as busy as possible

Scheduling Criteria




Throughput

# of processes that complete their execution per time unit

Scheduling Criteria




Turnaround time

Amount of time to execute a particular process

Scheduling Criteria




Waiting time

Amount of time a process has been waiting in the ready queue

Scheduling Criteria




Response Time

Amount of time it takes from when a request was submitted until the first response is produced, not output (for time-sharing environment)

Multiple-Processor Scheduling


Two types

Asymmetric multiprocessing

Symmetric mmultiprocessing (SMP)



Multiple-Processor Scheduling


Two types of Affinitity

Soft affinity - not guaranteed


Hard affinity - Guarantreed ex. Linux

Multiple-Processor Scheduling


Load Balancing

Keep the processor workload evenly distrbuted among processors.

Multiple-Processor Scheduling


Two types of migration

Push - specific task periodically checks


Pull - idle processor will pull a waiting task from a busy processor

Multiple-Processor Scheduling


Processor affinity

Cache memory populated with data accessed recently by the process in execution; if to switch processor, needs ot invalidate the first chache memory and repopulate the second cache.




Avoid this

Real-Time Scheduling


Two types

Hard real-time systems


Soft real-time systems

Solaris Dispatch Table for scheduling interactive and time-sharing threads60 Priority levels (0~59)

Priority: Higher number indicates higher priority Time quantum: Lowest priority has the highest time quantum

Windows Priorities

Priority-based, preemptive scheduling algorithm


Uses 32-level (0~31) scheme to determine the order of thread execution, higher number indicates higher priority.

Linux Scheduling

- Priority-based, preemptive


- Lower value indicates higher priority (different from Solaris and Windows)


- Linux assigns higher priority tasks longer time quanta and lower-priority tasks shorter time quanta

Process Synchronization


Background

Concurrent access to shared data may result in data inconcistency.


Maintaining data consistency requires mechanisms to ensure the orderly execution of cooperating processes

Critical-section Problem


3 requirements

1. Mutual Exclusion


2. Progress


3. Bounded Waiting

Peterson's Solution


Two process solution

Assume that load and store instructions are atomic (uninterruptable)

The two processes share two variables:


int turn;


Boolean flag[2];


Synchonization Hardware

Modern machines provide special atomic hardware instructions.




Either test memory word and set value


Or swap contents of two memory words

Semaphore


Hardware issue


Synchronization advantage


Semaphore S variable type



Hardware - hard for application programmers to use



Syn. tool doesn't require busy waiting




Semaphore type - Integer



Semaphore


S modifiers


Synchronization hardware


Counting Semaphore


Binary Semaphore

Operations: acquire() and release()GetAndSet and Swap




Counting semaphore (Range over an unrestricted domain)




Binary Semaphore ( 0 or 1)

Semaphore Implementation


Guarantee

No two processes can execute acquire() and release() on the same semaphore at the same time

Semaphore Implementation


Critical section problem

Implementation, Wait and signal code placed in critical section




Busy waiting in critical section in implementation


Implementation code is short


Little busy waiting if critical section rarely occupied.

Semaphore Implementation


Why is this a bad solution

Applications may spent a lot of time in critical sections.

Semaphore Implementation with no Busy waiting


Waiting queue data types (2)

Value (of type integer)


pointer to next record in the list

Semaphore Implementation with no Busy waiting


Two operations

Block


Wakeup

Deadlock


Starvation

sdf

Monitors

A high-level abstraction that provides a convenient and effective mechanism for process synchronization


Only one process may be active within the monitor at a time

Condition variables


x.wait()


x.signal()

wait() - process that invokes the operation is suspended




signal() - Resumes one of the processes (if any) that invoked x.wait()

See and add stuff from slides

slides