A Single Stack Multitasking Operating System for Resource Limited Embedded Devices
Total Page:16
File Type:pdf, Size:1020Kb
Romantiki OS – A single stack Multitasking Operating System for Resource Limited Embedded Devices. Roman Glistvain1, Mokhtar Aboelaze2 Dept. of Computer Science and Engineering York University Toronto, ON. Canada [email protected] [email protected] Abstract-- Most resource limited embedded systems are 3) Fast response to time critical events. Thus, allowing programmed using super-loop architecture [21]. Although the operating system to be used in Soft Real-Time programs written for super-loop architecture are hard to systems. debug and maintain, however it requires much less memory 4) Multitasking OS model for writing application code. which makes it suitable for resource limited devices. Allows code reuse between resource limited In this paper, we propose an operating system “Romantiki” that combines the resource efficiency of super- embedded devices and devices running traditional loop architecture while featuring traditional multitasking operating systems. coding style which makes it easy to develop and maintain 5) “Socket-like” API to write networking applications. complex projects for. We also compare the speed and Thus providing the ability to create a common memory requirements for Romantiki with a commonly used networking abstraction layer between Romantiki OS OS for embedded devices (FreeRTOS). and traditional operating systems. These requirements are met by placing tough coding I. INTRODUCTION guidelines on the developer. The initial learning curve of Embedded processors are gaining popularity in many following those guidelines may result in a prolonged devices. The number of embedded processors sold is development cycle. However, the benefit derived by more than 20 times the number of general purpose making the system use limited resources is far greater. processors in desktop PC’s. The use of embedded The remainder of the paper is organized as follows: processors ranges from TV and DVD players to toasters Section II is a motivation for our work and describes and microwave ovens. The average car contains more Related Work. Section III describes local continuations. than 10 embedded processors for fuel injection, anti-lock Section IV describes the overall structure of Romantiki brakes, and many other functions. OS. Section V provides benchmarks of running similar Low end embedded processors that are widely used in applications on Romantiki vs. FreeRTOS Operating embedded systems and sensor networks are characterized System. Section VI is the direction of the future work. by a simple processor with a limited processing power, Section VII provides the conclusion which defines the limited resources, and low power consumption. They also goals achieved with the Romantiki Operating System. have a low-to-moderate size memory without a Memory management Unit (MMU). These processors require II. MOTIVATION AND PREVIOUS WORK special attention in developing application programs for. For example NXP LPC1111 has a 8K byte of A. Motivation programmable flash and 2K byte of SRAM. It is possible In his paper we focus on resource-constrained of course to get embedded processors with a more embedded devices which have network based user memory but that affects the price and power consumption interface (UI). Those devices include network routers, of the device. managed switches, automation equipment, wireless In this paper we propose a simple operating system sensor network devices, military surveillance, and that can run on embedded devices with very limited communication devices. We will show that it is possible memory resources. The operating system is called to write software for such devices following standard OS Romantiki, which is Russian for “day dreamer”, and it like architecture and create real-time software offers the feature-set of a standard cooperative components which can be shared between complex multitasking operating system. Our design requirement devices and resource limited devices. There are many for Romantiki is to satisfy five important criteria: applications for our proposed operating system, these 1) Fast startup time. include: 2) Small footprint in both RAM and Flash. 1) Making existing systems cheaper. Various systems have a requirement for networking interface for management purposes and currently employ complex stacks on a per task basis which are hard to calculate and microcontrollers and expensive operating systems. Using overall result in an inefficient use of memory resources simple microcontrollers will reduce the cost of the [12]. system. The concept of Y-Threads [13] makes it possible to 2) Systems which require very fast startup time, in create an operating system where the application order of milliseconds. One example of such device is an programmer is responsible for identifying the industrial automation Modbus/TCP station. To allow preemptable and non-preemptable parts of the code. The placement of those devices on a robot arm, the device preemptable portions are assigned private stacks, while needs to be operational within a very short period of time. the non-preemptable portions run on a common stack. Our proposed operating system is ideal for these The system allows application programmer to choose a situations. tradeoff between performance and memory utilization. 3) Battery operated wireless devices. Many home Even though, the use of common stack allows to provide automation wireless devices such as thermostats can significant improvements in memory resource efficiency, benefit from having a network GUI to be remotely this system still requires estimation of multiple stacks controlled. which can be hard in many cases [12]. One of the main advantages of our proposed operating In Mtss, [12] the authors proposed a technique where system is that programs written for Romantiki enjoy a tasks that need more stack space use stacks of other tasks significant improvement in memory utilization compared thus reducing the memory requirements of the program. to standard Operating Systems. In this paper we compare Mantis [3] is a multitasking operating system designed the memory requirements for running the same specifically for sensor nodes in a sensor network. Mantis application code on a small preemptive operating system allocates individual stack space for tasks and then uses FreeRTOS and Romantiki OS. The RAM requirement for round-robin scheduling of tasks in the same priority level the FreeRTOS based application is about two times larger using time slicing. which means that the device needs to employ a bigger There has been a significant amount of research in the and less energy efficient CPU. area of limited memory embedded systems. In particular the recent research focuses on the area of Operating B. Related Work Systems with an integrated TCP/IP networking for small microcontrollers with embedded Flash and RAM [8], Operating systems for embedded processors usually [10], [11], [14], [20]. fall in one of two categories: run to completion systems Some operating systems such as Linux and Windows and preemptive multitasking systems. In run to CE have an integrated TCP/IP stack and provide many completion systems once a process is started, it will run standard features of their desktop counterparts. They have until it is completed, then the next process is scheduled a very simple interface for the creation of processes and and so on. In preemptive multitasking a running job can tasks without forcing the user to worry about the stack be preempted to run a higher priority job. After the higher allocation for each task. This is accomplished by priority job is completed the preempted job could be requiring the use of Memory Management Unit (MMU) resumed. A run to completion system requires less hardware which provides protection mechanisms as well memory resources since only one process is running at as a simple way of dynamically growing task stacks. any time, and all programs share the same stack. Since, many embedded microcontrollers don’t have the However, it may be hard to handle deadlines for real time MMU hardware; they require a different kind of jobs. The lack of preemption may result in missing operating system, the kind which accomplishes the task of important deadline because a low priority job is running task scheduling with minimum amount of hardware and can not be preempted. On the other hand preemptive support. multitasking makes it easier to handle deadlines but it The work of Adam Dunkels [8], [6], [7]serves as a requires large amounts of memory since every task guideline that it is possible to have TCP/IP functionality running or preempted must have its own stack [19]. as well as a small operating system running on small Below is a brief description of previous work on microcontrollers. His work on Protothreads [6], which operating systems for embedded applications. provides a way to perform context switch using stack Baker in [2] discussed the theoretical possibility of rewinding, laid the foundation for the Romantiki building a system capable of preemption using a single operating system. He developed Contiki [8] event-driven stack. In his work he assumed that the stack grows with operating system which provides a feature-set similar to every preemption and shrinks when a job is completed. Romantiki OS. The main difference between Contiki OS He also assumed that resource requirements and deadlines and Romantiki OS lies in their target applications. are available offline. Although his work requires only a The Contiki Operating System with uIP stack is single stack, but it does not save any memory. primarily targeted to 8 and 16 bit microcontrollers with Traditional approaches of using the standard very small amounts of RAM such as 2kb. Contiki doesn’t cooperating [14] or preemptive [10], [11] multitasking have task priorities and therefore, it is hard to use in suffer from the problem of having to allocate separate applications where task level real-time response is snapshot of CPU registers at the place in the function the desired. execution needs to be resumed from. The Romantiki operating system is targeted to new 32 This functionality is similar to state machine programs bit microcontrollers with 16kb or more of RAM.