Proceedings of the 13th IFAC Conference on Proceedings of Devices the 13thand IFACEmbedded Conference on Programmable Systems Proceedings of the IFAC Conference on Proceedings of the 13th 13thand IFACEmbedded Conference on Programmable Devices Systems Available online at www.sciencedirect.com May 13-15, 2015. Cracow, Poland Programmable Devices and Embedded Systems Programmable Devices and Embedded Systems May 13-15, 2015. Cracow, Poland May 13-15, 13-15, 2015. 2015. Cracow, Cracow, Poland Poland May
ScienceDirect
IFAC-PapersOnLine 48-4 (2015) 141–146
Android Android Android
OS OS OS
parameters measurement parameters measurement parameters measurement S3C6410 S3C6410 S3C6410
on on on
∗∗∗ ∗∗∗∗ J. Arm ∗∗ S. Misik ∗∗ ∗∗ Z. Bradac ∗∗∗ V.Kaczmarczyk ∗∗∗∗ J. Arm S. Misik Z. Bradac V.Kaczmarczyk ∗ ∗∗ ∗∗∗ ∗∗∗∗ ∗ ∗∗ ∗∗∗ J. V.Kaczmarczyk J. Arm Arm S. S. Misik Misik Z. Z. Bradac Bradac V.Kaczmarczyk ∗∗∗∗ ∗ ∗ Department of Control and Instrumentation, Faculty of Electrical Department of Control and Instrumentation, Faculty of Electrical ∗ ∗Engineering Department of and Faculty of Communication, Brno University of Technology, Department and of Control Control and Instrumentation, Instrumentation, Faculty of Electrical Electrical Engineering and Communication, Brno University of Technology, Engineering and Communication, Brno University of Technology, Brno, Czech Republic (e-mail:
[email protected]) Engineering and Communication, Brno University of Technology, Czech (e-mail:
[email protected]) ∗∗ Brno, Brno, Republic (e-mail:
[email protected]) of Republic Control and Instrumentation, Faculty of Electrical Brno, Czech Czech Republic (e-mail:
[email protected]) ∗∗ Department Department of Control and Instrumentation, Faculty of ∗∗ ∗∗Engineering Departmentand of Control Control and Instrumentation, Instrumentation, Faculty of Electrical Electrical Communication, Brno University of Technology, Department of and Faculty of Electrical Engineering and Communication, Brno University of Technology, Engineering and Communication, Brno University of Technology, Brno, Czech Republic (e-mail:
[email protected]) Engineering and Communication, Brno University of Technology, Czech Republic
[email protected]) ∗∗∗ Brno, Czech Republic (e-mail:
[email protected]) Department Control(e-mail: and Instrumentation, Faculty of Electrical Brno, Czech of Republic (e-mail:
[email protected]) ∗∗∗ Brno, Department of Control and Instrumentation, Faculty of ∗∗∗ ∗∗∗ Departmentand of Control Control and Instrumentation, Instrumentation, Faculty of Electrical Electrical Engineering Communication, Brno University of Technology, Department of and Faculty of Electrical Engineering and Communication, Brno University of Technology, Engineering and Communication, Brno University of of Technology, Technology, Brno, and Czech Republic (e-mail:
[email protected]) Engineering Communication, Brno University Brno, Czech Republic
[email protected]) ∗∗∗∗ Brno, Republic (e-mail:
[email protected]) of Control and(e-mail: Instrumentation, Faculty of Electrical Brno, Czech Czech Republic (e-mail:
[email protected]) ∗∗∗∗ Department Department of Control and Instrumentation, Faculty of Electrical ∗∗∗∗ ∗∗∗∗ Department of Control and Instrumentation, Faculty of Engineering and Communication, Brno University of Technology, Department of Communication, Control and Instrumentation, Faculty of Electrical Electrical Engineering and Brno University of Technology, Engineering and Republic Communication, Brno University of of Technology, Technology, Brno, Czech (e-mail: Brno
[email protected]) Engineering and Communication, University Brno, Czech Republic (e-mail:
[email protected]) Brno, Brno, Czech Czech Republic Republic (e-mail: (e-mail:
[email protected])
[email protected]) Abstract: Nowadays Android becomes more and more popular operating system. Mostly, it Abstract: more and more popular operating system. Mostly, it Abstract: Nowadays Android becomes more and more system. Mostly, it is installed Nowadays on portableAndroid devices becomes with support and providing friendly user Abstract: Nowadays Android becomes more of andcommunications more popular popular operating operating system. Mostly, it is installed on portable devices with support of communications and providing friendly user is installed on portable devices with support of communications and providing friendly user environment. This article focuses on overview this system from the point of view of programmer is installed on portable devices with support of communications and providing friendly user environment. This article focuses overview the point of programmer environment. This focuses on overview this system from the of view of and showing other options whichon this OS canthis be system used in.from In this paper,of itview is also shown how environment. This article article focuses on overview this system from the point point ofit view of programmer programmer and showing other options which this OS can be used in. In this paper, is also how andmeasure showingsome othersystem optionsparameters which this this from OS can can be usedofin. in.view In this this paper, it it capabilities is also also shown shown how to thebe point of real-time such a and showing other options which OS used In paper, is shown how to measure some system parameters from the point of view of real-time capabilities such aa to measure some system parameters from the point of view of real-time capabilities such switching context time, interrupt latency time and time of work with memory. Thanks these to measure some system parameters from the point of view of real-time capabilities such a switching context time, interrupt latency time and time of work with memory. Thanks these switching context time, interrupt latency and time of work with memory. Thanks these parameters, the system capabilities can betime imagined on target platform. It is discussed about switching context time, interrupt latency time and time of work with memory. Thanks these parameters, system capabilities can imagined on target platform. It is discussed about parameters, the system capabilities can be imagined soft and hardthe real-time capabilities of OSbe Android. parameters, the system capabilities capabilities of can beAndroid. imagined on on target target platform. platform. It It is is discussed discussed about about soft and hard real-time OS soft and and hard hard real-time real-time capabilities capabilities of of OS OS Android. Android. soft © 2015, IFAC (International Federation of Automatic Control) Hosting by Elsevier Ltd. All rights reserved. Keywords: Android, operating system, Tiny6410, S3C6410, switching context time, interrupt Keywords: Android, Android, operating operating system, Tiny6410, Tiny6410, S3C6410, switching switching context time, time, interrupt Keywords: latency Keywords: Android, operating system, system, Tiny6410, S3C6410, S3C6410, switching context context time, interrupt interrupt latency latency latency 1. INTRODUCTION stack architecture (see Fig. 1). This stack is built up on 1. INTRODUCTION INTRODUCTION stack architecture architecture (see Fig. 1). 1). This stack stack is built power up on on 1. stack Fig. This built up Linux kernel which(see generally provides basic is drivers, 1. INTRODUCTION stack architecture (see Fig. 1). This stack is built power up on Linux kernel which generally provides basic drivers, kernel generally provides drivers, management, file-system management, inter-process comIn this paper, features of Android operating system will be Linux Linux kernel which which generally provides basic basic drivers, power power management, file-system management, inter-process comIn this this paper, paper, features of Android Android operating system will will be management, file-system management, communication and task scheduling. Above inter-process this layer, there is In features of operating system be presented regard to provide real-time capabilities. There management, file-system management, inter-process comIn this paper, features of Android operating system will be munication and task scheduling. Above this layer, there is presented regard to provide real-time capabilities. There and task scheduling. Above there is layer containing native libraries such as this SSL,layer, OpenGLES, presented to provide real-time capabilities. will be alsoregard presented demonstrative measurement ofThere main munication munication and task scheduling. Above this layer, there is presented regard to provide real-time capabilities. There layer containing native libraries such as SSL, OpenGLES, will be also presented demonstrative measurement of main containing libraries as SSL, OpenGLES, SQLite, etc. See native Edureka (2013).such will be also presented demonstrative measurement of main parameters determining this capabilities on official An- layer layer containing native libraries such as SSL, OpenGLES, will be also presented demonstrative measurement of main SQLite, etc. etc. See See Edureka Edureka (2013). (2013). parameters determining this capabilities ononofficial official An- SQLite, parameters this capabilities on Android v2.3.4 determining OS with kernel v2.6.36 installed Tiny6410. SQLite, etc. See Edureka (2013). parameters determining this capabilities ononofficial An- In this layer, there is Dalvik Virtual Machine (DVM). This droid v2.3.4 OS with kernel v2.6.36 installed Tiny6410. droid v2.3.4 with kernel v2.6.36 installed on Tiny6410. This paper isOS not intended to be measuring protocol but In this layer, there is Dalvik Virtual Machine (DVM). This droid v2.3.4 OS with kernel v2.6.36 installed on Tiny6410. In this layer, there is Dalvik Virtual Machine (DVM). This virtual machine relies on Linux process isolation and adds This paper is not intended to be measuring protocol but In this layer, there is Dalvik Virtual Machine (DVM). This This paper is intended to measuring protocol but it should some view on possibilities problems virtual machine relies on Linux process isolation and adds adds This paperbring is not not intended to be be measuringand protocol but virtual machine relies on process isolation and more security options forLinux accessing API. This concept is it should bring some view on possibilities and problems virtual machine relies on Linux process isolation and adds it should bring some view on possibilities and problems about measuring these parameters. It also brings a look at more security options for accessing API. This concept is it should bring some view on possibilities and problems more security options for accessing API. concept is called sand-boxing [Varga and Kostrecov´ aThis (2013)]. Sandabout measuring these parameters. It also brings a look at more security options for accessing API. This concept is about measuring these parameters. It also brings look at how much these values could be. This paper also aafocus on called sand-boxing [Varga and Kostrecov´ a (2013)]. Sandabout measuring these parameters. It also brings look at called sand-boxing and Kostrecov´ aafor (2013)]. Sandbox creates special [Varga run-time environment application. how much these values could be. This paper also focus on called sand-boxing [Varga and Kostrecov´ (2013)]. Sandhow much these be. paper also focus advanced possibilities this OS to box creates special run-time environment for application. how muchprogramming these values values could could be. This Thisin alsoregard focus on on creates run-time environment for In this case,special sandbox performs Dalvik byte-code which advanced programming possibilities inpaper this OS OS regard to box box creates run-time environment for application. application. advanced programming possibilities in this regard to achieve greater performance capabilities. In this this case,special sandbox performs Dalvik byte-code which advanced programming possibilities in this OS regard to In case, sandbox performs Dalvik byte-code which the application is created of. Above this layer, there is achieve greater performance capabilities. In this case, sandbox performs Dalvik byte-code which achieve the application application is created created of.which Aboveconsists this layer, layer, there is achieve greater greater performance performance capabilities. capabilities. the is of. Above this there is Application Framework layer of managers. the application is created of. Above this layer, there is Application Framework layer which consists of managers. 2. ANDROID Application layer which consists of managers. This layer isFramework visible for programmers and provides access Application Framework layer which consists of managers. 2. ANDROID This layer is is visible for for programmers and with provides access 2. 2. ANDROID ANDROID This layer visible programmers and provides access to system functions such as operations devices or This layer is visible for programmers and with provides access to system functions such as operations devices or Android is operating system based on Linux. It can be to system functions such as operations with devices or resources. Above this layer, there is application layer which to system functions such as operations with devices or Android is operating system based on Linux. It can be resources. Above this layer, there is application layer which Android is system based on Linux. can be installed on operating ARM, Power Architecture or even It x86 platresources. Above this layer, there there is application application layer layer which which user and system application are in. Android is operating system based on Linux. It can be resources. Above this layer, is installed ongoverned ARM, Power Power Architecture or even even x86 x86 platplatuser and and system application application are are in. in. installed ARM, Architecture or form. It ison by Open Handset Alliance orig- user installed ARM, Power Architecture or even and x86 platuser and system system are in. form. It It isongoverned governed by in Open Handset Alliance and orig- Programmers canapplication develop application for this system in form. is by Open Handset Alliance and originally intended for use portable user devices. Thanks form. It is governed by in Open Handset and orig- Programmers canindevelop develop application for for this system in in inally intended for use use portable userAlliance devices. Thanks can application system aProgrammers standard way Java environment. Javathis byte-code is Programmers can develop application for this system in inally intended for in portable user devices. Thanks to open source policy, Android community is growing and inally intended for use in portable user devices. Thanks a standard way in Java environment. Java byte-code is to open source policy, Android community is growing and a standard way in Java environment. Java byte-code is translated by SDK tools into Dalvik byte-code. It can be standardby way in tools Java into environment. Java byte-code is to open Android is and Android is usedpolicy, more and morecommunity in other sectors. Android to open source source policy, Android is growing growing and atranslated SDK Dalvik byte-code. It can can be Android is used used more and morecommunity in other other sectors. Android SDK tools Dalvik byte-code. It be used nearlyby components Java ecosystem. Other translated byall SDK tools into intofrom Dalvik byte-code. It can be Android is more in sectors. is intended to bemore user and friendly for end-users and Android to have translated Android is used more and more in other sectors. Android used nearly all components from Java ecosystem. Other is intended intended to be be user friendly friendly for end-users end-users and nearly all from Java option is developing in native environment. Here, Other C or used all components components from Java ecosystem. ecosystem. Other is to for and to to have have the same programming environment for programmers over used is intended to be user user friendly for end-users and to have optionnearly is developing developing in native native environment. Here, C or or the same programming environment for programmers over option is in environment. Here, C C++ programming language is used. The part of applioption is developing in native environment. Here, C or the same programming environment for programmers over all supported devices. In other words, once it is ported on the same programming environment for programmers over C++ programming language is used. The part of appliall supported supported devices. In other other words, once it it is ported ported on C++ programming used. part application called shared language library is is deployed together with apC++ language is used. The The part of of appliall In words, once on device, it has devices. to provide the same programming environall supported devices. In other words, once it is is ported on cation cation programming called shared libraryonis isunderlying deployed together with apdevice, it has to provide the same programming environcalled shared library deployed together with application and runs directly Linux. There are cation called shared library is deployed together with device, it has the same programming environment and according components of such device plication and runs directly on underlying Linux. There apdevice, it libraries has to to provide provide the to same programming environare ment and libraries according to components of such device plication and runs directly on underlying Linux. There are two concepts of thisdirectly combination. First, itLinux. is calling native plication and runs on underlying There are ment and libraries according to components of such device like WiFi, Camera, GPS, etc. The concept of this OS is ment and libraries according to components of such device two concepts of this combination. First, it is calling native like WiFi, WiFi, Camera, Camera, GPS, GPS, etc. etc. The The concept concept of of this this OS OS is is two concepts of this combination. First, it is calling native two concepts of this combination. First, it is calling native like like WiFi, Camera, GPS, etc. The concept of this OS is
Copyright © 2015, IFAC IFAC 2015 (International Federation of Automatic Control) 141Hosting by Elsevier Ltd. All rights reserved. 2405-8963 © Copyright IFAC responsibility 2015 141Control. Peer review© of International Federation of Automatic Copyright © IFAC 141 Copyright ©under IFAC 2015 2015 141 10.1016/j.ifacol.2015.07.022
PDeS 2015 142 May 13-15, 2015. Cracow, Poland
J. Arm et al. / IFAC-PapersOnLine 48-4 (2015) 141–146
Fig. 2. Interrupt handling queue 3.2 Interrupt latency Fig. 1. Android OS stack functions from applications in standard environment. In this case, it is needed only to pass function declarations and addresses from native to standard environment. Second, it is possible to create Dalvik run-time environment in native environment and there to call functions from standard environment. Android Linux kernel is standard built with completely fair scheduler (CFS) which tries to execute all threads in time-slices equally often. Threads with higher priority are executed more often. In standard Android system, it is denied to change priority of thread. It has to be used root privilege. The kernel of the system has to be specially recompiled to use these functions. The kernel has to be recompiled to set other type of scheduler (FIFO or Round-Robin) too [Bar (2000)] or can be patched with Preempt RT patch which adds to kernel real-time capabilities [Fu and Schwebel (2014)]. In this paper all parameters are measured on standard kernel scheduler. 3. OPERATING SYSTEM PARAMETERS In this section, operating system parameters will be described which it has been in this paper focused on. These parameters are switching context time, interrupt latency time and time of work with memory. Interrupt latency time is mainly parameter of processor but it has been included to bring comprehensive view on real-time issues of operating system.
Interrupt latency is the time between occurrence and handling of interrupt. Interrupt is handled by CPU whenever hardware or software event occurs. Hardware interrupts (IRQ) are handled first by interrupt service routine according to addresses in Interrupt Descriptor Table (IDT) implemented by kernel of the system. Interrupt routines are implemented by kernel drivers to achieve the fastest response. Once all IRQ handlers have been executed, softirqs are executed. Softirqs are software interrupts such as low level ethernet communication interrupts, software exceptions or other tasklets [LWN.net (2005)]. Then CPU is given back to scheduler to execute threads (see Fig. 2). 3.3 Time of work with memory measurement Time of work with memory is mainly determined by processor clock source, recall time of memory, cache strategy, Memory Management Unit (MMU) implementation and system implementation of memory management. Hardware aspects are determined by device but operating system implementation of memory management may vary. In Android OS standard environment, Java virtual machine implements own functions to create safer memory management. JVM also brings tools like Garbage Collector which cares about unused memory of destroyed objects to provide better comfort for programmers. On the other side, especially this tool brings some aspects like stochastic memory management and extra load for processor. In Android OS native environment, memory management is implemented only by Linux kernel. 4. TINY6410
3.1 Switching context time According to definition, switching context time is the time between end of execution of first thread and start of execution of second thread which is executed right after. During this time, CPU has to save context of first thread, load context of second thread, set CPU registries and start executing the second thread. This process also includes erasing processor pipe-line and refreshing Translation Lookaside Buffer (TLB). These overheads are called direct overheads. When thread operates with larger data ares in memory, there can be indirect overheads because of refreshing of cache memories and Tightly Coupled Memories (TCM) [Li et al. (2007)]. 142
Tiny6410 is one of the development kits of FriendlyARM family. This kit consists of CPU board and base board. The CPU board, called System on Module (SOM), has installed processor and memories. The core of this SOM is System on Chip (SoC) S3C6410 by Samsung. This SoC is based on ARM11 core architecture and contains subsystems for communication and graphic capabilities. Due to this fact, this processor is suitable for user portable devices generally devices to interface with human. On this SOM, there is installed the processor running on 533MHz, 2 x 256MB DDR RAM, 2GB NAND flash memory, power management and connectors (see Fig. 3).
PDeS 2015 May 13-15, 2015. Cracow, Poland
J. Arm et al. / IFAC-PapersOnLine 48-4 (2015) 141–146
143
synchronization mechanism – event (see Fig. 4). In Android standard environment, there is an issue with root permission. Because of that, high priorities of measuring threads can not be set. In consequence of that issue, this measurement is exposed to burden besides handling interrupts with uncertainty of unknown scheduled queue. Before measurement, unnecessary applications and services have been closed to achieve the most accurate values. The switching context time has been measured in standard environment and native environment too. In native environment, there is also measured the switching context time by using system timer but also by using external oscilloscope. In this case, output pin is set and cleared by two measurement threads which call API functions for special pin control through output pin driver. Because of that, one pulse is created on output which length should with some uncertainty correspond to switching context time (see Fig. 5). All measurements are noted in Table 1.
Fig. 3. Tiny 6410 kit - CPU board 5. MEASUREMENT In this section, it will be presented demonstrative measurement of OS parameters discussed in this paper on Tiny6410 development kit. It will be measured the switching context time in standard and native environment of Android OS, latency interrupt time and time of work with memory declared as static and dynamic in standard and native environment supposing the values of parameters in native environment will be lesser than in standard environment. During measurement of switching context time and time of work with memories, there are some uncertainties. The biggest one comes from scheduler and its stochastic planning of execution of tasks which may be fixed by changing scheduler type and core recompiling. The systemic stochastic uncertainty comes from preferred execution of interrupts by CPU. These impacts are minimized on one-core processor only by closing unnecessary tasks and by performing more measurements and selection the least value supposing the smallest impact of these uncertainties. Another lesser uncertainty comes from jitter of programmable interval timer of system. There is also an uncertainty of timer granularity which has been measured but not presented in this paper. In each measurement, there is presented average of measured values according to Formula 1, dispersion of measured values according to Formula 2 and minimal value. N 1 τ= τi N i=1
sτ =
(1)
N
1 (τi − τ )2 N − 1 i=1
(2)
5.1 Switching Context Time Measurement This parameter is measured by using method based on measuring the time between switching from execution of first thread to execution of second thread by using thread 143
Another way to measure this parameter, it can be done by using tracing functions of Linux kernel which needs its changing and recompilation. Other way can be statistical by using Linux pipes. Between two pipes in two threads is cyclically sent one byte for example 10, 000 times. The same is done between only one pipe because in Linux the output of pipe may be redirected to input of the same pipe [Shields (2009)]. These two time values will be subtracted. The uncertainties such as interrupt handling or stochastic scheduler policy are supposed to be equal in both measurements and then subtracted [Li et al. (2007)]. Table 1. Switching context time measurement Environment Standard Native Native - scope
Average [µs] 150.21 45.51 48.12
Dispersion [µs] 118.50 5.60 2.34
Min [µs] 80.12 34.93 44.60
5.2 Interrupt latency Time Measurement Android OS has restricted access to Linux kernel. Only root user can perform directly functions provided by kernel. The kernel needs to be recompiled to gain root access. Options to measure interrupt latency are : • mapping the physical address space of kernel to user virtual space – the kernel needs to be changed and recompiled • by using Interrupt-off latency monitor of kernel – the kernel needs to be changed and recompiled • reading virtual file containing list of active interrupts and checking positive edge – this method will have greater uncertainty of measurement because measuring thread will be executing after all interrupts have been executed and after scheduler decides to execute this thread • creation driver into kernel and implementing through ADB which grants root permissions – this method will be used in this paper in combination with setting up output pin directly in interrupt routine In this experiment, the interrupt is done by setting directly of processor pin to logical high. This pin is bound in kernel to interrupt handler routine through interrupt description
PDeS 2015 144 May 13-15, 2015. Cracow, Poland
J. Arm et al. / IFAC-PapersOnLine 48-4 (2015) 141–146
Fig. 6. Interrupt latency time measurement - oscilloscope monitor kernel space. The average value of measured interrupt time is 10.91 µs and dispersion 0.86 µs. 5.3 Time of work with memory measurement This measurement is also exposed to the burden of uncertainty comes from stochastic scheduler and interrupt handling like switching context time measurement. In this paper, there is measured writing a double (8 bytes) value into every element of array of specified length located in memory declared as static and dynamic. Dynamic declared array is initialized before measurement. Measurement values of time of work with memory and time of allocation of this memory in standard environment are noted in Table 2. Measurement values of time of work with memory and time of allocation of this memory in native environment are noted in Table 3. Graph containing time of work with memories over length of memory array in standard environment is noted in Fig. 7 and in native environment Fig. 8. These graphs also compares time o work with memory and time of allocation. In fact, whole time of work with dynamic memory is addition of time of work and allocation time. On the other hand, allocation of memory declared as static is done after process start. Graph comparing time of work with memory in standard and native environment is noted in Fig. 9. This graph is the most important of these graphs because it compares work time with memory in both environments.
Fig. 4. Switching context time measurement diagram
Table 2. Time of work with memory in standard environment Fig. 5. Switching context time measurement with oscilloscope table which other pin is cleared immediately in. Therefore between these two actions, the windows is created which width corresponds to interrupt latency time (see Fig. 6). To measure this parameter, it is needed to register own interrupt handler routine into the kernel of OS. New routine has been programmed to change pin state from kernel space and this routine has been compiled against current kernel source to provide addresses of functions in 144
Capacity [-] Dynamic [ms] Static [ms] Allocation [ms]
100 0.059 0.051 0.034
1000 2.798 2.316 0.125
5000 5.491 3.198 0.338
10000 3.692 2.972 0.750
20000 4.233 3.629 1.234
Table 3. Time of work with memory in native environment Capacity [-] Dynamic [ms] Static [ms] Allocation [ms]
100 0.012 0.010 0.014
1000 0.080 0.105 0.110
5000 0.452 0.531 0.084
10000 0.826 0.943 0.126
20000 1.793 1.859 0.160
PDeS 2015 May 13-15, 2015. Cracow, Poland
J. Arm et al. / IFAC-PapersOnLine 48-4 (2015) 141–146
145
management which causes higher switching context time. The interrupt latency time of hardware interrupt IRQ has been measured on S3C6410 SoC processor. The time of writing to each element of array in memory declared as static and dynamic in standard and native environment has been measured.
Fig. 7. Time of work with memory in standard environment
The switching context time parameter has evinced greater dispersion in contrast to interrupt latency parameter. One of the reasons of lesser dispersion is that interrupt handling is designed to be fast as possible directly in processor which has to save the current context immediately and execute interrupt routine provided by OS. Measured value is high in comparison with capabilities o the processor. First source of delay is that our IRQ has higher value therefore lower priority. Second source of delay comes from the kernel architecture which does not put IRQ routine of GPIO directly into area interrupt description table of CPU but has its own management of these interrupts [LWN.net (2005)]. Third source of delay is switching on another GPIO to catch execution of this interrupt by oscilloscope. To minimize uncertainties of the measurement of switching context time and time of work with memory, measuring has been done during the least system usage and the minimal values have been taken as the most accurate. To achieve more accurate value, the core of OS could have been recompiled with another scheduler type for example Round-Robin and measurement application could have had threads with priorities and could have run with root privileges to truly ensure executing these measuring threads second after first. But normal user applications on this system will be running in standard environment with restricts privileges. Because of that, measured values are the most truly values of these parameters from the point of view of applications in standard user space. As expected, the time of work with memory in native environment is lesser than in standard environment. The time of work with static and dynamic variable array in each environments are nearly equal. Because linker puts all variables into dynamic memory (DRAM). Static variables are initialized during application start. Unlike dynamic variables has to be allocated first. This operation is considered to be non-deterministic due to going through memory. But the probability of allocation time can be calculated. However in both cases, access to these variables is mainly determined apart from hardware specifications by segmentation and fragmentation mechanism [Kucera (2012)].
Fig. 8. Time of work with memory in native environment
7. HARD REAL-TIME CAPABILITY SUPPORT
Fig. 9. Comparison of work time with dynamic memory in native and standard environment 6. RESULTS The switching context time in standard and native environment of Android operating system has been measured (see Table 1). As expected, the switching context time in native environment is lesser than in standard Dalvik runtime machine. This run-time has moreover its own thread 145
In case of requirement of hard real-time capability of this system, it may be first considered if usage of this system is necessary. This system is built up on Linux kernel so it can be recompiled and patched with real-time support. Real-time applications can now run in real-time (native) environment of the kernel. To achieve real-time capabilities in standard environment there are two options : • recompile and patch Linux kernel for real-time capabilities, replace Dalvik virtual machine with classical Java real-time machine and adapt other Android parts
PDeS 2015 146 May 13-15, 2015. Cracow, Poland
J. Arm et al. / IFAC-PapersOnLine 48-4 (2015) 141–146
• rebuild Dalvik virtual machine with real-time capabilities according to Java real-time machine These two other options are considered to be heavy on developing time and resources [Mauerer et al. (2012)]. In fact, hard real-time capabilities of Android OS or any OS can not be achieved on one-core processor based on architecture by Intel because despite of applying fully hard real-time capabilities of kernel, there are still some nonmaskable interrupts like System Management Interrupt SMI which can not be preempted by OS [RtWikiKernel (2014)]. This problem could have been solved by using of duo core processor and running real-time applications on second core. 8. PROPOSAL In this paper, all measurements have been made on official unmodified Android. For better nearly hard real-time capabilities, there are more ways to do this (see Chapter. 7). Nowadays, Android is used in many portable devices and the count of these devices is growing. This system is mostly installed on devices in commercial grade. The proposal is to use this OS with some modifications as OS on Human Machine Interface (HMI) devices such as touch panels in industrial grade - on devices which are supposed to meet soft real-time deadlines. On this custom devices, system parameters can be measured like switching context time, interrupt latency time or time of work with memory. According to these parameters and system requirements from the point of view of work tasks load, these deadlines can be determined. This system is considered to be user-friendly which can be used as a clearly interface for operators. It also has built in communication libraries which can be used for rapid developing of communication with devices on bus or with superior server.
sources except Dalvik virtual machine, pre-programmed libraries and big community. Among disadvantages, it can be considered existing a lot of versions and modifications. So any features do not have to run on any devices. ACKNOWLEDGEMENTS The research was financially supported by Brno University of Technology and the European Regional Development Fund under project No. CZ.1.05/2.1.00/01.0014. The above-mentioned funds and institutions facilitated efficient performance of the presented research and associated tasks. This work was supported also by the project “TA02010864 - Research and development of motorized ventilation for the human protection against chemical agents, dust and biological agents”, project “TA03020907 - REVYT - Recuperation of the lift loss energy for the lift idle consumption” and project “TA04021653 - Automatic Lift Inspection” granted by Technology Agency of the ˇ Czech Republic (TA CR). Part of the work was supported by project “FR-TI4/642 - MISE - Employment of Modern Intelligent MEMS Sensors for Buildings Automation and Security” granted by Ministry of Industry and Trade of Czech Republic (MPO). Part of the work was carried out with the support of core facilities of CEITEC – Central European Institute of Technology under CEITEC – open access project, ID number LM2011020, funded by the Ministry of Education, Youth and Sports of the Czech Republic under the activity “Projects of major infrastructures for research, development and innovations”. Part of this paper was made possible by grant No. FEKT-S-142429 - “The research of new control methods, measurement procedures and intelligent instruments in automation”, and the related financial assistance was provided from the internal science fund of Brno University of Technology. REFERENCES
9. CONCLUSIONS The switching context time, interrupt latency time and time of work with memory of the Android operating system on S3C6410 processor have been measured to draw possibilities of this system. These values are not accurate values of these parameters but the most truly values from the point of view of user application (see Chapter 6). Because of that, architecture of such application can be carefully designed and optimized to achieve soft real-time more precisely according to requirements and device capabilities. To achieve hard real-time, the Linux kernel has to be recompiled with real-time features, some patches have to be implemented to redesign Linux core and applications have to be adapted for this (see Chapter 7). This paper has also presented programming environments with emphasis on native environment and possibility to create own driver ported to Linux kernel of this OS. It has been proven that in this environment are system parameters like switching context time and time of work with memory lesser than in standard environment which is good for performance. Standard environment offers on the other hand better comfort for programmers. During measuring, some advantages and disadvantages have been discovered. Among advantages, it can be considered portability of the system on many devices, opened 146
Arm, J. (2014). An android application for tiny6410sdk. http://www.vutbr.cz. Bar, M. (2000). The linux scheduler. http://www.linuxjournal.com. Edureka (2013). The beginner’s guide to android: Android architecture. http://www.edureka.co. Fu, L. and Schwebel, R. (2014). Rt preempt howto. https://rt.wiki.kernel.org. Kucera, P. (2012). Real-time os - memory management. Li, C., Ding, C., and Shen, K. (2007). Quantifying the cost of context switch. http://www.cs.rochester.edu. Li, Q. and Yao, C. (2003). Real-Time Concepts for Embedded Systems. CMP Books. LWN.net (2005). Interrupt handling. http://lwn.net, 10. Mauerer, W., Hillier, G., Sawallisch, J., H¨onick, S., and Oberth¨ ur”, S. (2012). Real-time android: Deterministic ease of use. http://www.linuxtag.org. Penumuchu, C.V. (2007). Simple Real-time Operating System - A kernel inside view for a beginner. Trafford Publishing. RtWikiKernel (2014). Howto: Build an rt-application. Shields, I. (2009). Learn linux, 101: Streams, pipes, and redirects. http://www.ibm.com. Silva, V. (2009). Pro Android Games. Apress. Varga, J. and Kostrecov´ a, E. (2013). Os android - architecture and security. Sdˇelovac´ı technika, 10.