Você está na página 1de 53

A Reference Model of Real Time Systems

Chapter 3

Why we need a model?

To validate the real time systems and the timing constraints , we describe a reference model of real time systems In this model, the real time systems is characterized by three elements: (1) A workload model (2) A resource model (3) Algorithms that define how the application use these resources In this chapter, the focus will be on the first two models Model 3 will be discussed in a later chapters

Why we need a model?

The resource model describes the system resources available to the applications The workload model describes the applications supported by the systems

Processors and resources


The system resources is divided into two major types: 1. Processors 2. Resources

Processors Processors are often called servers e.g. computers, transmission link, disks, etc. We use p to denote processors p1, p2, , pm

Processors and resources


Resources the resources denoted by R Example: memory In order for the job to be executed, it needs memory

Temporal Parameters of real time workload


Job: is a unit of work to be allocated processor time and other resources Task: is a set of related jobs To ensure that the system meets its hard real time requirement, many parameters of hard real time jobs are known a head of time E.g. of parameters: the number of tasks , the deadline of the task,

Temporal Parameters of real time workload


The number of jobs in the system may change E.g. air traffic control system - each surveillance task monitors an aircraft - the number of tasks changes as tasks are added and deleted when aircraft enters and leave the coverage area the number of tasks with hard real timing constraints is known all the time Otherwise, it would not be possible to ensure that the system meet its hard real time requirements

Temporal Parameters of real time workload


The number of tasks with hard real timing constraints is known all the time When the satisfaction of their timing constraints is to be guaranteed, the admission and the deletion of the hard real time jobs are done by the scheduler The system must maintain information on all existing hard real timing constraints

Temporal Parameters of real time workload

Each job ji is characterized by its temporal parameters, functional parameters, and resource parameters, and interconnection parameters The temporal parameter of the jobs Tells us its timing constraints and behavior The interconnection parameter of the jobs Describe how it depends on other jobs and how other jobs depend on it The Functional parameters Specify the intrinsic properties of the job

Temporal Parameters of real time workload


The resource parameters Gives us the jobs resources requirements The release time, the absolute deadline, the relative deadline of a job ji ( temporal parameters) ri: release time di: absolute deadline Di : relative deadline The time interval (ri, di] : the time interval between the release time and the absolute deadline is the feasible interval Di , di are derived from the timing requirement of ji

Fixed, Jittered, and sporadic Release Times


In many systems, we dont know exactly when each job will be released to the system We dont know the actual release time ri of each job ji It is determined that ri is in the range [ri-, ri+] ri can be as early as the earliest release time ri ri can be as late as ri+ Some real time systems models assume that only the range of ri is known, this known is range is called the jitter in ri or the release time jitter

Fixed, Jittered, and sporadic Release Times

If we can approximate the actual release time of each job by its earliest or latest release time, then we say that the job has a fixed release time Every real time system is required to respond to external events which occur at random instant of time When such event occurs, the system executes the set of jobs in response The release time of these jobs are not known until the event triggering them occurs These jobs are called sporadic jobs or aperiodic jobs because they are released at random time instants

Fixed, Jittered, and sporadic Release Times


E.g. the pilot may disengage the auto pilot system at any time When this occurs, the autopilot systems change from cruise mode to stand by mode The jobs that execute to accomplish this mode change are called sporadic jobs The release times of sporadic and aperiodic jobs are random variables

Fixed, Jittered, and sporadic Release Times

The model of the system gives the probability distribution A(x) of the release time of such a job, or when there is a stream of similar sporadic or aperiodic jobs A(x) gives us the probability that the release time of the job is at or earlier than x We use the term arrival rate or interarrival rate instead of using the release time of aperiodic A(x) is the arrival time distribution

Execution Time

Another temporal parameter of a job Ji is its execution time ei ei is the amount of time required to complete the execution of ji when it executes and has all the resources it requires The value of this parameter depends mainly on the complexity of the job and the speed of the processor used to execute the job, not on how the job is scheduled

