QNX® Neutrino® RTOS System Architecture For release 6.4.0 © 2008, QNX Software Systems GmbH & Co. KG. © 1996–2008, QNX Software Systems GmbH & Co. KG. All rights reserved. Published under license by: QNX Software Systems International Corporation 175 Terence Matthews Crescent Kanata, Ontario K2M 1W8 Canada Voice: +1 613 591-0931 Fax: +1 613 591-3579 Email: [email protected] Web: http://www.qnx.com/ Electronic edition published 2008 QNX, Neutrino, Photon, Photon microGUI, Momentics, and Aviage are trademarks, registered in certain jurisdictions, of QNX Software Systems GmbH & Co. KG. and are used under license by QNX Software Systems International Corporation. All other trademarks belong to their respective owners. Contents About This Guide xiii What you’ll find in this guide xv Typographical conventions xvi Note to Windows users xvii Technical support xvii 1 The Philosophy of QNX Neutrino 1 Design goals 3 An embeddable POSIX OS? 3 Product scaling 3 Why POSIX for embedded systems? 4 Why QNX Neutrino for embedded systems? 5 Microkernel architecture 6 The OS as a team of processes 8 A true kernel 8 System processes 9 Interprocess communication 10 QNX Neutrino as a message-passing operating system 10 Network distribution of kernels 11 Single-computer model 11 Flexible networking 11 2 The QNX Neutrino Microkernel 13 Introduction 15 The implementation of QNX Neutrino 16 POSIX realtime and thread extensions 16 System services 16 Threads and processes 17 Thread attributes 20 Thread scheduling 24 When are scheduling decisions are made? 24 Scheduling priority 24 Scheduling algorithms 26 October 16, 2008 Contents iii © 2008, QNX Software Systems GmbH & Co. KG. IPC issues 31 Thread complexity issues 31 Synchronization services 32 Mutexes: mutual exclusion locks 33 Condvars: condition variables 34 Barriers 35 Sleepon locks 38 Reader/writer locks 38 Semaphores 38 Synchronization via scheduling algorithm 39 Synchronization via message passing 40 Synchronization via atomic operations 40 Synchronization services implementation 40 Clock and timer services 41 Time correction 42 Timers 42 Interrupt handling 44 Interrupt latency 45 Scheduling latency 45 Nested interrupts 46 Interrupt calls 47 3 Interprocess Communication (IPC) 51 Synchronous message passing 53 MsgReply() vs MsgError() 56 Message copying 56 Simple messages 58 Channels and connections 59 Pulses 61 Priority inheritance and messages 61 Message-passing API 62 Robust implementations with Send/Receive/Reply 62 Events 64 I/O notification 65 Signals 66 Special signals 68 Summary of signals 69 POSIX message queues 70 Why use POSIX message queues? 71 File-like interface 71 Message-queue functions 72 iv Contents October 16, 2008 © 2008, QNX Software Systems GmbH & Co. KG. Shared memory 72 Shared memory with message passing 73 Creating a shared-memory object 74 mmap() 74 Initializing allocated memory 78 Typed memory 78 Implementation-defined behavior 79 Practical examples 83 Pipes and FIFOs 84 Pipes 84 FIFOs 85 4 The Instrumented Microkernel 87 Introduction 89 Instrumentation at a glance 89 Event control 90 Modes of emission 90 Ring buffer 91 Data interpretation 91 System analysis with the IDE 92 Proactive tracing 93 5 Multicore Processing 95 Introduction 97 Asymmetric multiprocessing (AMP) 97 Symmetric multiprocessing (SMP) 98 Neutrino’s microkernel approach 99 Booting an x86 SMP system 100 Booting a PowerPC SMP system 100 How the SMP microkernel works 101 Critical sections 102 Bound multiprocessing (BMP) 103 A viable migration strategy 104 Choosing between AMP, SMP, and BMP 104 6 Process Manager 107 Introduction 109 Process management 109 Process primitives 109 Process loading 114 Memory management 114 October 16, 2008 Contents v © 2008, QNX Software Systems GmbH & Co. KG. Memory Management Units (MMUs) 115 Memory protection at run time 116 Quality control 117 Full-protection model 118 Variable page size 118 Pathname management 119 Domains of authority 119 Resolving pathnames 119 Symbolic prefixes 123 File descriptor namespace 125 7 Dynamic Linking 129 Shared objects 131 Statically linked 131 Dynamically linked 131 Augmenting code at runtime 132 How shared objects are used 132 ELF format 132 ELF without COFF 133 The process 133 Runtime linker 134 Loading a shared library at runtime 135 Symbol name resolution 136 8 Resource Managers 137 Introduction 139 What is a resource manager? 139 Why write a resource manager? 139 The types of resource managers 141 Communication via native IPC 142 Resource manager architecture 143 Message types 143 The resource manager shared library 144 Summary 148 9 Filesystems 149 Introduction 151 Filesystems and pathname resolution 151 Filesystem classes 152 Filesystems as shared libraries 152 io-blk 153 vi Contents October 16, 2008 © 2008, QNX Software Systems GmbH & Co. KG. Filesystem limitations 156 Image filesystem 156 RAM “filesystem” 157 Embedded transaction filesystem (ETFS) 157 Inside a transaction 158 Types of storage media 158 Reliability features 159 QNX 4 filesystem 161 Power-Safe filesystem 161 Problems with existing disk filesystems 161 Copy-on-write filesystem 162 Performance 164 DOS Filesystem 166 CD-ROM filesystem 168 FFS3 filesystem 168 Customization 169 Organization 169 Features 170 Utilities 172 System calls 172 NFS filesystem 172 CIFS filesystem 172 Linux Ext2 filesystem 173 Universal Disk Format (UDF) filesystem 173 Virtual filesystems 173 10 Character I/O 175 Introduction 177 Driver/io-char communication 178 Device control 179 Input modes 180 Device subsystem performance 183 Console devices 183 Terminal emulation 183 Serial devices 183 Parallel devices 184 Pseudo terminal devices (ptys) 184 11 Networking Architecture 187 Introduction 189 Network manager (io-pkt*) 189 October 16, 2008 Contents vii © 2008, QNX Software Systems GmbH & Co. KG. Threading model 191 Protocol module 192 Driver module 193 Loading and unloading a driver 193 12 Native Networking (Qnet) 195 QNX Neutrino distributed 197 Name resolution and lookup 198 File descriptor (connection ID) 199 Behind a simple open() 199 Global Name Service (GNS) 201 Network naming 201 Redundant Qnet: Quality of Service (QoS) and multiple paths 202 QoS policies 202 Specifying QoS policies 205 Symbolic links 205 Examples 206 Local networks 206 Remote networks 206 Custom device drivers 207 13 TCP/IP Networking 209 Introduction 211 Stack configurations 211 Structure of the TCP/IP manager 212 Socket API 212 Database routines 213 Multiple stacks 214 IP filtering and NAT 214 NTP 214 Dynamic host configuration 215 AutoIP 215 PPP over Ethernet 215 /etc/autoconnect 216 Embedded web server 216 CGI method 216 SSI method 217 14 High Availability 219 What is High Availability? 221 An OS for HA 221 viii Contents October 16, 2008 © 2008, QNX Software Systems GmbH & Co. KG. Custom hardware support 222 Client library 222 Recovery example 223 High Availability Manager 224 HAM and the Guardian 225 HAM hierarchy 225 Publishing autonomously detected conditions 229 Subscribing to autonomously published conditions 229 HAM as a “filesystem” 230 Multistage recovery 230 HAM API 231 15 Adaptive Partitioning 235 What are partitions? 237 Because adaptive partitions are not “boxes” what are they? 238 Why adaptive? 238 Benefits of adaptive partitioning 239 Engineering product performance 239 Dealing with design complexity 240 Providing security 241 Debugging 242 Adaptive partitioning thread scheduler 242 16 The Photon microGUI 245 A graphical microkernel 247 The Photon event space 248 Regions 249 Events 250 Graphics drivers 251 Multiple graphics drivers 252 Color model 252 Font support 253 Stroke-based fonts 253 Unicode multilingual support 253 UTF-8 encoding 253 Animation support 254 Printing support 254 The Photon Window Manager 255 Widget library 255 Fundamental widgets 256 Container widgets 258 October 16, 2008 Contents ix © 2008, QNX Software Systems GmbH & Co. KG. Advanced widgets 260 Convenience functions 265 Driver development kits 267 Summary 268 17 Multimedia 269 Overview 271 MME functional areas 272 The MME interface 273 Component-based architecture 274 The MME resource managers 274 Glossary 277 Index 295 x Contents October 16, 2008 List of Figures Conventional executives offer no memory protection. 7 In a monolithic OS, system processes have no protection. 7 A microkernel provides complete memory protection. 7 The QNX Neutrino architecture. 8 The QNX Neutrino microkernel. 15 QNX Neutrino preemption details. 17 Sparse matrix (tid,key) to value mapping. 21 Possible thread states. 22 The ready queue. 25 Thread A blocks; Thread B runs. 26 FIFO scheduling. 27 Round-robin scheduling. 27 A thread’s budget is replenished periodically. 29 A thread drops in priority until its budget is replenished. 29 A thread oscillates between high and low priority. 30 Interrupt handler simply terminates. 45 Interrupt handler terminates, returning an event. 46 Stacked interrupts. 47 Changes of state for a client thread in a send-receive-reply transaction. 54 Changes of state for a server thread in a send-receive-reply transaction. 55 A multipart transfer. 56 Scatter/gather of a read of 1454 bytes. 57 Connections map elegantly into file descriptors. 60 Pulses pack a small payload. 61 Threads should always send up to higher-level threads. 63 A higher-level thread can “send” a pulse event. 64 The client sends a sigevent to the server. 65 Signal delivery. 67 Arguments to mmap().75 Instrumentation at a glance. 90 The IDE helps you visualize system activity. 93 Virtual address mapping (on an x86). 115 Full protection VM (on an x86). 118 The SCOID and FD map to an OCB of an I/O Manager. 126 October 16, 2008 List of Figures xi © 2008, QNX Software Systems GmbH & Co. KG. Two processes open the same file. 127 A process opens a file twice. 128 Object file format: linking view and execution view. 133 Process memory layout on an x86. 134 A resource manager is responsible for three data structures. 146 Multiple clients opening various devices. 147 Encapsulation. 148 QNX Neutrino filesystem layering. 153 ETFS is a filesystem composed entirely of transactions. 158 The io-char module is implemented as a library. 177 Device I/O in QNX Neutrino.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages325 Page
-
File Size-