• No results found

Performance analysis of different scheduling algorithms in FreeRTOS

N/A
N/A
Protected

Academic year: 2021

Share "Performance analysis of different scheduling algorithms in FreeRTOS"

Copied!
27
0
0

Bezig met laden.... (Bekijk nu de volledige tekst)

Hele tekst

(1)

Bachelor Informatica

Performance analysis of

dif-ferent scheduling algorithms in

FreeRTOS

Eric van der Woude

June 19, 2020

Inf

orma

tica

Universiteit

v

an

Amsterd

am

(2)
(3)

Abstract

Real-time systems play an essential role in our society. One of the critical aspects of a real-time system is the scheduling of tasks. The two most researched and used scheduling policies are rate-monotonic scheduling and earliest deadline first scheduling. In theory, earli-est deadline first scheduling guarantees deadlines in the system at higher loading, compared to rate-monotonic scheduling. Despite this, rate-monotonic scheduling remains the prevalent scheduling policy used in real-time systems, perhaps due to negative misconceptions on ear-liest deadline first scheduling. In 2003, Buttazzo tried to tackle some of the misconceptions on earliest deadline first scheduling. This thesis will try to confirm his conclusions using the I.MX RT1020 embedded board by NXP and the real-time operating system FreeRTOS.

The results have shown that the theoretical feasibility bounds do not always hold in practice. The rate-monotonic scheduler was able to schedule the same task sets as the earliest deadline first scheduler could. One of the goals of this thesis was to validate some common beliefs which Buttazzo tried to tackle. It was found that rate-monotonic scheduling is indeed easier to implement than earliest deadline first scheduler. It was also found that the run-time overhead of earliest deadline first scheduling was higher than rate-monotonic scheduling, but negligible for the total execution time. Lastly, benchmarks have shown that the rate-monotonic scheduler provides more predictable behavior during overload, but only for the highest priority tasks, which is in line with the claim Buttazzo made.

(4)
(5)

Contents

1 Introduction 7

2 Theoretical background 9

2.1 Related work . . . 9

2.2 Ethical aspects . . . 9

2.3 Real-time operating systems . . . 10

2.4 Scheduling . . . 10

2.4.1 Static priority pre-emptive scheduling . . . 11

2.4.2 Rate-monotonic . . . 12

2.4.3 Earliest Deadline First . . . 13

2.5 FreeRTOS . . . 13

3 Implementation 15 3.1 FreeRTOS on the i.MX RT1020 Evaluation Kit . . . 15

3.2 Communication between FreeRTOS and host machine . . . 15

3.3 Rate-monotonic scheduling . . . 16

3.4 Earliest deadline first . . . 16

3.5 The ESFree scheduling library . . . 17

3.6 Run-time statistics . . . 17 4 Experiments 19 4.1 Task sets . . . 19 4.2 Feasibility analysis . . . 20 4.3 Benchmarking . . . 21 4.3.1 Task set A . . . 21 4.3.2 Task set B . . . 21 4.3.3 Task set C . . . 21 4.3.4 Task set D . . . 22 5 Conclusions 25 5.1 Discussion . . . 26 5.2 Future research . . . 26

(6)
(7)

CHAPTER 1

Introduction

Real-time systems play an essential role in our society. Applications ranging from controlling the engine and brakes of our cars and regulating traffic lights to telecommunication, nuclear power plant control, and space missions [1].

One of the critical aspects of a real-time system is the scheduling of tasks. Some example tasks for real-time systems would be processing sensor data to ensure a safe environment for a nuclear plant or an aircraft, transforming data, and communication between an airplane and air traffic control tower. The scheduling of tasks is done by the operating systems’ scheduler. There is a variety of metrics to describe the effectiveness of real-time scheduling algorithms. This variety is an indication of the different types of real-time systems and their requirements [2]. Scheduling algorithms can be divided into static priority and dynamic priority [3]. In dynamic priority scheduling, the priority of a task can change at any time, whereas in static priority scheduling the priority is determined beforehand.

Liu and Layland showed that the rate-monotonic algorithm was the most optimal algorithm for static priority scheduling. They also showed that the earliest deadline first algorithm per-formed best for dynamic priority scheduling [4]. Although earliest deadline first scheduling is in theory better capable of scheduling task sets with a high processor utilization, rate-monotonic scheduling is the industry standard. In theory, earliest deadline first scheduling is better capable of scheduling task sets with high utilization than rate-monotonic scheduling. Rate-monotonic scheduling remains the industry standard, possibly due to misconceptions on earliest deadline first scheduling. Buttazzo tried to tackle some of these misconceptions in 2003, showing that these misconceptions do not hold [5] in general.

The goal of this thesis is to analyze the performance of these two common scheduling algo-rithms using the real-time operating system FreeRTOS and to validate some of the misconcep-tions that Buttazzo tried to tackle. The performance analysis will be supported by worst-case response time analysis and benchmarks. The benchmarks will be performed on the i.MX RT1020 Evaluation Kit by NXP, which is a PCB designed for high performance in real-time situations [6].

