summaryrefslogtreecommitdiff
path: root/realtime/rt-basics/pres_rt-app-agl_en.tex
blob: 2fc5d681e0de5df74260af20cf15dd7601f8418a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
\input{configpres}
\date{18 October 2018}

\title{Building Real-Time Applications for Linux}
\maketitle

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}
\frametitle{What is real-time?}
\begin{itemize}
\item correctness also means executing at the correct time
\item failing to meet timing restrictions leads to an error
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{A Visual Aid}
\begin{overprint}
\onslide<1>
\begin{alertblock}{Remember...}
\bigskip
Failing to meet timing restrictions leads to an error!
\end{alertblock}
\onslide<2|handout:0>
\begin{figure}[h]
\centering
\includegraphics[height=0.5\textwidth]{images/nuclear.png}
\end{figure}
\end{overprint}
\end{frame}

\begin{frame}
\frametitle{Requirements}
\begin{itemize}
\item deterministic time behavior
\item interruptible
\item avoid priority inversion \\ (priority inheritance / priority ceiling)
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Priority Inversion}
\begin{figure}[h]
\centering
\includegraphics[width=0.8\textwidth]{images/prio_inv.png}
\end{figure}
Task 3 is holding a lock that Task 1 wants. But Task 3 never has a chance
to release the lock because Task 2 is running unbounded.
\end{frame}

\section{Evaluating a Real-Time Linux System}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}
\frametitle{Testing Preempt RT Systems}
RT Tests:
\bigskip
\begin{itemize}
\item cyclictest
\item hwlatdetect
\item pi\_stress
\item signaltest
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{cyclictest}
\bigskip
\begin{itemize}
\item originally developed by Thomas Gleixner for Preempt RT testing
\item high resolution timer test software
\item creates any number of cyclic real-time tasks with varying priorities and varying intervals
\item provides lots of debugging possibilities
\item yields very significant results to determine the real-time behavior of a platform
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Load Scenarios}
Suitable load scenarios in order to create worst-case situations:
\bigskip
\begin{itemize}
\item CPU Load: ''hackbench'', orginally written for scheduler benchmarking
\item Interrupt Load: flood pinging (''ping -f'')
\item Serial/Network Load: ''top -d 0'' via console and network shell
\item Various Load Scenarios: ''stress-ng''
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{hackbench}
\begin{figure}[h]
\centering
\includegraphics[height=3.5cm]{images/hackbench.png}
\label{img:hackbench}
\end{figure}
\begin{itemize}
\item starts groups, each with 20 clients and 20 servers
\item every client sends 100 messages via socket to every server
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Pitfall!}
\begin{verbatim}
cat /proc/sys/kernel/sched_rt_runtime_us
\end{verbatim}
\begin{figure}
\centering
\includegraphics[height=0.4\textwidth]{images/pitfall.png}
\end{figure}
\end{frame}

\section{Application Development}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}
\frametitle{Real-Time Development with Preempt RT}
\begin{figure}
\includegraphics[height=0.4\textwidth]{images/thumb.png}
\end{figure}
POSIX!
\end{frame}

\subsubsection{Priorities}

\begin{frame}
\frametitle{Real-Time Scheduling Policies}
\begin{itemize}
\item SCHED\_FIFO: static priority
\item SCHED\_RR: priority based, round robin scheduling per priority
\item SCHED\_DEADLINE: dynamic priority based upon deadlines
\end{itemize}
\bigbreak
SCHED\_FIFO and SCHED\_RR scheduling policies accept priorities from 1 to 99, where 99
is the highest priority. (But never use 99! It is for special critical kernel tasks!)
\bigbreak
The SCHED\_DEADLINE policy calculates priorities dynamically.
\end{frame}

\begin{frame}[fragile]
\frametitle{Setting the Scheduling Policy}
The scheduling policy can be set using the ''chrt'' command:
\bigskip
\begin{verbatim}
Set policy:
  chrt [opts] <policy> <prio> <pid>
  chrt [opts] <policy> <prio> <cmd> [<arg> ...]

