Download PPT

Document related concepts

Copland (operating system) wikipedia , lookup

Distributed operating system wikipedia , lookup

DNIX wikipedia , lookup

CP/M wikipedia , lookup

OS 2200 wikipedia , lookup

Burroughs MCP wikipedia , lookup

Process management (computing) wikipedia , lookup

Thread (computing) wikipedia , lookup

Transcript
Multiprocessor and Real-Time
Scheduling
Chapter 10
Classifications of
Multiprocessor Systems
• Loosely coupled multiprocessor
– 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
Scheduling and
Synchronization
• Scheduling concurrent processes has to
take into account the synchronization of
processes.
• Scheduling decisions for one process may
affect another process if the two
processes are synchronized.
• Synchronization granularity means the
frequency of synchronization between
processes in a system
Types of synchronization
granularity
• Fine – parallelism inherent in a single instruction
stream
• Medium – parallel processing or multitasking
within a single application
• Coarse – multiprocessing of concurrent
processes in a multiprogramming environment
• Very coarse – distributed processing across
network nodes to form a single computing
environment
• Independent – multiple unrelated processes
Independent Parallelism
• Separate application or job
• No synchronization
• Same service as a multiprogrammed
uniprocessor
• Example: time-sharing system
Coarse and Very CoarseGrained Parallelism
• Synchronization among processes at a
very gross level (e.g. at the beginning and
at the end)
• Good for concurrent processes running on
a multiprogrammed uniprocessor
– Can by supported on a multiprocessor
with little change
Medium-Grained Parallelism
• Parallel processing or multitasking within
a single application
• Single application is a collection of
threads
• Threads usually interact frequently
Fine-Grained Parallelism
• Highly parallel applications
• Specialized and fragmented area
Scheduling
design issues
• Assignment of processes to
processors
• Use of multiprogramming on
individual processors
• Actual dispatching of a process
• The scheduling depends on
– degree of granularity
– number of processors available
Issue #1
Assignment of Processes to Processors
• Treat processors as a pooled
resource and assign process to
processors on demand
• Static or dynamic assignment?
• Master/slave or peer architecture?
Static vs. dynamic assignment
• Static: dedicate short-term queue for
each processor
– Advantages: Less overhead
– Disadvantages: Processor could be idle while
another processor has a backlog
• Dynamic: use a global queue and
schedule processes to any available
processor
Type of architecture master/slave or peer?
• Master/slave architecture
– Key kernel functions always run on a
particular processor
– Master is responsible for scheduling
Advantages: simple approach
Disadvantages
–Failure of master brings down
whole system
–Master can become a
performance bottleneck
Type of architecture master/slave or peer?
• Peer architecture
– Operating system can execute on any
processor
– Each processor does self-scheduling
Disadvantages
Complicates the operating system
• Make sure two processors do not
choose the same process
Issue #2:
Multiprogramming on a single processor
• Depends on the synchronization granularity
• A. Course-grained parallelism:
– processor utilization considerations
Each individual processor should be able to
switch among a number of processes
• B. Medium-grained parallelism:
– application performance considerations:
An application that consists of a number of
threads may run poorly unless all of its threads
are available to run simultaneously
Issue #3:
Process dispatching
• Uniprocessor systems:
– sophisticated scheduling algorithms
• Multiprocessor systems
– processes: simple algorithms work
best (see Fig.10.1)
– threads: the main consideration is the
synchronization between threads
Process Scheduling
• Basic method used:
dynamic assignment
• Single queue for all processes
• Multiple queues are used for priorities
• All queues feed to the common pool of
processors
• specific scheduling discipline is much
less important with multiprocessors
with one processor (see Fig.10.1)
Threads
• An application can be a set of threads that
cooperate and execute concurrently in the
same address space
• Threads running on separate processors
yield a dramatic gain in performance
Multiprocessor Thread
Scheduling
• Load sharing
– Processes are not assigned to a
particular processor
• Gang scheduling
– Simultaneous scheduling of threads
that make up a single process
Multiprocessor Thread
Scheduling
• Dedicated processor assignment
– Threads are assigned to a specific
processor
• Dynamic scheduling
– Number of threads can be altered
during course of execution
Load Sharing
One of the most commonly used
schemes in current multiprocessors,
despite the potential disadvantages
• Load is distributed evenly across the
processors
• No centralized scheduler required
• Use global queues
Versions of Load Sharing
• First come first served (FCFS)
• Smallest number of threads first:
– priority queue, with highest priority given to
threads from jobs with the smallest number of
unscheduled threads.
• Preemptive smallest number of threads
first:
– An arriving job with a smaller number of
threads than an executing job will preempt
threads belonging to the scheduled job.
Disadvantages of Load
Sharing
• The common queue needs mutual
exclusion
– May be a bottleneck when more than one
processor looks for work at the same time
• Preempted threads are unlikely to resume
execution on the same processor
– Cache 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
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
Gang scheduling
• Processor allocation
• N processors, M applications
• each application - less than N threads
• options:
– each application is given 1/M of the available
time on the N processors
– the given time slice is proportional to the
number of threads in each application
Scheduling Groups
Dedicated Processor
Assignment
• When application is scheduled, its threads
are assigned to a set of processors, oneto-one, for the duration of the application.
• Some processors may be idle
• No multiprogramming of processors
Dedicated Processor
Assignment
• Motivation
• In a highly parallel system processor
utilization is no longer so important
• Total avoidance of process switching
Dedicated Processor
Assignment
• Problem:
• If the number of the active threads is
greater than the number of the
processors, there would be greater
frequency of thread preemption and
rescheduling
Dedicated Processor
Assignment
• Comparison with gang
scheduling:
•
Similarities - threads are
assigned to processors at the same
time
•
Differences - in dedicated
processor assignment threads do not
change processors.
Gang scheduling and
Dedicated Processor Assignment
• More similar to memory assignment
than to uniprocessor scheduling:
•
In memory scheduling, pages are
assigned to processes
•
In Gang scheduling and
dedicated processor assignment
processors are assigned to
processes.
Dynamic Scheduling
• Both the operating system and the
application are involved in making
scheduling decisions.
The operating system is responsible
for partitioning the processors among
jobs.
Each job uses the processors
currently in its partition to execute
some subset of its runnable tasks by
mapping these tasks to threads.
Dynamic Scheduling
On request for a processor
• If there are idle processors, use them
to satisfy the request.
• Otherwise, if it is a new arrival,
allocate it a single processor (by taking
one away from any job currently allocated more
than one processor.)
• If any portion of the request cannot
be satisfied, it remains outstanding
Upon release of one or more
processors
• Scan the current queue of unsatisfied
requests for processors.
• Assign a single processor to each job in
the list that currently has no processors
(i.e., to all waiting new arrivals).
• Then scan the list again, allocating the
rest of the processors on an FCFS basis.
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
process must be able to keep up with
them
Real-Time Systems
•
•
•
•
•
•
Control of laboratory experiments
Process control plants
Robotics
Air traffic control
Telecommunications
Military command and control
systems
Types of Tasks
A. With respect to urgency
• Hard real-time task
– must meet its deadline
• Soft real-time task
– deadline is desirable but not
mandatory
Types of Tasks
B. With respect to execution
• Aperiodic task has a deadline by
which it must finish or start, or both
• Periodic task executes once per
period T or exactly T units apart.
Characteristics of Real-Time
Operating Systems
Areas of concern
 Determinism
 Responsiveness
 User control
 Reliability
 Fail-soft operation