Hypothesis:

The earliest deadline first scheduler will feasibly schedule task sets with a higher utilization value than the rate-monotonic scheduler.

(8)
(9)

CHAPTER 2

Theoretical background

2.1 Related work

The scheduling of periodic tasks with hard deadlines was first studied by Liu and Layland in the early seventies. Assuming that the period of the task equals the deadline, they have shown that rate-monotonic scheduling and earliest deadline first scheduling are most optimal for static priority and dynamic priority scheduling respectively [4]. Later, Lehoczky, Sha and Ding have shown using stochastic analysis that the average case behavior of rate-monotonic scheduling is usually much better than the worst-case behavior [7]. Bini and Buttazzo proposed a new feasi-bility formula called the hyperbolic bound. The hyperbolic bound offers a more relaxed bound for rate-monotonic scheduling which is shown to be a better reflection of the schedulability of different task sets with rate-monotonic scheduling.

Although rate-monotonic scheduling is the dominant real-time scheduling algorithm, for some real-time systems the static scheduling algorithms are too restrictive and inflexible. For systems in highly non-deterministic environments such as communication and real-time multimedia sys-tems, earliest deadline first approaches are more appropriate. Stankovic, Spuri, Ramamritham and Buttazzo compiled an extensive list of literature on EDF scheduling and their variants into a single book: Deadline Scheduling for Real-Time Systems: EDF and Related Algorithms.

Later in 2003, Buttazzo tried to tackle common misconceptions about RM and EDF schedul-ing. According to common beliefs, RM is easier to implement, has better jitter control, less overhead, and is more predictable during short-term overload. He concluded that the implemen-tation of EDF is indeed not easy and efficient on most commercial real-time kernels since they are based on static priority scheduling. The dynamic nature of EDF scheduling is a problem since in the worst-case all tasks are assigned a new priority each task switch, creating an undesirable amount of overload. He has been able to refute the other misconceptions regarding EDF and RM scheduling for general cases. [8].

2.2 Ethical aspects

Whether you can see them or not, real-time systems are all around us. Extra research into these systems is therefore important since they are so widely used. Also, the earliest deadline first scheduler is used less than the rate-monotonic scheduler while it allows for full processor utilization, perhaps due to misconceptions. Extra validation on the misconceptions will shed light on the true strengths and weaknesses of the scheduling algorithms. Allowing those who are implementing a real-time application to choose the best scheduler based on the true properties, and not on misconceptions.

(10)

2.3 Real-time operating systems

The word time indicates that the correctness of the system depends on two variables: the logical result of the computation, and the time the result arrives. The word real indicates that the system must react to external events during their evolution. The notion of real-time is often misunderstood as a quick response to external events [9]. This implies that all fast computers are real-time, which is false. The right interpretation of real-time is that real-time systems must react following external time. The difference is that the environment plays a critical role in real-time systems [10].

A real-time operating system (RTOS) is an operating system that operates in real-time. Therefore, the correctness of such an operating system depends on the logical result of the com-putation and the time the result arrives, because of it’s real-time nature. Let’s define a task as a unit of work. Tasks typically have an arrival time and a deadline. The arrival time is the time when the task is available for execution and this execution should be done before the deadline. It is the job of a RTOS to perform all tasks with respect to their deadline.

There are many different types of tasks. Some tasks have a soft deadline, meaning that miss-ing the deadline is undesirable but may happen occasionally. In contrast, tasks can have a hard deadline, which if missed is considered a critical error and a failure of the real-time operating system. Tasks do not have to have a strictly hard or soft deadline, but it can have a deadline anywhere in between those two terms. Tasks also vary in their periodic or aperiodic nature. In some situations, tasks are required to be run with a fixed frequency such as 10ms, while other tasks are sporadic. While real-time systems are often very tailored to their environment, the system must be able to process all types of tasks since all types of tasks take place in a real-time environment [10].

Real-time systems can be found extensively in all areas of our life. Some examples of applica-tions for real-time systems include nuclear plant control, flight control systems, telecommunica-tion systems, industrial automatelecommunica-tion, military systems, space missions, multimedia systems, and virtual reality [10]. Due to the nature of the applications, the correctness of a RTOS is incredi-bly important. Incorrect behavior can have catastrophic consequences. For example, missing a deadline where the wing of an airplane is not correctly positioned on time. Such a small error can have major consequences at the velocity of an airplane.

2.4 Scheduling

