
Efficient and Predictable Thread Synchronization Mechanisms for Mixed-Criticality Systems on Shared-Memory Multi-Processor Platforms by Alexander Züpke Approved Dissertation thesis for the partial fulfillment of the requirements for a Doctor of Natural Sciences (Dr. rer. nat.) Fachbereich 4: Informatik Universität Koblenz-Landau Chair of PhD Board: Prof. Dr. Ralf Lämmel Chair of PhD Commission: Prof. Dr.-Ing. Dietrich Paulus Examiner and Supervisor: Prof. Dr. Dieter Zöbel Further Examiners: Prof. Dr. Robert Kaiser, Prof. Dr.-Ing. Daniel Lohmann Date of the doctoral viva: December 18, 2020. Abstract Real-time operating systems for mixed-criticality systems must support different types of software, such as real-time applications and general purpose applications, and, at the same time, must provide strong spatial and temporal isolation between independent software components. Therefore, state-of-the-art real-time operating systems focus mainly on predictability and bounded worst-case behavior. However, general purpose operating systems such as Linux often feature more efficient—but less deterministic—mechanisms that significantly improve the average execution time. This thesis addresses the combination of the two contradicting requirements and shows thread synchronization mechanisms with efficient average-case behavior, but without sacrificing predictability and worst-case behavior. This thesis explores and evaluates the design space of fast paths in the im- plementation of typical blocking synchronization mechanisms, such as mutexes, condition variables, counting semaphores, barriers, or message queues. The key technique here is to avoid unnecessary system calls, as system calls have high costs compared to other processor operations available in user space, such as low-level atomic synchronization primitives. In particular, the thesis explores futexes, the state-of-the-art design for blocking synchronization mechanisms in Linux that handles the uncontended case of thread synchronization by using atomic operations in user space and calls into the kernel only to suspend and wake up threads. The thesis also proposes non-preemptive busy-waiting monitors that use an efficient priority ceiling mechanism to prevent the lock holder preemption problem without using system calls, and according low-level kernel primitives to construct efficient wait and notify operations. The evaluation shows that the presented approaches improve the average performance comparable to state-of-the-art approaches in Linux. At the same time, a worst-case timing analysis shows that the approaches only need constant or bounded temporal overheads at the operating system kernel level. Exploiting these fast paths is a worthwhile approach when designing systems that not only have to fulfill real-time requirements, but also best-effort workloads. i Zusammenfassung Echzeitbetriebssysteme für Systeme mit gemischten Kritikalitäten müssen unter- schiedliche Arten von Software, wie z.B. Echtzeitanwendungen und Allzweckan- wendungen, gleichzeitig unterstützen. Dabei müssen sie eine solide räumliche und zeitliche Isolation zwischen unabhängigen Softwarekomponenten bieten. Daher fokussieren sich aktuelle Echtzeitbetriebssysteme hauptsächlich auf Vorhersag- barkeit und ein berechenbares Worst-Case-Verhalten. Allerdings bieten Allzweck- Betriebssysteme wie Linux häufig effizientere, aber weniger deterministische Me- chanismen, welche die durchschnittliche Ausführungszeit signifikant erhöhen. Diese Thesis befasst sich mit der Kombination der beiden gegensätzlichen Anforderungen und zeigt Mechanismen zur Thread-Synchronisation mit einem effizienten Durch- schnittsverhalten, ohne jedoch die Vorhersagbarkeit und das Worst-Case-Verhalten zu beeinträchtigen. Diese Thesis untersucht und bewertet den Entwurfsraum von Abkürzungen (engl. fast paths) bei der Umsetzung von typischen blockierenden Synchronisati- onsmechanismen wie Mutexen, Bedingungsvariablen, Zähl-Semaphoren, Barrieren oder Nachrichtenwarteschlangen. Der Ansatz ist dabei, unnötige Systemaufrufe zu vermeiden. Systemaufrufe haben im Vergleich zu anderen Prozessoroperationen, die im Benutzermodus verfügbar sind, wie z.B. atomaren Operationen, höhere Kosten. Insbesondere erforscht die Thesis Futexe, ein aktuelles Design für blockie- rende Synchronisationsmechanismen in Linux, welches den konkurrenzfreien Fall der Synchronisierung mithilfe atomarer Operationen im Benutzermodus löst und den Kern nur aufruft, um Threads zu suspendieren und aufzuwecken. Die Thesis untersucht auch nicht-unterbrechbare Monitore mit aktivem Warten. Dort wird ein effizienter Mechanismus mit Prioritätsschranken verwendet, um das sogenannte Lock-Holder-Preemption-Problem ohne Systemaufrufe zu vermeiden. Ebenfalls werden passende niedere Kernprimitive beschrieben, die effiziente Warte- und Benachrichtigungsoperationen ermöglichen. Die Evaluation zeigt, dass die vorgestellten Ansätze die durchschnittliche Leistung vergleichbar zu aktuellen Ansätzen in Linux verbessern. Gleichzeitig zeigt eine Analyse des Worst-Case-Zeitverhaltens, dass die Ansätze nur konstante oder begrenzte zeitliche Mehraufwände auf der Ebene des Betriebssystemkerns benötigen. Die Nutzung dieser Abkürzungen ist ein lohnender Ansatz für den Entwurf von Systemen, die nicht nur Echtzeitanforderungen erfüllen, sondern auch Allzweckanwendungen gut unterstützen sollen. ii CONTENTS Contents 1 Introduction 1 1.1 Efficient Synchronization Mechanisms . 2 1.2 Predictability and Determinism . 3 1.3 Contributions . 3 1.4 Organization . 5 2 Basics 7 2.1 Basic Concepts and Terminology . 7 2.1.1 Operating System Concepts . 7 2.1.2 Shared Resources and Critical Sections . 9 2.1.3 The Lock Holder Preemption Problem . 10 2.1.4 Real-Time Scheduling . 11 2.1.5 Real-Time Locking Protocols . 13 2.1.6 WCET Analysis Methods . 19 2.1.7 Operating System Architectural Concepts . 20 2.1.8 Processor Architecture . 26 2.1.9 Predictability Issues on Multicore Processors . 28 2.2 User-Level Synchronization Mechanisms . 28 2.2.1 Spinlocks . 30 2.2.2 Mutexes . 31 2.2.3 Condition Variables . 32 2.2.4 Reader-Writer Locks . 33 2.2.5 Counting Semaphores . 34 2.2.6 Barriers . 35 2.2.7 One-Time Initializers . 35 2.2.8 Queuing Ports and Buffers . 36 2.2.9 Sampling Ports and Blackboards . 36 2.2.10 Events . 37 2.2.11 Futexes . 39 2.2.12 Adaptive Mechanisms . 40 2.2.13 Waiting With Timeouts . 41 2.3 Synchronization Inside an Operating System Kernel . 42 2.3.1 Level of Indirection . 42 2.3.2 Queuing . 42 2.3.3 Locking and Preemption Control . 43 2.3.4 Waiting and Wake-up . 44 3 Analysis 45 3.1 Related Work . 46 3.1.1 Futexes and Fast Synchronization Mechanisms . 46 iii CONTENTS 3.1.2 Lazy Techniques and Optimization . 47 3.2 Settings and Requirements . 48 3.2.1 System Model . 48 3.2.2 Relative Costs of CPU Instructions . 50 3.2.3 Requirements for Predictability . 51 3.2.4 Metrics to Evaluate Efficiency and Predictability . 54 3.3 Building Blocks of Real-Time Locking Protocols . 55 3.4 Building Blocks of User-Level Blocking Synchronization . 57 3.4.1 High-Level Analysis and Generalization . 58 3.4.2 Mapping to Low-Level Building Blocks in the Kernel . 62 3.5 Futexes in Linux Revisited . 67 3.5.1 Conceptual OS Implementation of Futexes . 67 3.5.2 Linux Futex Implementation . 69 3.5.3 Issues with Futexes in Linux . 72 3.5.4 Safety and Security Aspects of Futexes . 76 3.5.5 Summary . 77 3.6 Alternative Approaches for Efficient Synchronization Mechanisms 77 3.7 Preemption Control Mechanisms . 81 3.7.1 Related Work on Lock Holder Preemption . 81 3.7.2 Preemption Control inside OS Kernels . 83 3.7.3 Building Blocks of Preemption Control Mechanisms . 84 3.7.4 Temporary Non-Preemption in Symunix II . 85 3.7.5 Fast IPCP Implementation by Almatary et al. 87 3.7.6 Discussion . 90 3.8 Low-Level Wait and Wake-up Mechanisms . 90 3.9 Analysis Summary . 93 4 Design 96 4.1 Deterministic Futexes . 96 4.1.1 Design Considerations . 97 4.1.2 Binary Search Trees . 99 4.1.3 Address Tree Management . 99 4.1.4 Wait Queue Management . 101 4.1.5 Preemptible Operation . 102 4.1.6 Interference of Shared Futexes . 103 4.1.7 Summary . 104 4.2 Static Futexes . 104 4.2.1 Design Considerations . 104 4.2.2 Futex Operations for ARINC 653 in AUTOBEST . 106 4.3 Higher-Level Synchronization Mechanisms based on Futexes . 107 4.3.1 Blocking Mutexes . 108 4.3.2 Condition Variables . 109 4.3.3 Counting Semaphores . 112 iv CONTENTS 4.3.4 Barriers . 113 4.3.5 One-time initializers . 114 4.3.6 ARINC 653 Synchronization Mechanisms . 115 4.4 Non-Preemptive Busy-Waiting Monitors . 117 4.4.1 Efficient IPCP Protocols . 117 4.4.2 Light-Weight Blocking for IPCP . 121 4.4.3 Monitor Synthesis . 126 4.5 Higher-Level Synchronization Mechanisms based on Monitors . 128 4.5.1 Data Model of Monitor-Based Synchronization Mechanisms 128 4.5.2 Blocking Mutexes . 129 4.5.3 Condition Variables for Blocking Mutexes . 130 4.5.4 Low-Level Monitor API . 131 5 Evaluation 134 5.1 Validating Assumptions . 135 5.2 Performance Measurements . 137 5.2.1 Specifics of Deterministic Futexes . 138 5.2.2 IPCP Performance . 141 5.2.3 Comparison for Different Mutex Implementations . 142 5.3 Analysis of Worst-Case Timing Behavior . 146 5.3.1 Reference Architecture for Analysis . 147 5.3.2 Analysis of Kernel Primitives . 149 5.3.3 Analysis of Mutexes and Condition Variables . 158 5.4 Evaluation Summary . 165 6 Discussion 169 6.1 Design Space Exploration . 169 6.2 Futexes . 172 6.2.1 Deterministic Futexes . 172 6.2.2 Static Futexes . 175 6.2.3 Practicality of Futexes . 176 6.3 Monitors . 179 6.3.1 Efficient IPCP Protocols . 179 6.3.2 Light-Weight
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages216 Page
-
File Size-