Light-Weighted Virtualization Layer for Multicore Processor-Based Embedded Systems
Total Page:16
File Type:pdf, Size:1020Kb
Light-Weighted Virtualization Layer for Multicore Processor-Based Embedded Systems Hitoshi Mitake, Hiromasa Shimada, Tsung-Han Lin, Ning Li, Yuki Kinebuchi, Chen-Yi Lee, Daisuke Yamaguchi, Takumi Yajima, Tatsuo Nakajima Department of Computer Science and Engineering Waseda University fmitake,h-shimada,johnny,lining,yukikine,victor,no-trick-in-go,takumi- yajima,[email protected] Abstract or TOPPERS1, are designed and developed for executing real-time The real-time resource management in the Linux kernel is dra- tasks such as processing wireless communication protocols. In a matically improving due to the effective contribution of the real- typical case, these tasks run periodically for short time. The feature time Linux community. However, reusing existing real-time appli- of executing such deadline sensitive tasks relies on the limitation cations in embedded systems is required to develop commercial to RTOSes. For example, most RTOSes cannot change the number products without significantly increasing their cost because exist- of tasks dynamically. On the other hand, GPOSes, like Linux, are ing real-time applications run on real-time OSes whose OS API is designed and developed for executing tasks which consist of sig- significantly different from the POSIX interface. A virtual machine nificant amount of computation. Of course some of them in desk- monitor that executes multiple operating systems simultaneously is top computers are latency sensitive for offering the comfortable a promising solution, but existing virtual machine monitors such experience to users, but missing deadlines is not fatal for them. as Xen and KVM are hard to be used for embedded systems due The contribution from the real-time Linux community has signif- to their complexities and throughput oriented designs. In this pa- icantly improved the real-time resource management capability of per, we introduce a lightweight processor abstraction layer named Linux [16]. However, there is always a tradeoff between satisfying vlk. vlk provides virtual CPUs (vCPUs) for respective guest OSes, real-time constraints and achieving maximum throughput [9]. and schedules them according to their priorities. In a typical case, In order to develop such a modern real-time embedded sys- vlk schedules Linux with a low priority and an RTOS with a high tem which needs to satisfy conflicting requirements, combining priority. Two important features of vlk are an interrupt prioritiz- multiple OSes on a virtual machine monitor can be an effective ing mechanism and a vCPU migration mechanism that improves approach. Virtual machine monitors, e.g. KVM [7], Xen [4] and real-time capabilities in order to make the virtualization layer more VMware [18], are traditionally used in the area of data center suitable for embedded systems. We also discuss why the traditional or desktop computing for executing multiple OS instances in one virtual machine monitor design is not appropriate for embedded physical machine. Their capability of executing multiple OSes is systems, and how the features of vlk allow us to design modern also attractive for embedded systems because they make it possi- complex embedded systems with less efforts. ble to implement the system which has multiple OS personalities. If there is a virtualization layer which has a capability of executing GPOS and RTOS in one physical machine, development of real- 1. Introduction time embedded systems can be simpler. In [2], Armand and Gien presented several requirements for a Modern real-time embedded systems like smart phones become virtualization layer to be suitable for embedded systems: highly functional along with the enhancements of CPUs targeting their market. But their functional features introduced significant 1. It should execute an existing operating system and its supported engineering cost. The main difficulty in the development of such applications in a virtualized environment, such that modifica- devices comes from the conflicting requirement of them: low la- tions required to the operating system are minimized (ideally tency and high throughput must be established in one system. This none), and performance overhead is as low as possible. requirement is hard to satisfy with existing OSes, because all of them are categorized as either Real-Time Operating System(RTOS) 2. It should be straightforward to move from one version of an or General Purpose Operating System(GPOS). RTOSes, like eCos operating system to another one; this is especially important to keep up with frequent Linux evolutions. 3. It should reuse native device drivers from their existing execu- tion environments with no modification. 4. It should support existing legacy often real-time operating sys- tems and their applications while guaranteeing their determin- istic real-time behavior. 1 TOPPERS is an open source RTOS that offers µITRON interface, and it [Copyright notice will appear here once ’preprint’ option is removed.] is used in many Japanese commercial products. Unfortunately, there is no open source virtualization layer that tions runs on them. The virtualization layer can execute such in- has a capability to satisfy above all requirements. VirtualLogix2 house software with standard OS platforms like Symbian or An- VLX [2] is a virtualization layer designed for combining RTOS and droid. If the in-house software is developed as software that de- GPOS, but it is proprietary software. OKL4 microvisor [17] is a mi- pends on such a standard platform, it should be modified when a crokernel based virtualization technology for embedded systems, standard platform is replaced. Actually, the standard platform is but performs poorly as the nature of microkernels [2]. In addition, frequently replaced according to various business reasons. On the we found that there is fatal performance degradation of guest OSes other hand, if the in-house software is developed as application pro- when RTOS and SMP GPOS share the same physical CPU. This grams that run on the vendor specific OSes, porting application pro- performance problem comes from the phenomenon called Lock grams is not required even if a standard platform is replaced. Holder Preemption(LHP) [13]. It is a general phenomenon of virtu- The third advantage is the isolation of source code. For example, alization layers, hence a solution for this problem was already pro- proprietary device drivers can be mixed with GPL code without posed. However these existing solutions only focus on the through- license violation. This may solve various business issues when put of guest OSes, therefore the virtualization layers that execute adopting Linux in embedded systems. RTOSes cannot adopt these solutions. To the best of our knowl- The fourth advantage is the isolation of mutual exclusions be- edge, there is no virtualization layer that can execute RTOS and tween guest OSes. Yodaiken explained that the priority inheritance GPOS on a multicore processor without performance degradation mechanism are not suitable for designing real-time systems be- caused by LHP, and is distributed as open source software. cause of its high overhead and complexity [19]. In short, Yodaiken Our laboratory is developing an open source virtualization layer concluded that making critical sections fast and short is the es- for combining RTOS and Linux on embedded systems that adopt sential contribution for real-time responsiveness. McKenney also multicore processors, named vlk (vCPU Layer in Kernel), a forked showed that the priority inheritance mechanism implemented in project from our original project named SPUMONE. During the the rt patch of Linux produces the overhead which affects through- development of this virtualization layer, we faced many difficul- put performance [9]. In general, the priority inheritance mechanism ties specific to embedded systems. They come from the limita- radically contributes to the low latency with preserving original se- tion of hardware resources, the requirement of engineering cost, or mantics of mutexes, even if the OS contains various length of crit- scheduling RTOS and SMP GPOS on the same CPU. Because of ical sections. But it sacrifices the throughput performance as the these difficulties, we believe that virtualization layers for real-time trade-off. embedded systems should be developed as open source software for Of course, the rt patch makes writing soft real-time applications incorporating various insights from a wide range of community. with POSIX APIs possible and this feature is very important and This paper is structured as follows: in Section 2, the detailed useful especially in the area of enterprise computing. But real-time motivation of our project is described. Section 3 describes the applications in the embedded systems area do not require such a basic architecture of vlk. Section 4 describes the difficulties of rich functional APIs like POSIX. dealing with real-time virtualization layers which adopt multicore With hosting RTOS and GPOS, the isolation of mutual exclu- processors. Finally Section 5 concludes this paper and mentions sions can be established because the OSes have their own mutual about future directions of this project. exclusion mechanisms. The threads of the RTOS never acquire the mutex for protecting critical sections of the GPOS, and vice versa. 2. Why Virtualization Of course the mutexes for protecting data structures and critical sections used for inter OS communication must be implemented, This section presents four advantages to use the virtualization layer but the mutexes