The term schedule commonly refers to something that is prepared ahead of time, such as the schedule of a dentist. At different times throughout the day, the dentist has appointments with different patients and has to perform different procedures. When trying to schedule an appoint-ment at the dentist, the dentist has to appoint a limited resource, time, to different patients. Scheduling in computer systems is not so different from everyday scheduling. The computer system has to share limited resources among different tasks. Those resources could be memory, CPU time, mutexes, and disk usage. One difference between everyday scheduling and computer scheduling is the notion of static and dynamic [11]. While everyday scheduling is often easily scheduled ahead of time because of its static nature, computer systems are not. For instance, a task could be idle waiting for a mutex to become available, as soon as the mutex is available the task changes its state to waiting, the schedule has to dynamically adapt to these sorts of events. Scheduling is done by a scheduling algorithm (also called a scheduling policy). There are many scheduling algorithms, for different applications. One algorithm could have a good av-erage response time, while the other algorithm provides more deterministic scheduling or less missed deadlines. Scheduling requires special attention in real-time systems due to how critical the correctness of real-time systems is. Therefore, they use different scheduling algorithms than non-real-time systems. Real-time systems have a broad application, therefore there is a variety

(11)

among those systems in the requirements of the scheduling algorithms [3]. Those algorithms use different metrics to describe the effectiveness of the scheduling. Metrics such as the number of tasks that meet their deadline, average earliness, or the level of predictability of a scheduling approach.

Earlier it is stated in literature by Doeppner and Baruah and Goossens that scheduling policies can be separated into two distinct scenarios: static priority and dynamic priority algorithms [3, 11]. Ramamritham and Stankovic further subdivide these algorithms into four classes [2]:

• Static table-driven approaches: performing static schedulability analysis and using the schedule at run time to determine when a task must begin execution.

• Static priority-driven approaches: performing static schedulability analysis concerning the priority of tasks. It does not use an explicit schedule, tasks are run with the highest priority first.

• Dynamic planning-based approaches: during run-time, an arriving task will be accepted for execution if it can meet its deadline. To perform this check, a table is used.

• Dynamic best-effort approaches: no checking is done if tasks can reach the deadline, the scheduler will do a best-effort approach to meet deadlines.

Now three scheduling policies will be described because an adaptation of the first scheduling policy is used in FreeRTOS while the other two policies are common in real-time systems [12].

Task Ci Ti

τ1 3 10

τ2 2 6

τ3 1 10

Table 2.1: This table shows a periodic task set with Ci, Ti and in milliseconds.

2.4.1

Static priority pre-emptive scheduling

The task with the highest priority is executed first. Every job is executed until completion. Tasks to be executed are popped from a first-in-first-out queue. A drawback of static priority pre-emptive scheduling is that low-priority tasks may be starved, as the higher priority tasks take the bulk of the processor time. Some static priority pre-emptive schedulers provide a time-slicing option, this is referred to as static priority round-robin scheduling. If the task is not able to complete execution in one single time-slice, it is put back in the queue. Time-slicing is used to evenly divide processor time between priority-equal tasks. Static priority round-robin scheduling is commonly used for scheduling time-shared applications, such as real-time traffic in high-speed switched networks [13]. One drawback of time-slicing is overhead resulting from switching tasks every time-slice. FreeRTOS uses a static priority pre-emptive scheduler with the option to use time-slicing, which is turned off by default.

τ1

τ2

τ3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Figure 2.1: A static priority pre-emptive scheduling approach to the task set defined in table 2.1. The priority order from highest priority to lowest priority is as follows: τ1> τ2> τ3.

(12)

2.4.2

Rate-monotonic

The rate-monotonic scheduler is a static priority-driven scheduling algorithm that is designed to schedule periodic tasks. A task τican be described with two variables; a period Tiand a capacity

Ci. A task also has a phasing Ii with 0≤ Ii < Ti, meaning that a task may be initiated at the

time Ii+ kTiwith i≥ 0 [7]. Tasks have no explicit deadline in rate monotonic scheduling (RMS).

Instead, the task must be scheduled and the computation completed before their next period arrives. The priority of each task is based on the period Ti, where the task with the shortest

period receives has the highest priority. The image below showcases a task set scheduled using rate-monotonic scheduling.

τ1

τ2

τ3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Figure 2.2: The rate-monotonic scheduling algorithm on the task set given in table 2.1. Take note that rate-monotonic scheduling uses a priority based on the shortest period.

Liu and Layland defined the processor utilization factor to be the fraction of processor time spent in the execution of the task set. The processor time for a task τi equals to Ui =CTi

i, thus

the utilization factor for a task set A with n tasks is defined as [4]:

UA= ni=1 Ci Ti

In theorem 4 of their paper; they proved that the least upper utilization bound is U = n(2n1−1),

sometimes also referred to as the Liu and Layland bound. As n → ∞, limx→∞n(2

1

n − 1) =

loge2≈ 0.6931. This shows that rate-monotonic scheduling can find a feasible schedule for any

periodic task set of any size as long as the utilization factor is not greater than 0.6931 [7]. More specifically, a feasible schedule for a given task set can be found if the following formula holds:

ni=1 Ci Ti ≤ n(21 n− 1)