Execution Time
The actual amount of time required by a job to complete its execution may vary for many reasons A computation may contain conditional branch The branches may take different amount of time to complete The branches takes during the execution of the computation job depend on the input data Cache memory, pipeline For these reasons, the actual execution time of a computation job is unknown until it completes

Execution Time
What can be determined a priori is minimum execution time and the maximum execution time [ei-, ei+] ei-: the minimum amount of time required to complete a job ei+: the maximum amount of time required to complete a job We assume that we know ei- and ei+ for every hard real time job Ji The actual execution time of the job is unknown

Execution Time
For the purpose of determining whether each job can always complete by its deadline Knowing the maximum execution time of job is sufficient In most real time systems models that used to characterize hard real time systems, ei of each job Ji specifically means the maximum execution time Except where state otherwise, we never mean that the actual execution time of the job is fixed and known, only that it never exceeds ei

Execution Time

The processors might be underutilized The hard real time portion is often small The timing requirements of the rest of the system are soft It is the best option to design the hard real time subsystem based on its worst case processor time and the resource requirement even though their actual requirements maybe much smaller This method will be used to ensure that the hard timing constraints will surely be met all the time

Periodic Task Model


It characterizes accurately many hard real time applications In the periodic task model, each computation or data transmission that is executed repeatedly at regular or semi regular time intervals in order to provide a function of the system on a continuing basis is modeled as a period task Each periodic task denoted by Ti, is a sequence of jobs The period pi of the periodic task Ti is the minimum length of all time intervals between release time of consecutive jobs in Ti

Periodic Task Model


The execution time of the periodic task is the maximum execution time of all the jobs in it We use ei to denote the execution time of the periodic task The periodic task refers to a task that is truly periodic, the interrelease time of all jobs in the periodic task are equal to its period More details in periodic task will be explained in chapter 6

Periodic Task Model


We call the periodic tasks in the system T1, T2, , Tn To refer to an individual job in a task Ti, we call them Ji,1, Ji,2, Ji,3,, Ji,k being the kth job in task Ti The release time ri,1 of the first job Ji,1 in each task Ti is called the phase of Ti i - phase of Task Ti, equal to ri1 in general, different tasks may have different phases Some tasks are in the phase meaning that they have the same phase

Periodic Task Model


We use H to denote the least common multiple of pi for i= 1, 2, 3, ,n A time interval of length H is called a hyperperiod of the periodic tasks The maximum number N of jobs in each hyperperiod is equal to ni=1 H/pi The length of a hyperperiod of three periodic tasks with periods 3, 4, and 10 is 60. the total number N of jobs in the hyperperiod is 41

Periodic Task Model


ui is the utilization of the task Ti ui = ei/pi It is equal to the fraction of time a truly periodic task with period pi and execution time ei keeps a processor busy The total utilization of the system is the sum of the utilization of the individual tasks in it If the execution time of three periodic tasks are 1,1, and 3, and their period are 3,4, and 10 then their utilization is 0.33, 0.25, 0.3 The total utilization of the tasks is 0.88, meaning that these tasks can keep the processor busy at most 88 percent of the time

Aperiodic and Sporadic Tasks


Real time system is required to respond to external events To respond, it executes aperiodic or sporadic jobs whose release times are not known a priori Example: an operators adjustment of the sensitivity setting of the radar surveillance system The radar system must continue to operate, but in addition it also must respond to the operators command When a pilot changes the auto pilot from cruise mode to standby mode, the system must respond by configuring itself , while continuing to execute the control tasks that fly the airplane

Aperiodic and Sporadic Tasks


Each aperiodic and sporadic task is a stream of a periodic or sporadic jobs The interarrival times between consecutive jobs in such a task may vary widely The jobs in each task model the work done by the system in response to events of the same type Example The jobs that execute to change the detection threshold of the radar system are in one task The job that change the operation mode of the auto pilot are in one task, and the jobs that process sporadic data messages are in one task

