what is a good model
play

What is a good model? A model is a representation of something. It - PDF document

10/8/2019 What is a good model? A model is a representation of something. It captures not all attributes of the represented thing, but rather only those that are relevant for a specific purpose. It should be expressive (an accurate


  1. 10/8/2019 What is a good model? A model is a representation of something. It captures not all attributes of the represented thing, but rather only those that are relevant for a specific purpose.  It should be expressive (an accurate representation of reality)  It should be tractable (provide results in a bounded time) Unfortunately, expressiveness and tractability do not get along very well Unfortunately, expressiveness and tractability do not get along very well Untractability (complexity) Useless models (too complex to be GOOD analyzed) Useless models MODEL (too far from reality) 2 expressiveness Important aspects Types of variables Building a model implies:  Parameters (variables you don’t want to change);  clearly identifying the assumptions you need to  Input variables (commands given by the user/controller) simplify reality (but don't simplify too much);  Design variables (variables you want to identify to apply  defining the variables that characterize the model. your control actions);  defining the system interface (variables are exposed  State variables (variables describing the system state to the user); and behavior);  defining the metrics for evaluating the outputs of  Output variables (variables you want to measure to your system and its performance. evaluate the performance of your method). 3 4 Example Modeling computation Application model Timing Timing solution Analysis Analysis Task model Task model Assumptions Assumptions Evaluation metrics NO Definition of task/app feasible? parameters YES  Parameters: Pole length/mass, cart mass Sys. Req. Sys. Req. implementation implementation  Input variables: Force applied to the cart System model System model RTOS model RTOS model Platform model Platform model  Design variables: Control parameters (K P , K I , K D )  State variables: System to be controlled Position/speed of the cart and pole I/O I/O RTOS RTOS devices devices  Output variables: Pole angle 6 1

  2. 10/8/2019 Task Ready queue Sequence of instructions that in the absence of other activities In a concurrent system, more tasks can be simultaneously is continuously executed by the processor until completion. active, but only one can be in execution (running).  An active task that is not in execution is said to be ready. Activation Task  i time (a i )  Ready tasks are kept in a ready queue, managed by a C i scheduling policy. Start time (s i ) t a i s i f i  The processor is assigned to the first task in the queue through a dispatching operation. Computation R i time (C i ) The interval f i  a i The interval f i  a i Ready queue activation dispatching termination is referred to as the task is referred to as the task  3  2  1 CPU Finishing response time R i response time R i time (f i ) Preemption Schedule It is a kernel mechanism that allows to suspend the It is a kernel mechanism that allows to suspend the Is a particular assignement of tasks to the processor that execution of the running task in favor of a more important execution of the running task in favor of a more important determines the task execution sequence: task. The suspended task goes back in the ready queue. task. The suspended task goes back in the ready queue. Formally, given a task set  = {  1 , ...,  n }, a schedule is a Formally, given a task set  = {  1 , ...,  n }, a schedule is a function  : R +  N that associates an integer k to each function  : R +  N that associates an integer k to each Ready queue activation dispatching termination  3  2  1 interval of time [t, t+1) with the following meaning: interval of time [t, t+1) with the following meaning: CPU preemption k = 0 in [t, t+1) the processor is IDLE  Preemption enhances concurrency and allows reducing the response times of high priority tasks. in [t, t+1) the processor executes  k k > 0  It can be disabled (completely or temporarily) to ensure the consistency of certain critical operations. Schedule Preemptive schedule priority  1  2  3  1 idle idle  (t)  2 3  3 2 1 0 2 4 6 8 10 12 14 16 18 20 0 t 1 t 2 t 3 t 4 t  (t)  Each interval [t i , t i+1 ) is called a time slice . 3 2  In time instants t 1 , t 2 , t 3 , t 4 the processor is said to 1 0 perform a context switch . 0 2 4 6 8 10 12 14 16 18 20 2

  3. 10/8/2019 Task states Task states priority running  1 BLOCKED signal wait running running  2 ready running running  3 ready dispatching 0 2 4 6 8 10 12 14 16 18 20 activation termination READY RUNNING  (t) preemption 3 2 1 ACTIVE 0 0 2 4 6 8 10 12 14 16 18 20 Real-Time Task Slack and Lateness  It is a task characterized by a timing constraint on its D i response time, called deadline:  i relative deadline D i t a i s i f i d i  i R i slack i = d i - f i t a i s i f i d i D i lateness L i = f i - d i absolute deadline response time R i ( d i = a i + D i )  i t A real‐time task  i is said to be feasible if it guaranteed to A real‐time task  i is said to be feasible if it guaranteed to a i s i d i f i complete within its deadline, that is, if f i  d i , o complete within its deadline, that is, if f i  d i , o R i equivalently, if R i  D i equivalently, if R i  D i Activation mode Tasks and jobs • Time driven : ( periodic tasks) A task running several times on different input data generates a sequence of instances (or jobs): A task is automatically activated by the operating system at predefined time instants.    Job 1 Job k Job k+1 • Event driven : ( aperiodic tasks)  i,1  i,k  i,k+1 A task is activated at the arrival of an event (by interrupt or by another task through an explicit C i  i system call). t a i,1 a i,k a i,k+1 3

  4. 10/8/2019 Periodic task Periodic task  i (C i , T i , D i ) job  ik input T i C i U i = C i T i C i computation time output utilization factor a i,1 =  i a i,k a i,k+1 t sync (period T i ) timer task phase  A periodic task  i generates an infinite sequence of a i,k =  i + (k  1) T i often jobs:  i1 ,  i2 , …,  ik (same code on different data): D i = T i d i,k = a i,k + D i T i C i  i Aperiodic task Estimating C i is not easy C i (computation time or execution time) is the C i (computation time or execution time) is the  Aperiodic: a i,k+1 > a i,k minimum minimum time taken by a processor to execute task  i , time taken by a processor to execute task  i , interarrival time interarrival time without considering suspension times. without considering suspension times.  Sporadic: a i,k+1  a i,k + T i C i  i t job  ik R i C i C i C i … If we want to meet a given deadline for all possible  i cases (i.e., event combinations), we have to estimate t a i,1 a i,k a i,k+1 the worst-case execution time (WCET). Example Let’s estimate the time taken to go to the airport by car. Two different approaches By Measurements # occurrences Home Airport WOET = WCET? WOET = WCET? time BOET AOET WOET 1. By Analysis : make a number of assumptions and estimate the worst-case time. BOET: Best Observed Execution Time 2. By Measurements : perform a lot of measures and AOET: Average Observed Execution Time take the maximum. WOET: Worst Observed Execution Time WCET: Worst-Case Execution Time 4

  5. 10/8/2019 By Measurements For a computation To make a precise estimate, we need to To make a precise estimate, we need to # occurrences know the task code and the CPU speed. know the task code and the CPU speed. Safety Margin ? Each job operates on different data and can take different paths. ? time BOET AOET WOET WCET WCET loop By Analysis actual BOUND ? estimated by analysis  Bound the loop cycles. ? BOET: Best Observed Execution Time  Compute the longest path. AOET: Average Observed Execution Time  Bound the number of cache misses. WOET: Worst Observed Execution Time  Compute the execution time for each WCET: Worst-Case Execution Time instruction in the longest path. For a computation Predictability vs. Efficiency By Measurements # occurrencies  Execute the task several times using different input data. ?  Collect statistics on the execution times: loop ? execution # occurrencies time ? min avg max C i C i C i C i estimate execution unsafe efficient safe time min max C i C i Predictability vs. Efficiency Criticality HARD task SOFT tasks FIRM tasks HARD tasks All jobs must meet their deadlines. Missing a single deadline may cause catastrophic effects on the whole system. FIRM task efficiency predictability Missing a job deadline has not catastrophic effects on the system, but invalidates the execution of that particular job. SOFT task Missing a deadline is not critical. A job finishing after its deadline has still some value but causes a performance degradation. C i An operating system able to handle hard real-time min avg max C i C i C i tasks is called a hard real-time system. 5

Recommend


More recommend