It has been shown that the Liu and Layland bound is often too pessimistic. Bini and Buttazzo proposed a novel schedulability formula to verify the feasibility of large task sets under rate-monotonic scheduling. Instead of minimizing the processor utilization concerning task periods, they manipulate the feasibility condition to find a more relaxed feasibility test as a function of the individual task utilization [8]. Their formula is as follows:

n

i=1

(Ui+ 1)≤ 2

As you can see in figure 2.3, the feasibility formula by Bini and Buttazzo, also called the hy-perbolic bound, offer a more relaxed bound over the Liu and Layland bound, while still being tighter than earliest deadline first scheduling.

In 2004, Audsley et al. proposed the Response Time Analysis (RTA) exact schedulability formula. A periodic task set is schedulable with the deadline monotonic (or rate-monotonic if

Di = Ti) if and only if the worst-case response time of each task is less or equal its relative

deadline. The worst-case response time of a task can be measured with the following iterative formula [5, 14]:   Ri(0)= Ci Ri(k)= Ci+ ∑ j:Dj<DiRk−1 i TjCj

(13)

Figure 2.3: Schedulability bounds for rate-monotonic scheduling and earliest deadline first scheduling [8]

2.4.3

Earliest Deadline First

The earliest deadline first (EDF) is a dynamic priority-driven scheduling policy. In the most simplistic form of earliest deadline first scheduling, a task τi has a deadline di, a lateness li =

fi− di, where fiis the computation time of di, and all tasks are ready for execution at the same

start time. The priority of a task is related to the relative deadline of that task, so the task with the earliest upcoming deadline is executed first. Earliest deadline first scheduling can be used if the goal is to minimize the maximum lateness of all tasks [12]. The earliest deadline first algorithm can guarantee a feasible schedule as long as the utilization is not more than 1, in a formula: ni=1 Ci Ti ≤ 1

Which means the earliest deadline first scheduling can guarantee deadlines at a higher utilization load than rate-monotonic scheduling.

τ1

τ2

τ3

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

Figure 2.4: The earliest deadline first scheduling approach to the task set given in table 2.1. For this task set, RM and EDF results in the same schedule.

In 2003, Buttazzo tried to tackle the misconceptions about RM and EDF scheduling. It is com-monly believed that RM scheduling has a lower run time overhead, more predictable behavior during transient overload, and better jitter and efficiency in handling aperiodic tasks. He con-cluded that the implementation of EDF is indeed not easy and efficient on most commercial real-time kernels since they are based on a set of fixed priority levels. Most of those kernels have a small number of priority levels, generally at most 256. The dynamic nature of EDF scheduling is a problem. In the worst-case all tasks are assigned a new priority each task switch, creating an undesirable amount of overload. He also concluded, that in general, RM does not have better predictability during overload and better jitter control, while EDF does allow for full processor utilization while RM is often bound to the Liu and Layland bound or the hyperbolic bound [8].

2.5 FreeRTOS

(14)

a base kernel and optional libraries that bring extra functionality such as TPC/UDP and IO. FreeRTOS comes with extensive documentation and a big community of developers.

By default, FreeRTOS ships with a static priority pre-emptive scheduler without time-slicing. The priority of tasks must be set manually beforehand. The real-time operating system supports aperiodic tasks and periodic tasks using the vTaskDelayUntil functionality. It has no concept of deadlines, instead, it chooses tasks on priority and availability (in a ready state) only. A task can be in multiple states, the state is determined by both kernel and developer function calls. The figure below shows the states a task can have and their respective function calls.

(15)

CHAPTER 3

Implementation

3.1 FreeRTOS on the i.MX RT1020 Evaluation Kit

The NXP i.MX RT1020 EVK is an embedded board designed for industrial and smart home ap-plications, such as avionics, industrial control or to be used as a high-end smart thermostat. It features the ARM Cortex©-M7 core at 500MHz, 256 kilobytes of static random-access-memory, real-time low-latency responses as low as 20ns and it can be extended with an interface to be used wirelessly with Wi-Fi, Bluetooth, and other technologies. NXP provides support for the newest version of FreeRTOS, which is the reason why this board is chosen for this thesis.

Figure 3.1: The i.MX RT1020 Evaluation Kit by NXP [6]

Development for the board is done using the MCUXpresso IDE, which is based on Eclipse. The IDE is extended with an SDK for the development board, which includes FreeRTOS and the arm-none-eabi toolchain, which is used to compile.

3.2 Communication between FreeRTOS and host machine

UART stands for Universal asynchronous receiver-transmitter. It is used often in embedded systems and allows communication between two machines. The biggest upside of UART is that it allows for minimal overhead since all data is processed on the host machine. UART can also be implemented very minimally so communication can be made without using too much extra code, which is important in embedded systems. UART was chosen instead of ethernet because it has less overhead and is easier to program. A small overhead is important so that the

(16)

re-bridge between the GPIO pins on the development board and the USB cable to the host machine.

Figure 3.2: A USB to serial UART interface board [16]

