Top Banner
1 Multiprocessor and Real-Time Scheduling Chapter 10
62
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

1

Multiprocessor and Real-Time SchedulingChapter 10

Page 2: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

2

Classifications of Multiprocessor Systems Loosely coupled or distributed multiprocessor, or

cluster Each processor has its own memory and I/O channels

Functionally specialized processors Such as I/O processor Controlled by a master processor

Tightly coupled multiprocessing Processors share main memory Controlled by operating system

Page 3: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

3

EG Cluster Computing (Loosely coupled, distributed)

High-Performance Clusters (HPC) Shared computational tasks

Grid Computing (simil to HPC) Heterogeneous Little shared data

High-availability Cluster (HA) Redundant nodes for improving up-time

Load-balancing Clusters Server Farm – front-end allocation and back-end servers Higher availability and higher performance

Page 4: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

4

EG. Specialized Processors High-end graphics cards

Own RAM Own IO (Capture, TV connections etc.) Own local buses

EG. ATI Crossfire and Nvidia scalable link interface (SLI) Multiple Processors

Can be used for scientific computing

RAID HDD Controllers Keyboard

Captures and stores keypresses etc.

Page 5: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

5

Page 6: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

6

Independent Parallelism

Separate application or job No synchronization among processes Example is time-sharing system

Page 7: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

7

Coarse and Very Coarse-Grained Parallelism Synchronization among processes at a

very gross level Good for concurrent processes running on

a multiprogrammed uniprocessorCan by supported on a multiprocessor with

little change

Page 8: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

8

Medium-Grained Parallelism

Single application is a collection of threads Threads usually interact frequently

Page 9: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

9

Fine-Grained Parallelism

Highly parallel applications Specialized and fragmented area

Page 10: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

10

Scheduling

Assignment of processes to processors Use of multiprogramming on individual

processors Actual dispatching of a process

Page 11: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

11

Assignment of Processes to Processors Treat processors as a pooled resource and

assign process to processors on demand Permanently assign process to a processor

Known as group or gang scheduling Dedicated short-term queue for each processor Less overhead Processor could be idle while another processor has

a backlog

Page 12: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

12

Assignment of Processes to Processors Global queue

Schedule to any available processor

Master/slave architecture Key kernel functions always run on a particular processor Master is responsible for scheduling Slave sends service request to the master Disadvantages

Failure of master brings down whole system Master can become a performance bottleneck

Page 13: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

13

Assignment of Processes to Processors Peer architecture

Operating system can execute on any processor

Each processor does self-schedulingComplicates the operating system

Make sure two processors do not choose the same process

Page 14: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

14

Process Scheduling

Single queue for all processes Multiple queues are used for priorities All queues feed to the common pool of

processors See graphs 10.1. (next slide) General Conclusion:

“The specific scheduling algorithm is much less important with two processors than with one. This conclusion … stronger as number of processors increases”

Page 15: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

15

Relative performance of scheduling algorithms Algorithm less

significant

Page 16: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

16

Thread Scheduling

Executes separate from the rest of the process

An application can be a set of threads that cooperate and execute concurrently in the same address space

Threads running on separate processors yields a dramatic gain in performance

Page 17: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

17

Multiprocessor Thread Scheduling: 4 approaches1. Load sharing

Processes are not assigned to a particular processor. Single global queue

2. Gang scheduling A set of related threads is scheduled to run

on a set of processors at the same time

Page 18: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

18

Multiprocessor Thread Scheduling3. Dedicated processor assignment

Threads are assigned to a specific processor (opposite of load sharing)

Each program allocated #processors = #threads in program

4. Dynamic scheduling Number of threads can be altered during

course of execution

Page 19: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

19

Load Sharing

Load is distributed evenly across the processors

No centralized scheduler required Use global queues

Page 20: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

20

Disadvantages of Load Sharing

Central queue needs mutual exclusionMay be a bottleneck when more than one processor

looks for work at the same timeBigger problem with many processors

Preemptive threads are unlikely to resume execution on the same processorCache use is less efficient

If all threads are in the global queue, all threads of a program will not gain access to the processors at the same time

Page 21: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

21

Gang Scheduling

Simultaneous scheduling of threads that make up a single process

Useful for applications where performance severely degrades when any part of the application is not running

Threads often need to synchronize with each other

Page 22: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

22

Scheduling Groups

Page 23: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

23

Dedicated Processor Assignment When application is scheduled, its threads

are assigned to a processor Some processors may be idle No multiprogramming of processors

Page 24: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

24

Page 25: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

25

Dynamic Scheduling

Number of threads in a process are altered dynamically by the application

Operating system adjust the load to improve utilization Assign idle processors New arrivals may be assigned to a processor that is

used by a job currently using more than one processor Hold request until processor is available Assign processor a jog in the list that currently has no

processors (i.e., to all waiting new arrivals)

Page 26: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

26

Real-Time Systems

Correctness of the system depends not only on the logical result of the computation but also on the time at which the results are produced

Tasks or processes attempt to control or react to events that take place in the outside world

These events occur in “real time” and tasks must be able to keep up with them

Page 27: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

27

Real-Time Systems