Characteristics of Real-Time
Operating Systems
• Determinism
– Operations are performed at fixed,
predetermined times or within
predetermined time intervals
– Concerned with how long the operating
system delays before acknowledging
an interrupt
Characteristics of Real-Time
Operating Systems
• Responsiveness
– How long, after acknowledgment, it
takes the operating system to service
the interrupt
– Includes amount of time to begin
execution of the interrupt
– Includes the amount of time to perform
the interrupt
Characteristics of Real-Time
Operating Systems
• User control
– User specifies priority
– Specifies paging
– What processes must always reside in
main memory
– Disks algorithms to use
– Rights of processes
Characteristics of Real-Time
Operating Systems
• Reliability
– Degradation of performance may have
catastrophic consequences
• fail-soft operation - the ability to fail in such
a way as to preserve as much capability and data
as possible
– Attempt either to correct the problem or
minimize its effects while continuing to
run
Features of Real-Time
Operating Systems
• Small size (with its associated
minimal functionality)
• Fast process or thread switch
• Ability to respond to external
interrupts quickly
• Use of special sequential files that
can accumulate data at a fast rate
Features of Real-Time
Operating Systems
• Ability to respond to external
interrupts quickly
 Multitasking with interprocess
communication tools such as semaphores,
signals, and events
 Preemptive scheduling based on priority
 Minimization of intervals during which