The RX pin on the board above is connected to GPIO_AD_B0_06 (LPUART1_TX) and the TX pin is connected to GPIO_AD_B0_07 (LPUART1_RX). The interface board also needs to be supplied with 5V and the ground pin. NXP provides the necessary drivers by Freescale to send and receive via UART on FreeRTOS. Any serial terminal can be used on the host machine with the following settings:

• Baud rate: 115200 • Data: 8bits • Parity: None • Stop bits: 1

3.3 Rate-monotonic scheduling

Implementing rate-monotonic scheduling in FreeRTOS is quite simple, as the base FreeRTOS uses a static priority pre-emptive scheduler. The priorities of tasks are set manually by the developer. To turn the standard scheduler into a rate-monotonic scheduler, the priorities can be set manually so that the lower period tasks get higher priority and higher period tasks get lower priority.

3.4 Earliest deadline first

The first step to implementing the earliest deadline first algorithm would be to extend FreeRTOS to support deadlines since it has no notion of deadlines by default. To do this we append the task control block (TCB) with two variables: deadline and absolute deadline. This task control block is the context of a task, each task has its task control block. The deadline for a task must be given at task creation by the developer using task parameters. The task creation function is then altered to explicitly save the given deadline parameter in the task control block.

The prvAddTaskToReadyQueue function is called to trace the task for debugging purposes and to call a different function that places the task control block in the appropriate ready queue. When EDF scheduling is enabled, the latter function ‘vListInsertEnd‘ must be swapped for one that is aware of deadlines. This function will insert the task into the ready queue, which is sorted from the first upcoming to the last upcoming absolute deadline. The absolute deadline is computed using the deadline and a high-frequency tick timer, provided by the general-purpose timer on the development board. The same timer is used for implementing run-time statistics.

(17)

3.5 The ESFree scheduling library

ESFree is an open-source scheduling library for FreeRTOS created by Robin Kase [17]. The library is released under the GNU general public license. ESFree was created to close the gap between practical implementation of task scheduling on numerous RTOS and theoretical real-time scheduling. It features rate-monotonic scheduling, deadline-monotonic scheduling, and two implementations of earliest deadline first scheduling (a naive, and efficient implementation). The library enables the creation of periodic tasks with phasing, aperiodic tasks, and sporadic tasks. Lastly, it also adds handling of missed deadlines and handling for worst-case execution time excess.

Robin Kase provided statistics on the overhead that each of the scheduling algorithms car-ries. One of the reasons why RMS is often preferred over EDF is less overhead. Following these statistics, the default FreeRTOS priority scheduler and the RMS scheduler show a negligible difference in overhead. In contrast, the EDF Naive implementation has roughly 25 times the overhead of the FreeRTOS priority scheduler for both the non-caching and caching tests. The efficient EDF implementation has a less dramatic difference in overhead, but still roughly four times the overhead of the FreeRTOS scheduler.

FreeRTOS RMS EDF Naive EDF Efficient 30 tasks average 8 519 8 723 210 349 32 044 30 tasks average (cache) 655 676 16 520 2 627

Table 3.1: Overhead in CPU cycles for the default FreeRTOS task scheduler and numerous ESFree task scheduling algorithms on the Digilent ZedBoard [17].

The rate-monotonic algorithm and earliest deadline algorithm are implemented just for this thesis so that the difficulty of implementing both algorithms could be compared. However, the algorithms provided by the ESFree library are used for benchmarking as this library has been around for longer and is thus less likely to contain any bugs that might interfere with the benchmark results.

3.6 Run-time statistics

The ESFree library implemented an extended task control block (TCB) which includes additional information. Some of these additions include [17]:

• Release time (task’s phase) • Last wake time

• Relative deadline • Absolute deadline • Period

• Execution time counter

After a task is done executing, it enters a critical section. During this time the lateness of a task is computed. The lateness of a task τi is defined as Li= fi− di, the difference between

the finish time and the absolute deadline. Lateness is sometimes referred to as earliness if the value is negative, and tardiness if the value is positive. The scheduler also keeps track of missed deadlines and the number of aperiodic tasks scheduled and done.

This information is later processed on the host computer using Python. The mean, median and the standard deviation of the lateness is computed as those values will give more insight in

(18)
(19)

CHAPTER 4

Experiments

4.1 Task sets

Task Ci Ti τ1 2 15 τ2 10 80 τ3 20 120 τ4 5 65

Table 4.1: Task set A, with Ci and Ti in milliseconds. Every fifth execution of τ2, an aperiodic

task τ5is scheduled with C4= 10 milliseconds.

Task Ci Ti

τ1 20 60

τ2 20 65

τ3 15 95

Table 4.2: Task set B, with Ci and Ti in milliseconds. Every 30th execution of τ1, an aperiodic

τ4is scheduled with C4= 150 ms. Task Ci Ti τ1 10 60 τ2 15 60 τ3 20 100 τ4 350 1000

