Concurrency From last time - PowerPoint PPT Presentation

1 / 10
About This Presentation
Title:

Concurrency From last time

Description:

Race conditions - unpredictable results because processes simultaneously ... The up operation increments the counter and awakens a sleeper if the counter was 0. ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 11
Provided by: tomn8
Category:

less

Transcript and Presenter's Notes

Title: Concurrency From last time


1
Concurrency - From last time
  • The theoretical core of OS
  • An OS creates a set of processes that run
    concurrently
  • A process is like a person - it has
  • a stream of consciousness
  • possessions - memory, files, data
  • is created, reproduces, dies
  • interacts with other processes
  • In actuality, it is a program in execution
  • Concurrent process misbehaviors
  • Race conditions - unpredictable results because
    processes simultaneously modify data or devices
  • Deadlocks - Each has what the other wants
  • Starvation - some processes go hungry - others
    eat well

2
Some operating system ideas - also review
  • Everything is a file - even devices
  • This allows a program to work with human input,
    or a device, or a temporary or permanent file
  • Interrupt-driven behavior
  • Example - windows - process is simultaneously
    sensitive to events from mouse, keyboard, process
    subsystem, and window manager
  • Caching - Foreground and background copies
  • Used in
  • Cache memory
  • Swapping
  • The disk block cache - recent transactions are in
    memory
  • Networking utilities

3
Processes and their states
  • The process state includes the following
  • Running/ready/blocked (waiting on an
    event/events)
  • Priority
  • Kernel/User mode
  • In-memory/swapped
  • Process ID
  • Priority
  • The process owns
  • U-area (but user cant examine/modify it)
  • Entries in the system open-file table
  • Its own file control blocks (linked to the system
    table)
  • Its own memory space

4
The system process table
  • Used for scheduling and control of processes
  • Scheduler acts on timer interrupt or a process
    state change
  • It schedules the highest-priority process that is
    ready
  • It causes a context switch (gives the process
    control)
  • This mechanism
  • Gives system and I/O processes high priority
  • Keeps the CPU puercos from monopolizing
  • Interrupts are outside process country
  • This avoids make a context switch for each
    interrupt
  • It means the interrupt service routines use only
    the kernels memory

5
Mutual Exclusion - software solutions
  • Unsuccessful solutions (on separate slides)
  • Strict alternation
  • Algorithms where mutual exclusion fails
  • Petersons algorithm
  • Description of Bakery Algorithm
  • Just like Baskin-Robbins - incoming process takes
    a number
  • Since two users can grab same number,
    lowest-number process gets priority

6
Avoiding busy waiting - Semaphores and messages
  • Classical semaphores
  • The semaphore is an ADT with a counter, a process
    queue, and two operations
  • The down operation sleeps enqueued if the counter
    is zero, and then decrements the counter
  • The up operation increments the counter and
    awakens a sleeper if the counter was 0.
  • The down operation enters a critical section, the
    up leaves it.
  • Messages
  • Reliable messages to an administrator work like a
    down or up
  • Messages and semaphores are equivalent
  • Thats why

7
Semaphores and messages - continued
  • Mistakes are easy
  • Deadlock
  • Geteway-controlling and resource-controlling
    semaphores

8
Language Mechanisms - Monitors
9
Classical IPC problems
  • Producer-consumer
  • Scenario
  • Producer produces information
  • Consumer consumes it
  • Both must wait on buffer availability
  • Problem resembler disk I/O and print servers
  • Code
  • Readers-Writers
  • Scenario
  • Readers can write whenever no writer is active
  • Writers must have solitude
  • Problem resembles database
  • Code
  • Dining Philosphers
  • Scenario
  • N philosophers think, wait for chopsticks, and
    eat
  • Problem is useless but illustrative
  • Code

10
(No Transcript)
Write a Comment
User Comments (0)
About PowerShow.com