Aperiodic and Sporadic Tasks


The task is aperiodic if the jobs in it have either soft deadlines or no deadline Example: the task to adjust radar sensitivity We want the system to be responsive, that is to complete each adjustment as soon as possible A late response is annoying but tolerable

Aperiodic and Sporadic Tasks

The autopilot system is required to respond to a pilots command to disengage the autopilot and take over the control manually within a specific time Tasks containing jobs that are released at random time instants and have hard deadlines are sporadic tasks

Precedence Constraints and Data Dependency


Data and control dependencies among jobs may constrain the order in which they can execute In classical scheduling theory, the jobs are said to have precedence constraints if they are constrained to execute in some order Otherwise, if the jobs can execute in any order, they are said to be independent For example, in radar surveillance system, the signal processing task is the producer of track records, while the tracker task is the consumer

Precedence Constraints and Data Dependency


Each tracker job processes the track records generated by a signal processing job The designer may choose to synchronize the tasks so that the execution of the kth tracker job does not begin until the kth signal processing job complete The tracker job is precedence constrained In general, a consumer job has this constraint whenever it must synchronize with the corresponding producer jobs and wait until the producer completes in order to execute

Precedence Constraints and Data Dependency


Example Consider queries to an information server Suppose that before each query is processed and the requested information retrieved, its authorization to access the requested information is first checked The retrieval job can not begin execution until the authorization job completes The communication job that forwards the information to the requester can not begin until the retrieval job completes

Precedence Constraints and Data Dependency

In communication system, the jobs that generate an acknowledgement of a message and transmit the acknowledgement of a message can not begin until the job receives and processes the message complete

Precedence Graph and Task Graph


use the partial order relation <, called a precedence relation over the set of jobs to specify the precedence constraints among jobs A job Ji is a predecessor of another job Jk (Jk is a successor of Ji) if Jk can not begin execution until the execution of Ji completes Ji < Jk ( Jk depends on Ji) Ji is an immediate predecessor of Jk, and Jk is an immediate successor of Ji If Ji < Jk and there is no other jobs Jj such that Ji<JJ<Jk

Precedence Graph and Task Graph


Two jobs Ji and Jk are independent when neither Ji<Jk nor Jk<Ji A job with predecessors is ready for execution when the time is at or after its release time and all of its predecessors are completed

Precedence Graph and Task Graph


A classical way to represent the precedence constraints among jobs in a set J is by a directed graph G = (J, <) Each vertex in this graph represents a job in J We call each vertex by the name of the job represented by it There is a directed edge from the vertex Ji to the vertex Jk when the job Ji is an immediate predecessor of the job Jk This graph is called a precedence graph

Precedence Graph and Task Graph

A task graph gives us a general way to describe the application system is an extended precedence graph

Functional Parameter
Preemptivity of jobs execution of jobs can often be interleaved The scheduler may suspend the execution of a less urgent job and give the processor to a more urgent job When the more urgent job completes, the scheduler returns the processor to the less urgent job so the job can resume execution This interruption of jobs called preemption

Functional Parameter
A job is preemptable if its execution can be suspended at any time to allow the execution of other jobs, and later on, can be resumed from the point of suspension A job is nonpreemptable if it must be executed from start to completion without interruption This constraint me be imposed because its execution , if suspended and the processor given to other jobs, must be executed again from the beginning Example Jobs that model the transmission of data frame in a token ring, if transmission of frame is interrupted before it completes, the partially transmitted frame is discarded by the receiver

Functional Parameter

During the preemption, the system must first save the state of the preempted jobs at the time of preemption so it can resume the job from that state For example, in the case of CPU jobs, the state of the preempted job include the content of its program counter, processor status register, and register containing temporary results After saving the contents of these registers in memory and before the preempting job can start, the operating system must load the new processor status register, clear the pipeline, and so on These actions are called context switch (overhead work done during preemption)