Table 4.3: Task set C, with Ciand Tiin milliseconds. Every second execution of τ4, an aperiodic

τ5is scheduled with C5= 200 ms.

Task Ci Ti

τ1 25 60

τ2 30 60

τ3 200 650

Table 4.4: Task set D, with Ci and Ti in milliseconds. Every tenth execution of τ1, an aperiodic

(20)

4.2 Feasibility analysis

Let’s define a boolean function f (S) to check the schedulability of a given task set S for RM and EDF scheduling. The hyperbolic bound is used to check schedulability for rate-monotonic scheduling. For checking the schedulability with earliest deadline first, it is simply checked if the total utilization is less or equal to 1.

fRM(S) = ni=1 (Ui+ 1)≤ 2 fEDF(S) = n ∑ 1 Ci Ti ≤ 1 fRM(A) = 4 ∏ i=1 (Ui+ 1)≤ 2 = ( 2 15+ 1)∗ ( 10 80+ 1)∗ ( 20 120 + 1)∗ ( 5 65+ 1)≤ 2 = 1.60 ≤ 2 fEDF(A) = 4 ∑ 1 Ci Ti ≤ 1 = 2 15+ 10 80+ 20 120+ 5 65 ≤ 1 = 0.50 ≤ 1 fRM(B) = 3 ∏ i=1 (Ui+ 1)≤ 2 = ( 25 60+ 1)∗ ( 20 65+ 1)∗ ( 15 95+ 1)≤ 2 = 2.15 ≤ 2 fEDF(B) = 3 ∑ 1 Ci Ti ≤ 1 = 25 60+ 20 65+ 15 95 ≤ 1 = 0.88 ≤ 1 fRM(C) = 4 ∏ i=1 (Ui+ 1)≤ 2 = ( 10 60+ 1)∗ ( 15 60+ 1)∗ ( 20 100 + 1)∗ ( 350 1000+ 1)≤ 2 = 2.36 ≤ 2 fEDF(C) = 4 ∑ 1 Ci Ti ≤ 1 = 10 60+ 15 60+ 20 100+ 350 1000 ≤ 1 = 0.97 ≤ 1 fRM(D) = 3 ∏ i=1 (Ui+ 1)≤ 2 = ( 25 60+ 1)∗ ( 30 60+ 1)∗ ( 200 650 + 1)≤ 2 = 2.78 ≤ 2 fEDF(D) = 3 ∑ 1 Ci Ti ≤ 1 = 25 60+ 30 60+ 200 650 ≤ 1 = 1.22 ≤ 1

Task set Feasible with RM Feasible with EDF

A 3 3

B 7 3

C 7 3

D 7 7

Table 4.5: The schedulability for each task set using the rate-monotonic scheduler and the earliest deadline first scheduler.

(21)

4.3 Benchmarking

The full results from the benchmarks can be accessed here by signing in into FNWI’s GitLab.

4.3.1

Task set A

The mean, median and standard deviation of the lateness for RM and EDF scheduling. Task Mean Median SD Max

τ1 -15.000 -15 0 -15

τ2 -75.000 -75 0 -75

τ3 -102.469 -100 2.515 -100

τ4 -65.000 -65 0 -65

Table 4.6: Rate-monotonic

Task Mean Median SD Max

τ1 -15.000 -15 0 -15

τ2 -75.000 -75 0 -75

τ3 -102.469 -100 2.515 -100

τ4 -65.000 -65 0 -65

Table 4.7: Earliest deadline first

The total execution time of the task set is 9705 milliseconds. According to the timing error detection service, neither scheduling algorithm missed deadlines. They were both able to fit 22 out of 22 aperiodic tasks during execution time.

4.3.2

Task set B

The mean, median and standard deviation of the lateness for RM and EDF scheduling. Task Mean Median SD Max

τ1 -40.000 -40 0.000 -40

τ2 -42.050 -40 7.788 -30

τ3 -70.061 -70 11.958 -50

Table 4.8: Rate-monotonic

Task Mean Median SD Max

τ1 -39.617 -40 1,331 -35

τ2 -44.958 -50 6.816 -30

τ3 -69.737 -70 12.090 -50

Table 4.9: Earliest deadline first

The total execution time of the task set is 23495 milliseconds. Neither algorithm missed any deadlines and they were both able to fit in 13 out of 14 scheduled aperiodic tasks.

4.3.3

Task set C

The mean, median and standard deviation of the lateness for RM and EDF scheduling. Task Mean Median SD Max

τ1 -55.000 -55 0.000 -55

τ2 -45.000 -45 0.000 -45

τ3 -79.978 -85 7.094 -70

τ4 -625.000 -625 0.000 -625

Table 4.10: Rate-monotonic

Task Mean Median SD Max

τ1 -50.013 -55 5.007 -45

τ2 -47.493 -45 2.503 -45

τ3 -79.978 -85 7.094 -70

τ4 -625.000 -625 0.000 -625

Table 4.11: Earliest deadline first