Telecommunications Control of laboratory experiments Process control in industrial plants Robotics Air traffic control Military command and control systems

Page 28: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

28

What is Real-time?

A. Clock-time B. Defined input to output response time

Hard R-T: system has failed if defined response not met

Soft R-T: deadline defined but not mandatory Firm R-T: defined risk and handling of failures

Periodic vs. aperiodic Examples

Page 29: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

29

Characteristics of Real-Time OS

DeterministicOperations are performed at fixed,

predetermined times or within predetermined time intervals

Concerned with how long the operating system delays before acknowledging an interrupt and there is sufficient capacity to handle all the requests within the required time

Page 30: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

30

Characteristics of Real-Time OS Responsiveness

How long, after acknowledgment, it takes the operating system to service the interrupt

Includes amount of time to begin execution of the interrupt.

Interrupt Latency: time from when the interrupt occurs in real world to execution of first line of code of ISR

Thread vs. process switching issues

Includes the amount of time to perform the interruptEffect of interrupt nesting

Page 31: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

31

Characteristics of R-T OS (cont) User control

More control than in conventional OS User specifies priority

Different handling for soft and hard RT tasks

Specify paging What processes must always reside in main memory Disks algorithms to use Rights of processes

Page 32: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

32

Characteristics of Real-Time OS

Reliability very importantDegradation of performance may have

catastrophic consequences Fail-soft operation

Ability of a system to fail in such a way as to preserve as much capability and data as possible

Stability (handle critical tasks)

Page 33: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

33

Features of Typical Real-Time Operating Systems Fast process or thread switch Small size Ability to respond to external interrupts

quickly Multitasking with interprocess

communication tools such as semaphores, signals, and events

Page 34: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

34

Features of typical RTOS (cont)

Use of special sequential files that can accumulate data at a fast rate

Preemptive scheduling base on priority Minimization of intervals during which

interrupts are disabled Delay tasks for fixed amount of time Special alarms and timeouts

Page 35: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

35

Short-term task sched in RTOS

Short term Scheduler is key Fairness and avg response not important Meet needs of hard RT tasks is preeminent Most current RTOS do not deal directly w.

deadlines Fast scheduling Deterministic response times (millisec range)

Page 36: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

36

Scheduling of a Real-Time Process

Page 37: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

37

Scheduling of a Real-Time Process

Page 38: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

38

Real-Time Scheduling

Static table-drivenDetermines at run time when a task begins execution

Static priority-driven preemptiveAnalyzed and then traditional priority-driven

preemptive scheduler is used Dynamic planning-based

Feasibility determined at run time dynamically Dynamic best effort

No feasibility analysis is performed

Page 39: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

39

Deadline Scheduling

Real-time applications are not concerned with speed but with completing tasks

Page 40: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

40

Deadline Scheduling Need more info than “priority” Information used

Ready timeStarting deadlineCompletion deadlineProcessing timeResource requirementsPriority (Hard RT is absolute priority)Subtask scheduler

Page 41: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

41

Two Tasks

Page 42: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

42

Page 43: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

43

Page 44: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

44

Page 45: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

45

Rate Monotonic Scheduling

Assigns priorities to tasks on the basis of their periods

Highest-priority task is the one with the shortest period

Page 46: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

46

Periodic Task Timing Diagram

Page 47: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

47

Page 48: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

48

Priority Inversion

Can occur in any priority-based preemptive scheduling scheme

Occurs when circumstances within the system force a higher priority task to wait for a lower priority task

Page 49: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

49

Unbounded Priority Inversion

Duration of a priority inversion depends on unpredictable actions of other unrelated tasks

Page 50: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

50

Priority Inheritance

Lower-priority task inherits the priority of any higher priority task pending on a resource they share

Page 51: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

51

Linux Scheduling

Scheduling classesSCHED_FIFO: First-in-first-out real-time

threadsSCHED_RR: Round-robin real-time threadsSCHED_OTHER: Other, non-real-time threads

Within each class multiple priorities may be used

Page 52: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

52

Page 53: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

53

Non-Real-Time Scheduling

Linux 2.6 uses a new scheduler the O(1) scheduler

Time to select the appropriate process and assign it to a processor is constantRegardless of the load on the system or

number of processors

Page 54: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

54

Page 55: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

55

UNIX SVR4 Scheduling

Highest preference to real-time processes Next-highest to kernel-mode processes Lowest preference to other user-mode

processes

Page 56: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

56

UNIX SVR4 Scheduling

Preemptable static priority scheduler Introduction of a set of 160 priority levels

divided into three priority classes Insertion of preemption points

Page 57: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

57

SVR4 Priority Classes

Page 58: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

58

SVR4 Priority Classes

Real time (159 – 100)Guaranteed to be selected to run before any

kernel or time-sharing processCan preempt kernel and user processes

Kernel (99 – 60)Guaranteed to be selected to run before any time-

sharing process Time-shared (59-0)

Lowest-priority

Page 59: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

59

SVR4 Dispatch Queues

Page 60: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

60

Windows Scheduling

Priorities organized into two bands or classesReal timeVariable

Priority-driven preemptive scheduler

Page 61: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

61

Page 62: 1 Multiprocessor and Real-Time Scheduling Chapter 10.

62