Scheduling policies:
-d, --deadline  set policy to SCHED_DEADLINE
-f, --fifo      set policy to SCHED_FIFO
-r, --rr        set policy to SCHED_RR (default)
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Setting the Scheduling Policy}
...or in code:
\bigskip
\begin{verbatim}
#include <stdio.h>
#include <sched.h>

struct sched_param param;

param.sched_priority = 80;

if (sched_setscheduler(0, SCHED_FIFO, &param) == -1) {
    perror("sched_setscheduler() failed)";
    exit(1);
}
\end{verbatim}
\end{frame}

\subsubsection{CPU Affinity}

\begin{frame}[fragile]
\frametitle{Setting the CPU Affinity}
The CPU affinity can be set using the ''taskset'' command:
\bigbreak
\begin{verbatim}
taskset [options] mask command [arg]...
taskset [options] -p [mask] pid
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Setting the CPU Affinity}
...or in code:
\bigskip
\begin{verbatim}
#define _GNU_SOURCE
#include <stdio.h>
#include <sched.h>

cpu_set_t set;

CPU_ZERO(&set);
CPU_SET(0, &set);
CPU_SET(1, &set);

if (sched_setaffinity(pid, CPU_SETSIZE, &set) == -1) {
    perror("sched_setaffinity() failed");
    exit(1);
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{CPU Affinity on Boot}
Kernel Parameters:
\bigbreak
\begin{itemize}
\item maxcpus=\textit{n}: limits the kernel to bring up \textit{n} processors
\item isolcpus=\textit{cpulist}: specify CPUs to isolate from disturbances
\item threadirqs: force threading of interrupt handlers
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Interrupt Routing}
\begin{verbatim}
$ ls /proc/irq/
0  1  10  11  12  13  14  15  17  18  19 ... default_smp_affinity

$ cat /proc/irq/default_smp_affinity
3
\end{verbatim}
Set default IRQ affinity to CPU0
\begin{verbatim}
echo 1 > /proc/irq/default_smp_affinity
\end{verbatim}
Set affinity for IRQ19 to CPU1
\begin{verbatim}
echo 2 > /proc/irq/19/smp_affinity
\end{verbatim}
\end{frame}

\subsubsection{Memory Management}

\begin{frame}
\frametitle{Memory Over-Committing}
Comparable to those low-cost airlines ;)
\pause
\bigbreak
\begin{itemize}
\item ...selling more tickets than available seats
\item ...hoping not everyone will come ;)
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Memory Over-Commit Settings}
\begin{verbatim}
/proc/sys/vm/overcommit_memory
\end{verbatim}
\bigbreak
Possible settings are:
\begin{itemize}
\item 0: heuristic overcommit handling (default)
\item 1: always overcommit
\item 2: do not overcommit
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Virtual Address Memory Mapping}
By default, physical memory pages are mapped to the virtual
address space \emph{on-demand}. This is how over-commitment works
and it affects \emph{all} virtual memory of a process:
\bigbreak
\begin{itemize}
\item text segment
\item initialized data segment
\item uninitialized data segment
\item stack(s)
\item heap
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Locking The Memory}
\begin{verbatim}
#include <stdio.h>
#include <sys/mman.h>

if (mlockall(MCL_CURRENT | MCL_FUTURE) == -1) {
    perror("mlockall() failed");
    exit(1);
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Stack Prefaulting}
\begin{verbatim}
#include <unistd.h>

#define MAX_SAFE_STACK (512 * 1024)

void prefault_stack(void)
{
    unsigned char dummy[MAX_SAFE_STACK];
    int i;

    for (i = 0; i < MAX_SAFE_STACK; i += sysconf(_SC_PAGESIZE))
        dummy[i] = i;
}
\end{verbatim}
\end{frame}