They were both able to fit in 10 out of 10 scheduled aperiodic tasks and neither algorithm missed deadlines. The rate-monotonic scheduler executed all 1000 tasks with a total execution time of 22625 milliseconds, and the earliest deadline first scheduler executed the same amount in 22630 milliseconds.

(22)

4.3.4

Task set D

The mean, median and standard deviation of the lateness for RM and EDF scheduling. Task Mean Median SD Max

τ1 -25.560 -20 11.951 -15

τ2 -23.465 -15 9.506 -15

τ3 -32.778 -65 288.653 470

Table 4.12: Rate-monotonic

Task Mean Median SD Max

τ1 -22.167 -15 29.370 220

τ2 -19.302 -15 30.784 245

τ3 -137.000 -210 364.563 1775

Table 4.13: Earliest deadline first

According to the timing error detection service provided by the scheduler, rate-monotonic missed eight deadlines, and earliest deadline first scheduler missed 69 deadlines. The rate-monotonic scheduler was able to fit 144 out of 146 aperiodic tasks and performed all 1000 peri-odic tasks with a total execution time of 28940 milliseconds. The earliest deadline first scheduler executed all 1000 periodic tasks in 29880 milliseconds and was able to fit 143 out of 145 scheduled aperiodic tasks.

(23)
(24)
(25)

CHAPTER 5

Conclusions

The benchmarks show that both rate-monotonic scheduling and earliest deadline first scheduling were able to schedule task set A, B, and C without missing any deadlines. This contradicts the feasibility analysis, which predicted that rate-monotonic scheduling will only be able to feasibly schedule task set A. This contradicts the hypothesis which was based on the hyperbolic bound and the EDF bound. The benchmarks show that the theoretical bounds do not always corre-spond to the actual scheduling bound.

The other goal of this thesis was to validate the common beliefs which Buttazzo tried to tackle. The first common belief is that RM is easier to implement. Implementing these algorithms on FreeRTOS has shown that to be true. The operating system is based on a static priority sched-uler, therefore implementing the static priority rate-monotonic scheduler was straightforward. Implementing the dynamic earliest deadline first scheduler was inefficient due to manyO(n) list

operations each tick, as opposed to the rate-monotonic scheduler, that used a O(1) list access

operation. A conclusion can be made which aligns with Buttazzo’s conclusion, that RM is in-deed easier to implement. The next common belief is that RM introduces less run-time overhead. This statement became apparent during the implementation of the algorithms but was quantified with the results of Kase, who showed that the ESFree rate-monotonic scheduler indeed had a lower run-time overhead than the ESFree earliest deadline first scheduler [17]. However, the total execution time of task sets A and B did not differ using both scheduling algorithms. For task set C, the rate-monotonic scheduler finished executing 5 milliseconds shy of the earliest deadline scheduler, and for task set D the EDF scheduler finished 60 ms shy of the RM scheduler. It can be concluded that the higher run-time overhead of earliest deadline first scheduling is negligible and does not make a notable impact on the total execution time.

Another belief is that rate-monotonic scheduling provides more predictable behavior during overload than earliest deadline first scheduling. Results from benchmarking the overloaded task set D have shown that the lateness of tasks τ1, τ2 and τ3 had a standard deviation of 11.951,

9.506 and 288.653 when scheduled by the rate-monotonic scheduler, and 29.370, 30.784 and 364.563 when scheduled by the earliest deadline first scheduler. This spread of lateness is visible in figures 4.1 and 4.2. These results show that rate-monotonic scheduling indeed has more predictable behavior during overload. It should be noted however that the standard deviation of τ3 was heavily influenced by one outlier of τ3 in particular, with a lateness value of 1775.

The standard deviation of the lateness of τ3 becomes 194.250 if this outlier is disregarded. It

can be concluded that the rate-monotonic scheduler provides more predictable behavior during overload, only for the highest priority tasks, which aligns with the statement Buttazzo made in his 2003 paper.

(26)

5.1 Discussion

The benchmarks show that the theoretical bounds do not always correspond to the actual schedul-ing bound. This outcome might be because of inaccuracies in the simulated capacity time of a task, which is based on the tick time of a task. Each task is given a worst possible execution time, which corresponds with the capacity Ci for a task. The scheduler pre-empts the current

task if it exceeds the worst possible execution time. To achieve capacity times that are close to the worst possible execution time, a millisecond is subtracted from the total simulated capacity time. Tests have shown that for some tasks this results in 5 milliseconds less capacity time. Due to those inaccuracies, the actual utilization value of a task set might be lower than the calculated bound, which could be a possible explanation of why the rate-monotonic scheduler feasibly scheduled task sets above its hyperbolic bound.

5.2 Future research

