Professional Documents
Culture Documents
Paez 2015
Paez 2015
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
Francisco E. Páez 1,2, José M. Urriza 1 Ricardo Cayssials 3, Javier D. Orozco 2,3
1 3
Depto. de Informática - Facultad de Ingeniería Depto. de Ingeniería Eléctrica y Computadoras
Universidad Nacional de la Patagonia San Juan Bosco Universidad Nacional del Sur
Puerto Madryn, Argentina Bahía Blanca, Argentina
2
CONICET
fpaez@unpata.edu.ar, josemurriza@unp.edu.ar
Abstract— Real-time systems are applied in the more diverse reliability, although modifications of this type lead to a more
applications. Most of these applications require specific efficient use of the resources. The second option, unlike the
configurations in order to meet their timing constraints. Real- first one, allows the designer to easily adapt the RTOS to the
time Operating Systems offer scheduling policies that produce a application specific scheduling requirements. The RTOS safety
certain behavior of the application, difficult to change in order to certifications, robustness and reliability are not altered, and it
get a specific and desired dynamic of the system. On the other should be just enough to verify the developed application. A
hand, most real-time applications include tasks with different survey of previous and related work in user-level schedulers is
real-time constraints: from hard real-time tasks to sporadic and presented in the next section.
soft real-time tasks. Configuring a real-time operating system to
get the desire response for each one of these tasks generally In this paper, a user-level scheduler is developed through a
involves a deep knowledge of the structure of the kernel and user-level task, called Heterogeneous Scheduling Task (HST),
programming it in a privilege mode. In this paper, it is proposed in order to support Mixed Critical Systems in a very flexible
an implementation of a user-level scheduler, easily configurable way. An implementation on FreeRTOS is presented.
to adapt the dynamic of the system to the specific features of the
application.
A. Previous and related work
Keywords—Real-Time System; Scheduling; Mixed Critical Similar methods are proposed in the literature. An
Systems; Application-Defined Scheduling application-defined scheduling for MaRTE OS is proposed in
[3, 4], and support for user-level hierarchical scheduling
I. INTRODUCTION policies for FreeRTOS are presented in [5, 6]. An application-
defined scheduling model and its implementation as a library
Real-Time Operating Systems (RTOS) are used in the most framework for RTLinux are presented in [7, 8]. A framework
widely range of applications. The evolution of these for implementing real-time scheduling algorithms, verified
applications forces RTOSs to adapt their features to new with a model checker, is presented in [9]. A general scheduler
requirements. In such a way, it is possible to find applications framework, with implementations for Linux and VxWorks,
in which the RTOS has to execute, not just a set of real-time called ExSched, is developed in [10]. Similar frameworks for
tasks (RTTs), but also a set of non-real-time tasks (NRTTs). prototyping and implementing user-space hierarchical
These kinds of systems that deal with a heterogeneous set of schedulers are SF3P ([11]), FSF ([12]) and Hijack ([13]). A
tasks (that involves RTTs as well as NRTTs) are named Mixed high-level domain specific language for programming user-
Critical Systems [1, 2]. When a RTOS has no support for a space scheduling policies, called Bossa and a framework for
heterogeneous set of tasks, it may happen that: (1) the timing executing it, are developed in [14]. In [15], it is proposed a
constraints of the RTTs may not be satisfied, (2) the CPU broker that mediates between a RTOS and its RTTs, and
performance of NRTTs may not be adequate or (3) the system provides the means of implementing a new scheduling policy.
resources may be wasted. A system that enables applications to dynamically load and
There exist two alternatives to adapt a RTOS in order to unload scheduling policies into a general-purpose operating
support a heterogeneous set of tasks. The first one is to modify system is described in [16].
the kernel in order to include new scheduling policies for this
kind of set of tasks. The second alternative is to provide a B. RTOS Selection
user-level scheduler, which overrides the kernel scheduler Nowadays, there exist several RTOSs used in different
actions. kind of applications. VxWorks, QNX, μs-OS, eCos, Windows
The former alternative requires changes to the RTOS CE and RT-Linux are just a few RTOSs currently available.
kernel, which in many cases are complex from several points The selection of the RTOS to implement the proposed HST
of view: requires a thorough knowledge of the RTOS structure, was based mainly on: (1) portability of the RTOS among
and can cause the loss of safety certifications, robustness and different embedded systems, (2) availability of well
37
2015 Sixth Argentine Symposium and Conference on Embedded Systems (CASE)
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
documented source code and (3) license to introduce II. SYSTEM ARCHITECTURE
modifications into the source code. With these criteria in mind The Task Control Block (TCB) defined by FreeRTOS does
we selected FreeRTOS which is a small footprint and widely not include attributes to hold particular parameters for generic
used RTOS. task models as the proposed in this paper. For this reason, it
FreeRTOS is an open source RTOS distributed under a was defined an extended TCB, denoted eTCB, based on the
modified GPL license. It is mainly written in C, with small attributes that a task in a Mixed Critical System may present.
sections written in assembler. Its main features are: its small Moreover, each eTCB has a reference to one TCB in order to
footprint, its low memory and processing requirements and its keep functional the FreeRTOS tasks control functions.
availability in more than 33 processor architectures. The eTCB for a task i hold the following parameters:
FreeRTOS implements tasks as threads, each with its own
Pointer to FreeRTOS TCB (Task handler).
stack of configurable size, and supports processors with
Memory Protection Unit (MPU). It implements multiple Task priority.
memory profiles, from static to dynamics ones with support of
malloc and free functions. Worst Case Execution Time (Ci).
38
2015 Sixth Argentine Symposium and Conference on Embedded Systems (CASE)
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
Context Switching (CS). The Fig. 1 shows the interaction AppSched_Delay(), AppSched_Block() and
between the HST, the scheduled tasks and the RTOS kernel. AppSched_Suspend(): these functions block and unblock
the HST and they are invoked when a task finishes its
execution, it is blocked or it is suspended, respectively.
B. AppSchedLogic module
This module implements a specific scheduling policy
through the following functions:
AppSchedLogic_Init(): initializes all the data structures
required by the implemented scheduling policy.
Fig. 1. General interaction among the HST, its application-scheduled tasks AppSchedLogic_Tick(): implements the action to be carry
and the FreeRTOS kernel. out each time that the timer tick interrupt takes place.
Returns true if it is required to unblock the HST.
The HST functionality is implemented by two modules: (1)
the AppSched module and (2) the AppSchedLogic module. AppSchedLogic_Sched(): implements the scheduling
These modules are described in the following sections. policy.
39
2015 Sixth Argentine Symposium and Conference on Embedded Systems (CASE)
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
notification that may include a value. In this way, it is possible AppSched_Create(): creates a task using the xTaskCreate()
to replace very effectively the utilization of binary function, with a priority equal to HST_TaskPrio. The task
semaphores for task synchronization, avoiding the overhead is then suspended using the vTaskSuspend() function in
produced by them. The HST blocks itself when trying to take a order to avoid inserting it into the FreeRTOS ready list.
notification and it is resumed by a notification issued from the System memory is reserved for the corresponding eTCB by
correspondent traces macros functions: calling the pvPortMalloc() function.
AppSched_Block(), AppSched_Suspend() and AppSched_Init(): creates the HST by calling the
AppSched_Delay(): these functions unblock the HST vTaskCreate() function with a priority equal to HST_Prio.
sending a notification to it, using the xTaskNotifyGive() It calls the AppSchedLogic_Init() function and then the
function. The notification is not sent if the HST is the FreeRTOS scheduler is executed, which starts the HST.
current task in execution. Fig. 2 shows an example of its
execution. Fig. 4 shows the overall architecture of both modules and
they interaction with the FreeRTOS kernel and a user-level
application.
Fig. 2. Example of the HST being released after the finalization of the current
release of Task 1, and then perfoming a CS to Task 2.
Fig. 4. Interaction between the HST modules and the FreeRTOS kernel.
40
2015 Sixth Argentine Symposium and Conference on Embedded Systems (CASE)
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
41
2015 Sixth Argentine Symposium and Conference on Embedded Systems (CASE)
ISBN: 9789874552341 EBook: 9789874552358 Printed IEEE CATALOG: CFP15C02PRT IEEE XPLORE: CFP15C02ART
As Fig. 5 shows, the average CS cost decreases for lower Systems (SIES), 2012 7th IEEE International Symposium on, 2012, pp.
priority tasks when the HST is used. This happens because the 319-322.
[7] Arnoldo Diaz, Ismael Ripoll, P Balbastre and A Crespo, "A new
HST suspends any new task arrival with a lower priority than application-defined scheduling implementation in rtlinux," in
the running task one. For higher priority tasks it is more likely Proceedings of the Sixth Real-Time Linux Workshop, 2004.
that new arrivals had happened. As the priority of a task [8] A. Diaz, I. Ripoll and A. Crespo, "A library framework for the posix
decreases, the chances of other arrivals at the end of its application-defined scheduling proposal," in Electrical and Electronics
execution are lower. In consequence, the HST doesn’t have to Engineering, 2005 2nd International Conference on, 2005, pp. 21-26.
[9] Li Peng, B. Ravindran, S. Suhaib and S. Feizabadi, "A formally
suspend new arrivals as often. verified application-level framework for real-time scheduling on posix
The clock cycles required for the execution of the HST real-time operating systems," Software Engineering, IEEE Transactions
on, vol. 30, Nº 9, pp. 613-629, 2004.
after an instance finalization is slightly more than twice of the [10] M. Asberg, T. Nolte, S. Kato and R. Rajkumar, "Exsched: An external
required by the FreeRTOS scheduler alone. Furthermore, it cpu scheduler framework for real-time systems," in Embedded and
shows little variation with respect the UF. In the evaluations Real-Time Computing Systems and Applications (RTCSA), 2012 IEEE
the increased CS time have not affected the overall real-time 18th International Conference on, 2012, pp. 240-249.
response of the tasks. [11] A. Gomez, L. Schor, P. Kumar and L. Thiele, "Sf3p: A framework to
explore and prototype hierarchical compositions of real-time
schedulers," in Rapid System Prototyping (RSP), 2014 25th IEEE
VI. CONCLUSIONS AND FUTURE WORK International Symposium on, 2014, pp. 2-8.
[12] M. Aldea, G. Bernat, I. Broster, A. Burns, R. Dobrin, J. M. Drake, G.
A user-level scheduler support for FreeRTOS is presented. Fohler, P. Gai, M. G. Harbour, G. Guidi, J. J. Gutierrez, T. Lennvall, G.
It gives the system designer more flexibility for developing Lipari, J. M. Martinez, J. L. Medina, J. C. Palencia, and M. Trimarchi,
new scheduling methods, especially for managing mixed "Fsf: A real-time scheduling architecture framework," in Real-Time
critical systems, without an excessive overhead. As an and Embedded Technology and Applications Symposium, 2006.
example of this capability, an implementation of a RM user- Proceedings of the 12th IEEE, 2006, pp. 113-124.
[13] G. Parmer and R. West, "Hijack: Taking control of cots systems for
level scheduler which manages NRTT with a Slack Stealing real-time user-level services," in Real Time and Embedded Technology
mechanism was developed. As future work, the proposed and Applications Symposium, 2007. RTAS '07. 13th IEEE, 2007, pp.
architecture will be extended with support for concurrent user- 133-146.
level schedulers and hierarchy scheduling strategies. Also, [14] G. Muller, H. Duchesne and J. L. Lawall, "A framework for
new scheduling algorithms will be implemented, evaluating simplifying the development of kernel schedulers: Design and
performance evaluation," in Object-Oriented Real-Time Dependable
their costs and feasibility within the framework of the HST. Systems, 2005. WORDS 2005. 10th IEEE International Workshop on,
2005, pp. 219-227.
AVAILABILITY [15] E. Eide, T. Stack, J. Regehr and J. Lepreau, "Dynamic cpu
management for real-time, middleware-based systems," in Real-Time
Source code and documentation can be downloaded from and Embedded Technology and Applications Symposium, 2004.
the UNPSJB Real Time Systems Group website: Proceedings. RTAS 2004. 10th IEEE, 2004, pp. 286-295.
http://www.rtsg.unp.edu.ar/. [16] George M Candea and Michael B Jones, "Vassal: Loadable scheduler
support for multi-policy scheduling," in Proceedings of the 2nd
USENIX Windows NT Symposium, 1998, pp. 157-166.
ACKNOWLEDGMENT [17] C. L. Liu and James W. Layland, "Scheduling algorithms for
multiprogramming in a hard real-time environment," Journal of the
We want to thanks Richard Barry, for his advices in order ACM, vol. 20, Nº 1, pp. 46-61, 1973.
to improve this work, the anonymous reviewers for their [18] John P. Lehoczky and Sandra Ramos-Thuel, "An optimal algorithm for
comments, and the ARM University Program, which provided scheduling soft-aperiodic tasks in fixed-priority preemptive systems,"
the mbed microcontrollers. in IEEE Real-Time Systems Symposium, Phoenix, Arizona, EUA,
1992, pp. 110-123.
[19] Sandra Ramos-Thuel and John P. Lehoczky, "On-line scheduling of
REFERENCES hard deadline aperiodic tasks in fixed-priority systems," in Real-Time
Systems Symposium, 1993, pp. 160-171.
[1] Alan Burns and Robert Davis, "Mixed criticality systems-a review,"
[20] Sandra Ramos-Thuel and John P. Lehoczky, "Algorithms for
2013.
scheduling hard aperiodic tasks in fixed-prioriys systems using slack
[2] S. Vestal, "Preemptive scheduling of multi-criticality systems with
stealing," in Real-Time Systems Symposium, 1994, pp. 22-33.
varying degrees of execution time assurance," in Real-Time Systems
[21] T. S. Tia, J. W. S. Liu and M. Shankar, "Algorithms and optimality of
Symposium, 2007. RTSS 2007. 28th IEEE International, 2007, pp.
scheduling soft aperiodic requests in fixed priority preemtive systems,"
239-243.
The International Journal of Time-Critical Computing Systems, vol. 10,
[3] M. A. Rivas and M. G. Harbour, "Posix-compatible application-defined
Nº pp. 23-43, 1996.
scheduling in marte os," in Real-Time Systems, 2002. Proceedings.
[22] José M. Urriza, Francisco E. Paez, Ricardo Cayssials, Javier D. Orozco
14th Euromicro Conference on, 2002, pp. 67-75.
and Lucas Schorb, "Low cost slack stealing method for RM/DM,"
[4] Mario Aldea Rivas and Michael González Harbour, "A new
International Review in Computers and Software (IRECOS), vol. 5, Nº
generalized approach to application-defined scheduling," in
6, pp. 660-667, 2010.
Proceedings of 16th Euromicro Conference on Real-Time Systems
[23] Gabriela Olguín, Laura Biscayart and José M. Urriza, "Generación de
(WiP), Catania, Sicily (Italy), 2004.
tareas periódicas y aperiódicas para simulación de sistemas de tiempo
[5] R. Inam, J. Maki-Turja, M. Sjodin, S. M. H. Ashjaei and S. Afshar,
real," Journal of Industrial Engineering (IJIE), vol. 3, Nº 6, pp. 53-69,
"Support for hierarchical scheduling in freertos," in Emerging
2011.
Technologies & Factory Automation (ETFA), 2011 IEEE 16th
Conference on, 2011, pp. 1-10.
[6] R. Inam, M. Sjodin and R. J. Brfi, "Implementing hierarchical
scheduling to support multi-mode system," in Industrial Embedded
42