\begin{frame}
\frametitle{Dynamic Allocations from Real-Time Context}
\bigbreak
\begin{itemize}
\item if possible, avoid memory allocations from real-time context
\item try to use a pre-allocated buffer instead
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Disable malloc() Trimming and mmap() Usage}
\begin{verbatim}
#include <stdio.h>
#include <malloc.h>

if (!mallopt(M_TRIM_THRESHOLD, -1)) {
    perror("mallopt(M_TRIM_THRESHOLD) failed");
    exit(1);
}

if (!mallopt(M_MMAP_MAX, 0)) {
    perror("mallopt(M_MMAP_MAX) failed");
    exit(1);
}
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{Heap Prefaulting}
\begin{verbatim}
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

void prefault_heap(int size)
{
    char *dummy;
    int i;

    dummy = malloc(size);
    if (!dummy) {
        perror("malloc() failed");
        exit(1);
    }

    for (i = 0; i < size; i += sysconf(_SC_PAGESIZE))
        dummy[i] = i;

    free(dummy);
}
\end{verbatim}
\end{frame}

\subsubsection{Clocks}

\begin{frame}
\frametitle{Time and Sleeping}
Functions:
\begin{itemize}
\item Use POSIX!
\item clock\_getres()
\item clock\_gettime()
\item clock\_settime()
\item clock\_nanosleep()
\end{itemize}
\bigbreak
Clocks:
\begin{itemize}
\item CLOCK\_MONOTONIC: A clock that cannot be set and represents monotonic time
since some unspecified starting point.
\item CLOCK\_REALTIME: System-wide real time clock. Can be set (by NTP, user, ...)!
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Cyclic Tasks}
\begin{itemize}
\item Use clock\_nanosleep()!
\item Do not use signals!
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Cyclic Example}
\begin{verbatim}
#define CYCLE_TIME_NS (100 * 1000 * 1000) 
#define NSEC_PER_SEC (1000 * 1000 * 1000)

static void norm_ts(struct timespec *tv)
{
    while (tv->tv_nsec > NSEC_PER_SEC) {
        tv->tv_sec++;
        tv->tv_nsec -= NSEC_PER_SEC;
    }
}

int main(void)
{
    struct timespec tv;

    clock_gettime(CLOCK_MONOTONIC, &tv);
    do {
        /* do the work */

        /* wait for next cycle */
        tv.tv_nsec += CYCLE_TIME_NS;
        norm_ts(&tv);
        clock_nanosleep(CLOCK_MONOTONIC, TIMER_ABSTIME, &tv, NULL);
    } while(1);
}
\end{verbatim}
\end{frame}

\subsubsection{Locking}

\begin{frame}
\frametitle{Synchronization}
\begin{itemize}
\item use pthread\_mutexes
\item activate priority inheritance
\item activate shared and robustness (if multi-process access)
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Locking Example}
\begin{verbatim}
pthread_mutex_t master_lock;
pthread_mutexattr_t mattr;

pthread_mutexattr_init(&mattr);
pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
pthread_mutex_init(&master_lock, &mattr);

pthread_mutex_lock(&master_lock);
/* do critical work */
pthread_mutex_unlock(&master_lock);

pthread_mutex_destroy(&master_lock);
\end{verbatim}
\end{frame}

\subsubsection{Signalling}

\begin{frame}
\frametitle{Signalling Mechanisms}
\begin{itemize}
\item Do not use signals!
\item Use pthread\_cond\_vars.
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{pthread\_cond\_var: Initialization}
\begin{verbatim}
pthread_mutexattr_t mattr;
pthread_mutex_t mutex;

pthread_condattr_t cattr;
pthread_cond_t cond;

pthread_mutexattr_init(&mattr);
pthread_mutexattr_setprotocol(&mattr, PTHREAD_PRIO_INHERIT);
pthread_mutex_init(&mutex, &mattr);

