1 / 48

2. Characterizing Real-Time Systems

2. Characterizing Real-Time Systems. 2.1 Modeling real-time systems 2.2 Estimating program run times 2.3 Real-time measures 2.4 Real-time kernels. Review. 1. Introduction 1.1 Background 1.2 Real-time applications 1.3 Misconceptions 1.4 Issues in real-time computing

sheba
Download Presentation

2. Characterizing Real-Time Systems

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 2. Characterizing Real-Time Systems 2.1 Modeling real-time systems 2.2 Estimating program run times 2.3 Real-time measures 2.4 Real-time kernels

  2. Review 1. Introduction 1.1 Background 1.2 Real-time applications 1.3 Misconceptions 1.4 Issues in real-time computing 1.5 Structure of a real-time system Real-Time Systems (Shin)

  3. 2.1 Modeling Real-Time Systems • Parameters of real-time tasks • timing constraints of a task • computation(execution) time, ci • deadline • relative deadline, di • absolute deadline, Di • release(arrival) time, ri • laxity(slack), Li For periodic tasks • period, Ti • hyperperiod, H: LCM of all periods • phase, Ii • the release time of the first instance Real-Time Systems (Shin)

  4. Parameters of real-time tasks(cont.) • inter-task constraints/parameters • preemptivity • context switch time • time caused by blocking, Bi • time caused by preemption • precedence constraints • data dependency • temporal dependency • criticality of tasks Real-Time Systems (Shin)

  5. Performance measures • reliability, R(t) • availability, A(t) • performability, P(L,t) • response time • throughput • nominal capacity, usable capacity • efficiency • utilization • cost/performance ratio Real-Time Systems (Shin)

  6. Modeling tools and methods • natural languages • mathematical specification • flowcharts • structure charts • pseudo-codes • finite state machines • data flow diagrams • petri net • statecharts Real-Time Systems (Shin)

  7. Petri Net • Basic model • bipartite graph • BPN = ( P, T, A ) • P = { p1, p2, …, pn } places • T = { t1, t2, …, tn } transitions • A = { P x T } ∪ { T x P } directed arc • Ai⊆ P x T, Ao⊆ T x P Real-Time Systems (Shin)

  8. A new job enters the system place A job is on the input list. The processor is idle. transition A job is being processed. directed arc Job processing is completed. A job is on the output list. Modeling of a simple computer system. A job leaves the system. Real-Time Systems (Shin)

  9. Marked Petri Net • tokens: A place pi has mi tokens. • PN marking: M = { m1, m2, …, mn } • model • PN = ( P, T, A, M0 ) • M0 = { m01, m02, …, m0n } : net initial marking • Rules • A transition is enabled when all input places have at least one token. • Tokens ‘travel’ to the output places when the enabled transition fires. • The firing of a net produces new marking. Real-Time Systems (Shin)

  10. Major characteristics of marked PN • voluntary: fires only if it is enabled • instantaneous • complete: no partial firing • System state • a particular marking of the places • changes through firing of the enable transitions • reachability tree Real-Time Systems (Shin)

  11. P1 t 1 P2 P3 t 4 t 2 t 3 P4 P5 An example of marked PN t 5 Real-Time Systems (Shin)

  12. M0 = {1,0,0,0,0} t1 M1 = {0,1,1,0,0} t2 t3 M2 = {0,0,1,1,0} M3 = {0,1,0,0,1} t3 t2 t4 M4 = {0,0,0,1,1} M1 t4 t5 M3 M0 The reachability tree of the marked PN Real-Time Systems (Shin)

  13. P 1 P6 P11 Modeling of a railroad crossing Approach t 1 t 4 P5 Before Crossing P2 P9 up t 2 t 7 Within t 6 P3 t 5 P7 P12 t 3 down Crossing P10 Past P4 P8 Computer Real-Time Systems (Shin)

  14. Timed Petri Net • timing properties • examples • delay added to transitions • timing constraints assigned to places • model • TPN = ( P, T, A, M0, D ) • D : a set of delays associated with transitions t1, d1 p2 p1 Real-Time Systems (Shin)

  15. Statecharts • Statecharts • FSA + depth + orthogonality + broadcast comm • depth : represented by ‘insideness’ of states • orthogonality : by dashed lines separating states • broadcast communication : labelled arrows • Combines the best of data flow and FSA • Represents concurrency and intertask comm. • CASE tool: STATEMATE by i-Logix Real-Time Systems (Shin)

  16. dead bt - in bt - rm/clh bt - dy alive main power weak OK displays bt - wk beep - rt beep light t - hits - tm [in{enab}] b on off b - up alarm-st chime-st a[in{alarm}] c-enab d [in{chime}] enab disab t-hits-hr c-beep quiet c-disab a[in{alarm}] beep-st d [in{chime}] Statechart: High-level description of the watch Real-Time Systems (Shin)

  17. dead bt-in bt-dy ali ve bt-rm/clh main power displays A state chart for the digital watch update date weak c t-min min d b d c c bt-wk c time hour sec c c a ok date day chime a c alarm a a c stopwatch zero c b H d[in{off}] b up-alarm light min disp run hour reg on d c off b c [in{on}] d b t-min lap off H b b-up on beep-rt t-tits-tm [in{enab}] 2-min beep [not in{stopwatch}] alarm-st chime-st c-enab d[in{chime}] d[in{alarm}] t-hits-hr enab disab c-beep quit c-disab beep-st d[in{alarm}] d[in{chime}] Real-Time Systems (Shin)

  18. 2.2 Estimating Execution Times • Factors affecting runtime estimation • source codes • compilers • operating systems • machine architectures • # registers • pipelining • cache • input data Real-Time Systems (Shin)

  19. Approaches • measure execution times while running a program with test data • test data may not cover all cases possible • test environment may be different from reality • estimate by simulating using specification or modeling languages • results may not reflect the actual target system • Predict using source-level timing schema Real-Time Systems (Shin)

  20. Estimating based on source-level timing schema • To predict temporal behavior of programs written in high-level languages • Timing schema • produces guaranteed best- and worst-case bounds • includes control costs and interference [ Ref: Park, Shaw “Experiments with a program timing tool based on source-level timing schema” RTSS’90 ] Real-Time Systems (Shin)

  21. Timing tool • computes estimates of the best-/worst-case execution times of a program P • given bounds of execution times for • elementary expressions • control structures • statements • procedures • loops • runs on a bare machine without OS Real-Time Systems (Shin)

  22. Timing schema approach (1) Decompose a statement S into basic component called atomic block. (2) Predict the implementation of each atomic block. - code prediction (3) Determine the execution times of the atomic blocks based on code prediction. (4) Compute execution time of the statement, T, using the times of its atomic blocks and timing schema. (5) Result: T(S) = [ tmin(S), tmax(S) ] Real-Time Systems (Shin)

  23. Timing schema approach - An example Given S1: a = b + c (1) decompose into atomic block T(S1) = T(b) + T(+) + T(c) + T(a) + T(=) (2) code prediction b : move M, R /* mov b, d0 */ + : add M, R /* mov c, d0 */ c, a : none = : mov R, M /* mov d0, a */ (3), (4) execution time ← T(b) + T(+) + T(=) Real-Time Systems (Shin)

  24. Timing schema for control statements S : if (exp) then S1 else S2 T(S) = [min(t1low, t2low), max(t1up, t2up)] where [t1low, t1up] = T(exp) + T(S1) + T(then) [t2low, t2up] = T(exp) + T(S2) + T(else) • Timing schema and code prediction for while statement S : while (exp) stmt; T(S) = (N+1) ·T(exp) + N · T(stmt) + T(while,N) where N is a pair of loop bounds (i.e., N = [nmin , nmax]) Real-Time Systems (Shin)

  25. (continued) Gnu C’s code generation rules: start_loop L1: exp exp S ==> exit_if_false ==> JRF L2 stmt stmt end_loop JRA L1 L2: where JRF means “jump_relative if false,” and JRA means “jump_relative always.” Real-Time Systems (Shin)

  26. Code prediction: T(exp) : T(expcode) T(stmt) : T(stmtcode) T(while,N) : N · T(JRF, fail) + T(JRF, succ) + N · T(JRA) where expcode and stmt code are predicted codes for exp and stmt, and JRF, fail is a jump instruction whose branch is not taken. Real-Time Systems (Shin)

  27. Timing tool design • The timing tool consists of • preprocessor • language analyzer • architecture analyzer • preprocessor • interprets user commands • prepares the working environment for the tool • converts the internal time scale(clock cycle) into a real time scale(microseconds) • architecture analyzer • maintains instruction execution times for language analyzer Real-Time Systems (Shin)

  28. (continued) • Language analyzer Preprocessor Language analyzer Parser Procedure times Loop bounds Time schema Code prediction Architecture analyzer Real-Time Systems (Shin)

  29. An example using the timing tool struct { int key; int value; } data[15]; binary_search(x) { int favalue, mid, up, low ; [low bound, upper bound] low = 0 ; [ 16, 16 ] up = 14 ; [ 20, 20 ] fvalue = -1 / * all data are positive */; [ 20, 20 ] Real-Time Systems (Shin)

  30. while (low <= up) *** WHILE statement *** Input LOOP-BOUNDS [1, 4] { mid = (low + up) >> 1; [ 52, 52 ] if ( data[mid].key == x ) { /* found */ up = low - 1; [ 40, 40 ] fvalue = data[mid].value; [ 72, 72 ] } [ 112, 112 ] else /* not found */ if (data[mid].key > x ) up = mid - 1; [ 40, 40 ] else low = mid + 1; [ 40, 40 ] [ 128, 134 ] [ 206, 222 ] } [ 258, 274 ] [ 352, 1340 ] Real-Time Systems (Shin)

  31. return fvalue; [ 26, 26 ] } [ 434, 1422 ] *** Target procedure( binary_sea ) Cycles = [ 478, 1466 ] Times = [ 48.62, 149.13 ] (microseconds) *** Target procedure( binary_sea ) body time Cycles = [ 434, 1422 ] Times = [44.15, 144.65 ] (microseconds) Real-Time Systems (Shin)

  32. 2.3 Real-Time Measures • Rhealstone metric • task switching time, tts • preemption time, tp • interrupt latency time, til • semaphore shuffling time, tss • deadlock breaking time, tdb • datagram throughput, tdt • Rhealstone number, R = ∑i(1/ti) Real-Time Systems (Shin)

  33. Task Number Task 3 Task 2 Task 1 Time t 1 t 2 t 3 Definition of task switching time Real-Time Systems (Shin)

  34. Tasks Interrupt Handler Current Running Task t IL Time Definition of interrupt latency time Real-Time Systems (Shin)

  35. Tasks Semaphore Ownership Task 1 Task 2 Task 2 Task 1 t 1 t 2 t 3 t 4 t 5 Time t SS Task 1 requests semaphore Task 1 relinquishes semaphore Task 2 requests semaphore Task 2 obtains semaphore Task 2 has a higher priority. Definition of semaphore shuffling time Real-Time Systems (Shin)

  36. tDB = ta + tb Critical Resource Owner Task 3 high priority Task 2 medium priority Task 1 low priority t1 t2 t3 t4 t5 t6 tA tB Task 1 gets a resource Task 1 releases the resource Task 3 requests the resource Task 3 gets the resource Deadlock breaking timing diagram Real-Time Systems (Shin)

  37. Datagram TASK 1 TASK 2 Acknowledgement Datagram throughput measured in kbytes/sec Real-Time Systems (Shin)

  38. Process dispatch latency time • interrupt response time • hardware delay • completion of current instruction • interrupt latency • interrupt routine • preprocessing • interrupt servicing • post processing • software recognition of the need for context switch • context switch Real-Time Systems (Shin)

  39. software recognition of the need for context switch interrupt routine interrupt response time context switch hard- ware delay finish current instr. interrupt latency pre- processing interrupt servicing post- processing High priority interrupt occurs. Real-time task execution Process dispatch latency time Real-Time Systems (Shin)

  40. 2.4 Real-Time Kernels • Characteristics of real-time software • no virtual memory • priority-based scheduling • static resource allocation • no file system • usually one application program • fast interprocess data transmission • fast context switching and interrupt processing • small size Real-Time Systems (Shin)

  41. Types of real-time kernels • polling loop • cyclic executive, “big loop” • coroutines • interrupt-driven system • foreground/background • real-time multitasking executive • real-time operating system Real-Time Systems (Shin)

  42. Kernel service • Basic services • task management • intertask communication and synchronization • interrupt management • time management • Additional services • memory management • device management • file management • fault-tolerant features Real-Time Systems (Shin)

  43. Functions of kernel services • task management • create/delete • suspend/resume • update of priority, preemptibility, etc. • inquiry of task state, priority, etc. • intertask communication and synchronization • semaphore: wait/signal • mailbox: send/receive • queue: enqueue/dequeue • event flag: pend/post Real-Time Systems (Shin)

  44. (continued) • memory management • dynamic memory allocation • memory locking • device management • standard character I/O service • device drivers • fault-tolerant functions • hardware fault management routines • exception processing Real-Time Systems (Shin)

  45. Languages - Fortran - C - Pascal - Ada TCP/IP FDDI Process I/O Interfaces - VME - Futurebus+ Networking and communi- cations NFS Real-time OS - Real-time UNIX Hardware architecture - multiprocessors - microprocessors - ASICs and VLSI Application generators CASE tools Databases Man-machine interface and graphics - X Window system - MOTIF Model of an open system for real-time applications Real-Time Systems (Shin)

  46. Development environment Real-time application programs Design environment Execution environment Real-time systems software - A perspective Real-Time Systems (Shin)

  47. Scheduler and schedules • terminology • scheduler: assigns processors to tasks • schedule: an assignment of all the tasks in the system on the available processors • valid schedule • Every processor is assigned to at most one task at any time. • Every task is assigned at most one processor at any time • No task is scheduled before its release time • The total amount of processor time assigned to each task is equal to its maximum or actual execution time. • All the precedence and resource usage constraints are satisfied. Real-Time Systems (Shin)

  48. Scheduler and schedules (cont’d) • feasible schedule • definition: a valid schedule by which every task completes by its deadline • a set of tasks is schedulable according to a scheduling algorithm if the scheduler always produces a feasible schedule • a hard real-time scheduling algorithm is optimal if the algorithm always produces a feasible schedule for a given set of tasks Real-Time Systems (Shin)

More Related