For future tests, it might be necessary to lower the inaccuracy in the calculated capacity time. This could be done using a hardware timer, such as the general-purpose timer on the I.MX NXP RT1020. The timer could be set to use a higher frequency than the FreeRTOS tick, causing fewer inaccuracies. Also, it is hard to draw a strong conclusion by testing only five task sets. It will be better to automate the benchmarking process. This way a high number of computer-generated task sets with an increasing utilization value can be tested and a conclusion can be drawn based on more data.

(27)

Bibliography

[1] L. S. Alger and J. H. Lala, “Real time operating system for a nuclear power plant com-puter,” Tech. Rep., 1986.

[2] K. Ramamritham and J. A. Stankovic, “Scheduling algorithms and operating systems sup-port for real-time systems,” Proceedings of the IEEE, vol. 82, no. 1, pp. 55–67, 1994. [3] S. Baruah and J. Goossens, “Scheduling real-time tasks: Algorithms and complexity,”

Handbook of scheduling: Algorithms, models, and performance analysis, vol. 3, 2004.

[4] C. L. Liu and J. W. Layland, “Scheduling algorithms for multiprogramming in a hard-real-time environment,” Journal of the ACM (JACM), vol. 20, no. 1, pp. 46–61, 1973.

[5] G. C. Buttazzo, “Rate monotonic vs. edf: Judgment day,” in International Workshop on

Embedded Software, Springer, 2003, pp. 67–83.

[6] NXP, Mimxrt1020-evk: I.mx rt1020 evaluation kit, 2018. [Online]. Available: https : / / www . nxp . com / design / development boards / i mx evaluation and development -boards/i-mx-rt1020-evaluation-kit:MIMXRT1020-EVK.

[7] J. Lehoczky, L. Sha, and Y. Ding, “The rate monotonic scheduling algorithm: Exact char-acterization and average case behavior,” in RTSS, vol. 89, 1989, pp. 166–171.

[8] E. Bini, G. C. Buttazzo, and G. M. Buttazzo, “Rate monotonic analysis: The hyperbolic bound,” IEEE Transactions on Computers, vol. 52, no. 7, pp. 933–942, 2003.

[9] J. A. Stankovic, “Misconceptions about real-time computing: A serious problem for next-generation systems,” Computer, vol. 21, no. 10, pp. 10–19, 1988.

[10] G. C. Buttazzo, Hard Real-Time Computing Systems: Predictable Scheduling Algorithms

and Applications, 3rd ed. 233 Spring Street, New York, NY 10013, USA: Springer, Sep.

2011, isbn: 978-1461406754.

[11] T. W. Doeppner, Operating systems in depth, 1st ed. John Wiley & Sons Inc, Nov. 2010, isbn: 978-0471687238.

[12] J. A. Stankovic, M. Spuri, K. Ramamritham, and G. C. Buttazzo, Deadline scheduling for

real-time systems: EDF and related algorithms. Springer Science & Business Media, 2012,

vol. 460.

[13] J. W. S. Liu, Real-Time Systems, 1. Prentice Hall, 2000.

[14] N. Audsley, A. Burns, M. Richardson, K. Tindell, and A. J. Wellings, “Applying new scheduling theory to static priority pre-emptive scheduling,” Software engineering journal, vol. 8, no. 5, pp. 284–292, 1993.

[15] R. T. E. Ltd., The freertos kernel: Market leading, de facto standard, and cross platform

rtos kernel, 2020. [Online]. Available: https://www.freertos.org/RTOS.html.

[16] K. Ltd, Usb to serial uart ftdi interface board for your atmel avr or microchip pic project, 2020. [Online]. Available: https://sigma-shop.com/product/1/usb-to-serial-uart-ftdi-interface-board-for-your-atmel-avr-or-microchip-pic-project.html. [17] R. Kase, Efficient scheduling library for freertos, 2016.

Referenties

GERELATEERDE DOCUMENTEN

In 2005 zijn de opbrengstprijzen voor zowel verse champignons als industriechampignons opnieuw lager dan in het jaar

When comparing accident densities for these road categories, it is important to keep in mind the difference between traffic function and intensity. Curiously

strain Design Method has been designed by a Reunion Internationale des Laboratoires d'Essais et de Recherches sur les Materiaux et les Constructions (RILEM) committee

Het merendeel van de archeologische sporen vondsten werd aangetroffen in de sleuven op perceel 932. Deze overblijfselen konden in de meeste gevallen gedateerd worden in de

Pharmacokinetic study Xhosa consent form:Version 2 BMS: Khusela Ixesha Elizayo INtlangano yamaQumrhu oPhando ngesifo sephepha TB ne-HIV ebantwaneni IYunivesithi yaseKapa /

Uit gesprekken met zorgprofessionals blijkt dat seksualiteit in de ouderenzorg nog maar nauwelijks erkend wordt als een belangrijk thema, terwijl uit onderzoek blijkt dat

The first step on the homotopy path for qpOASES takes approximately 10 ms. If no constraint is active, the optimal solution is found immediately. If a constraint is active, maximum

Forest site classification and evaluation has been used with success in the South African forestry industry, with a long history of research and technological development..