pthread_condattr_init(&cattr);
pthread_cond_init (&cond, &cattr);
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{pthread\_cond\_var: Send Signal}
Sender:
\begin{verbatim}
pthread_mutex_lock(&mutex);
/* do the work */
pthread_cond_broadcast(&cond);
pthread_mutex_unlock(&mutex);
\end{verbatim}
\bigbreak
Receiver:
\begin{verbatim}
pthread_mutex_lock(&mutex);
pthread_cond_wait(&cond, &mutex);
/* we have been signaled */
pthread_mutex_unlock(&mutex);
\end{verbatim}
\end{frame}

\section{Debugging and Verifying Applications}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Tracing: Overview}
\begin{itemize}
\item debugfs interface
\item static and dynamic trace events
\item various heuristics (tracers): function, function\_graph, wakeup, wakeup\_rt, \dots
\item custom trace events
\item graphical frontend (kernelshark)
\end{itemize}
\end{frame}

\begin{frame}[fragile]
\frametitle{Kernel Tracing: Overview}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/trace_overview.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{Kernelshark}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/kernelshark.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{Kernelshark}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/kernelshark_zoom.png}
\end{figure}
\end{frame}

\begin{frame}[fragile]
\frametitle{Wakeup Example}
\begin{verbatim}
$ sudo trace-cmd record -e irq_vectors:local_timer_entry \
                        -e sched:sched_wakeup \
                        -e sched:sched_switch \
                        -e syscalls:sys_exit_nanosleep \
                        chrt -f 98 /bin/sleep 1
$ kernelshark
\end{verbatim}
\bigbreak
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/kernelshark_sleep.png}
\end{figure}
\end{frame}

\begin{frame}[fragile]
\frametitle{IPC Signaling Example (with Priority Inheritance)}
Set custom events ''sending'' and ''received'' in userspace application.
\begin{verbatim}
$ sudo perf probe -x ./send sending=send.c:35
$ sudo perf probe -x ./recv received=recv.c:43
\end{verbatim}
Pin sender (real-time priority 80) and receiver (real-time priority 70)
to the same CPU to force priority inheritance.
\begin{verbatim}
$ sudo taskset 1 chrt -f 80 ./recv &
$ sudo trace-cmd record -e sched:sched_switch \
                        -e sched:sched_wakeup \
                        -e sched:sched_pi_setprio \
                        -e probe_send:sending \
                        -e probe_recv:received \
                        -e syscalls \
                        taskset 1 chrt -f 70 ./send
\end{verbatim}
\end{frame}

\begin{frame}[fragile]
\frametitle{IPC Signaling Example (with Priority Inheritance)}
\begin{verbatim}
$ kernelshark
\end{verbatim}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/kernelshark_ipcshm1.png}
\end{figure}
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/kernelshark_ipcshm2.png}
\end{figure}
\end{frame}

\section{Real-Time in the Kernel}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}
\frametitle{General Purpose vs. Real-Time}
\begin{figure}[h]
\centering
\includegraphics[height=0.5\textwidth]{images/gpos_vs_rt.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{Single Kernel}
\begin{figure}[h]
\centering
\includegraphics[height=0.5\textwidth]{images/single_kernel.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT: Real-Time for Linux}
\begin{itemize}
\item Thomas Gleixner, Ingo Molnar
\item in-kernel approach
\item large development community
\item many features already integrated in ''mainline'' Linux
\item POSIX real-time
\item highly accepted, agreement in 2006 for complete Linux integration
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Goals of Preempt RT}
\begin{itemize}
\item full Linux kernel hardware support
\item standard API (POSIX)
\item no special user ABI
\item full availability using existing tools
\item scalable!
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Influence of Preempt RT on ''Mainline'' Linux}
\begin{itemize}
\item generic interrupt subsystem
\item generic timekeeping
\item generic timer handling
\item high resolution timers
\item the NOHZ infrastructure
\item consolidation of the locking infrastructure
\item tracing!
\item ... and much more
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{Preempt RT and Mainline}
\textit{''Controlling a laser with Linux is crazy, but everyone in this room is
crazy in his own way. So if you want to use Linux to control an industrial
welding laser, I have no problem with your using Preempt RT''} \\ - Linus Torvalds
at the Kernel Summit 2006
\end{frame}

