Review: Process Communication - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

Review: Process Communication

Description:

Unpredictable and wrong behavior (example of printer queue with lost ... Priority Scheduling. Disadvantage of Round Robin: Even very important jobs wait in line ... – PowerPoint PPT presentation

Number of Views:30
Avg rating:3.0/5.0
Slides: 20
Provided by: claudia45
Category:

less

Transcript and Presenter's Notes

Title: Review: Process Communication


1
Review Process Communication
  • Sequential Communication
  • Result of P1 becomes at termination the input to
    P2
  • Tools Redirect (gt,gtgt) and Pipe ()
  • Concurrent Communication
  • between 2 running processes via shared resources
  • Resource Sharing
  • Each resource has a Boolean variable associated
  • A process can request a resource and set the lock
    1
  • To free a resource lock 0
  • Usually you only lock a resource if you want to
    change it

2
Problems of Sharing Resources
  • Inconsistency
  • Unpredictable and wrong behavior (example of
    printer queue with lost job)
  • Deadlock
  • Processes are waiting for resources held by
    another
  • Race conditions
  • Conditions under which sharing can lead to
    inconsistencies and deadlock

3
Solutions
  • Inconsistency can be avoided by ensuring
    uninterrupted blocks of instructions
  • Preventive
  • Test and Set Instruction
  • Semaphores
  • Critical Block
  • Detect and resolve

4
The Dining Philosophers
F3
Plate with food
P3
P4
F2
F4
P2
P5
P1
F1
Fork
F5
5
Detection for the Philosophers
  • 5 Processes (Philosophers) P1, P2, P3, P4, P5
  • 5 Resources (Forks) F1, F2, F3, F4, F5
  • Implementation of P
  • think
  • grab_left_fork
  • grab_right_fork
  • eat
  • free_right_fork
  • free_left_fork
  • Task draw the dependency graph

6
Dependency Graph
F1
F5
F2
F4
F3
7
Example for Dependency Graph
  • Notation R(resource) request/lock
  • F(resource) free resource
  • P1 R(a),R(b),R(c),F(c),R(d),F(b),F(d),F(a,)
  • P2 R(e),R(d),R(c),F(c),F(d),F(e)
  • P3 R(a),R(d),R(e),F(a),F(d),F(e)
  • P4 R(c),R(k),R(a),F(a),F(k),F(c)
  • Question Which process (P2,P3,P4) can you let
    run without danger of deadlock

8
Solution
  • Please copy the graph from the board!
  • You cant run the following combinations
  • P2,P3
  • P1,P4

9
Use of Dependency Graph
  • Prevention the OS does not allow a process to
    start if it could create a deadlock
  • this is in some cases a overly conservative and
    in some sense unfair policy
  • the implementation of this policy is
    computationally very expensive!
  • Detection wait for deadlock to happen
  • If a number of processes seem to be waiting
    beyond a certain timelimit, build the graph
    including the ownership of resources and select a
    process such that killing it will break the circle

10
Process Scheduling
  • Scheduler decides
  • Which process in ready queue is next to run
  • When to stop a running process

11
Scheduling
  • Main Constraint Every switch has overhead
  • Scheduling objectives depend on environment
  • Batch systems High performance computing, Server
  • Throughput maximize jobs per time
  • Turnaround time minimize time between creation
    and termination
  • User interactive systems Eureka or Sales
  • Response Time
  • Fairness

12
Batch Systems
  • Processes are executed sequentially to minimize
    switching overhead (no timeout arrow)
  • When to stop a running process Only if it is
    waiting for I/O
  • Which process to run next
  • First comes first serves
  • Fair, but can lead to long waiting of minor jobs
  • Shortest job next
  • assumes runtime is known, penalizes long jobs

13
Batch Example
  • Processes arriving in the following order
  • A(20s) at t10 ,B(14000s) at t20 ,C(10s) at
    t25, D(5s) at t 30
  • CPU currently runs E and terminates at t18
  • Execution Order for First-comes first-serves
  • A, B, C, D
  • Execution Order for Shortest First
  • A (terminates at 28), C (terminates at 38), D
    (terminates at 43), B (terminates at 14043)

14
Interactive Systems Multiprogramming
  • Each process is allowed to run for a certain time
    (quantum) after which it is interrupted
  • Parameter quantum length (e.g., 25ms)
  • Too small big overhead due to context
    switch(e.g., 1ms)
  • Too big low response time (wait to see character
    you typed)
  • Scheduling Schemes
  • Round Robin Scheduling
  • Priority Scheduling
  • Lottery Scheduling

15
Round Robin
  • Simplest
  • Scheduler has ready queue with first in first out
  • When interrupted after timeout (quantum is over)
  • Which next next in queue

Ready Queue
Running
T1
A
T2
B
16
Priority Scheduling
  • Disadvantage of Round Robin
  • Even very important jobs wait in line
  • Alternative multiple ready queues for different
    priority classes
  • Round robin for jobs in highest priority queue
  • Only if empty it picks from the next lower
    priority
  • Works well if there are few priority classes and
    few high priority jobs
  • Can starve low priority jobs

17
Example Priority
  • Quantum 10 sec, Switch cost 1 sec
  • Priority Levels 0, 1, 2 where 2 is highest
  • CPU started at t0 to run A (p0, t30)
  • at t5 arrives B (p1, t20)
  • at t15 arrives C (p1, t20)
  • at t25 arrives D (p2, t5)
  • Task draw timeline of execution
  • Solution A, B, C, D, B, C, A, A

18
Lottery Scheduling
  • Similar to Priority Scheduling
  • Multiple queue for different priorities
  • Every process that is next in his queue gets a
    lottery ticket
  • High priority jobs get more lottery tickets
  • OS picks a ticket to determine the next job
  • Higher priority has a higher probability to be
    executed next but you dont starve low priority
    jobs

19
What you should be able to do
  • Draw dependency graph from process specification
    and determine whether there is a chance of
    deadlock and which processes you can run safe
    together
  • Determine execution order for batch (first comes
    first serves, shortest first), Round Robin and
    Priority Scheduling
Write a Comment
User Comments (0)
About PowerShow.com