interrupts are disabled
 Primitives to delay tasks for a fixed amount
of time and to pause/resume tasks
 Special alarms and time-outs
Real-Time Scheduling
Approaches
• When to dispatch
• How to schedule
(1) whether a system performs schedulability
analysis,
(2) if it does, whether it is done statically or
dynamically, and
(3) whether the result of the analysis itself
produces a schedule or plan according to
which tasks are dispatched at run time.
• Types of tasks periodic/aperiodic
– deadline scheduling
– rate monotonic scheduling
Scheduling of a Real-Time Process
When to dispatch
Scheduling of a Real-Time Process
When to dispatch
Scheduling of a Real-Time Process
When to dispatch
Scheduling of a Real-Time Process
When to dispatch
Real-Time Scheduling
How to schedule
• Static table-driven
• Static priority-driven preemptive
• Dynamic planning-based
• Dynamic best effort
Real-Time Scheduling
How to schedule
• Static table-driven
– Determines at run time when a task
begins execution
– Used for periodic tasks
– Inflexible approach - any change
requires the schedule to be redone
Real-Time Scheduling
How to schedule
• Static priority-driven preemptive
– No schedule is drawn up.
– The analysis is used to assign
priorities to tasks
– Traditional priority-driven
scheduler is used
Real-Time Scheduling
How to schedule
• Dynamic planning-based
– feasibility is determined at run time
– attempt to accommodate the new task
into the existing schedule
Real-Time Scheduling
How to schedule
• Dynamic best effort
– no feasibility analysis is performed
– a priority is assigned based on the
characteristics of the task
– the system tries to meet all
deadlines and aborts tasks with
missed deadlines
– used for aperiodic tasks
Deadline Scheduling
• Real-time applications are not
concerned with speed but with
completing tasks
• Scheduling tasks with the earliest
deadline minimizes the fraction of
tasks that miss their deadlines
Deadline Scheduling
• Information used
– Ready time
– Starting deadline
– Completion deadline
– Processing time
– Resource requirements
– Priority (hard-real time vs soft real time)
– Subtask scheduler (mandatory subtask,
optional subtask)
Deadline Scheduling
• Ending deadlines - preemptive
scheduling
• Starting deadlines - non-preemptive
scheduling with unforced idle times
•
Requirement: we need to know in
advance the processes to be
executed
Two Tasks
Rate Monotonic Scheduling
• Assigns priorities to tasks on the basis of
their periods
• Highest-priority task is the one with the
shortest period
Periodic Task Timing Diagram
• CPU utilization = C/T
• to meet all deadlines:
• C1/T1 + C2/T2 + … Cn/Tn  1
Linux Scheduling
• Scheduling classes
– SCHED_FIFO: First-in-first-out real-time
threads
– SCHED_RR: Round-robin real-time threads
– SCHED_OTHER: Other, non-real-time
threads
• Within each class multiple priorities may
be used
UNIX SVR4 Scheduling
• Highest preference to
real-time processes
• Next-highest to kernel-mode processes
• Lowest preference to
other user-mode processes
Windows 2000 Scheduling
• Priorities organized into two bands or
classes
– Real-time
– Variable
• Priority-driven preemptive scheduler