\begin{frame}
\frametitle{How does Preempt RT make Linux real-time capable?}
\begin{overprint}
\onslide<1|handout:0>
\begin{alertblock}{Remember...}
\bigskip
Interruptibility is a main requirement of a real-time system.
\end{alertblock}
\onslide<2>
\begin{itemize}
\item Locking primitives: Spinlocks are replaced with RT mutexes that can sleep. Raw spinlocks are introduced to provide the classic spinlock functionality.
\item Interrupt handlers run by default each as its own kernel thread.
\end{itemize}
\end{overprint}
\end{frame}

\begin{frame}
\frametitle{Preempt RT}
\begin{figure}[h]
\centering
\includegraphics[height=0.5\textwidth]{images/RT_preempt_kernel_approach.jpg}
\end{figure}
\end{frame}

\section{Results: What is possible using this approach?}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}
\frametitle{Measurements on the Cortex A9 Platform}
\begin{itemize}
\item ARM Cortex A9 SOC
\item Load Scenario: 100\% CPU Load using ''hackbench''
\item IRQ measurements at 10 kHz with the OSADL Latency Box
\item Test Duration: 12h
\end{itemize}
\end{frame}

\begin{frame}
\frametitle{What was measured?}
Latency and Jitter
\begin{figure}[h]
\centering
\includegraphics[width=10cm]{images/latency.png}
\end{figure}
\end{frame}

\begin{frame}
\frametitle{Latency Userspace Task: Most Important Use Case}
The most important index is the reaction time for a userspace application.
It is quite common that an application is required to react from an
external event!
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT Latency Userspace Task}
\includegraphics[width=8cm]{images/10k-rt-usr-noisol.png}
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT Latency Userspace Task (isolated CPU)}
\includegraphics[width=8cm]{images/10k-rt-usr-isol.png}
\end{frame}

\begin{frame}
\frametitle{Latency in the Kernel}
...or how to compare apples and oranges!! ;-)
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT Latency Kernel}
\includegraphics[width=8cm]{images/10k-rt-irq-noisol.png}
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT Latency Kernel (isolated CPU)}
\includegraphics[width=8cm]{images/10k-rt-irq-isol.png}
\end{frame}

\begin{frame}
\frametitle{PREEMPT\_RT Latency Kernel (FIQ / fast interrupt)}
\includegraphics[width=8cm]{images/10k-fiq-irq-noisol.png}
\end{frame}

\section{Checklist for Real-Time Applications}

\begin{frame}
\tableofcontents[currentsection]
\end{frame}

\begin{frame}[fragile]
\frametitle{Checklist}
\begin{columns}[T]
\begin{column}{5cm}
{Real-Time Priority
\begin{itemize}
\item SCHED\_FIFO, SCHED\_RR
\end{itemize}
\medbreak
CPU Affinity
\begin{itemize}
\item applications
\item interrupt handlers
\item interrupt routing
\end{itemize}
\medbreak
Memory Management
\begin{itemize}
\item avoid mmap() with malloc()
\item lock memory
\item prefault memory
\end{itemize}
\medbreak
Time and Sleeping
\begin{itemize}
\item use monotonic clock
\item use absolute time
\end{itemize}
}
\end{column}
\begin{column}{5cm}
{Avoid Signals
\begin{itemize}
\item such as POSIX timers
\item such as kill()
\end{itemize}
\medbreak
Avoid Priority Inversion
\begin{itemize}
\item use pthread\_mutex \\ (and set attributes!)
\item use pthread\_condvar \\ (and set attributes!)
\end{itemize}
\medbreak
Be aware of NMIs
\bigbreak
Verify Results
\begin{itemize}
\item trace scheduling
\item trace page faults
\item monitor traces
\end{itemize}
}
\end{column}
\end{columns}
\end{frame}

\input{tailpres}