Functional Parameter
Criticality of Jobs jobs are not equally important The importance ( criticality) of jobs is a positive number that indicates how critical the job is with respect to other jobs The more critical the job, the larger its importance The term priority and weight are often used to refer to importance The more important a job, the higher its priority or the larger its weight

Functional Parameter
During the overload when it is possible to schedule all the jobs to meet their deadline Sacrifice the less critical jobs so that the more critical jobs can meet their deadline For example, in a flight control and management system, the job that controls the flight of the aircraft is more critical than the navigation job The navigation job is more critical than the job that adjust the course and cruise speed in order to minimize fuel consumption The cabin air flow and the temperature control job is more critical than jobs that run movies

Functional Parameter

The laxity type of a job indicates whether its timing constraints are soft or hard

CPU Scheduler

Selects from among the processes in memory that are ready to execute, and allocates the CPU to one of them. CPU scheduling decisions may take place when a process: 1. Switches from running to waiting state 2. Switches from running to ready state 3. Switches from waiting to ready 4. Terminates

Scheduling Criteria

CPU utilization keep the CPU as busy as possible Throughput # of processes that complete their execution per time unit Turnaround time (TAT) amount of time to execute a particular process Waiting time amount of time a process has been waiting in the ready queue Response time amount of time it takes from when a request was submitted until the first response is produced

First Come First Served Scheduling

First Come First Served Scheduling


Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3

Example:

Waiting time for P1 = 0; P2 = 24; P3 = 27

P1
0

P2

P3

Average waiting time: (0 + 24 + 27)/3 = 17

24 27arrive 30in the order: P2 , P3 , P1 . Suppose that the processes

P2 P3 P1 Non-preemptive scheduling 0 3 6 30 Troublesome for time-sharing systems Convoy effect short process behind long process

Waiting time for P1 = 6; P2 = 0; P3 = 3 Average waiting time: (6 + 0 + 3)/3 = 3


CSS430 CPU Scheduling 49

Shortest Job First Scheduling


Process P1 P2 P3 P4 Non preemptive SJF

Example:

Arrival Time Burst Time 0 7 2 4 4 1 5 4


Average waiting time = (0 + 6 + 3 + 7)/4 = 4

P1 0 P1(7) P2(4) P3(1) P4(4) 2 4 5

P3 7 8

P2 12

P4 16 P1s wating time = 0 P2s wating time = 6

P3s wating time = 3


P4s wating time = 7

CSS430 CPU Scheduling

50

Shortest Job First Scheduling Contd


Process P1 P2 P3 P4 Preemptive SJF

Example:

Arrival Time Burst Time 0 7 2 4 4 1 5 4


Average waiting time = (9 + 1 + 0 +2)/4 = 3

P1
P1(7) 0 2 P1(5)

P2 P3
4 5

P2 7

P4
11

P1 16 P1s wating time = 9 P2s wating time = 1

P2(4) P2(2) P3(1) P4(4)

P3s wating time = 0


P4s wating time = 2

CSS430 CPU Scheduling

51

Round Robin Scheduling


Each process is given CPU time in turn time quantum = 20 Process Burst Time W Wait Time P1 53 57 +24 = 81 P2 17 20 P3 68 37 + 40 + 17= 94 P4 24 57 + 40 = 97

P1 P2 P3 P4 P1 P3 P4 P1 P3 P3 0 20 37 57 77 97 117 121 134 154 162 P1(13) P1(33) 24 P1(53) 57 P2(17) 20 P3(68) P4(24)
37 57 Average wait time = (81+20+94+97)/4 = 73 40P3(48) 40

17

P3(28) P3(8)

P4(4)
CSS430 CPU Scheduling 52

Round Robin Scheduling

Typically, higher average turnaround than SJF, but better response. Performance q large FCFS q small q must be large with respect to context switch, otherwise overhead is too high.

CSS430 CPU Scheduling

53

Você também pode gostar