Active Vibration Control in Mechanical SystemsView this Special Issue
Research Article | Open Access
An Improved Task Scheduling Algorithm for Intelligent Control in Tiny Mechanical System
Wireless sensor network (WSN) has been already widely used in many fields in terms of industry, agriculture, and military, and so forth. The basic composition is WSN nodes that are capable of performing processing, gathering information, and communicating with other connected nodes in the network. The main components of a WSN node are microcontroller, transceiver, and some sensors. Undoubtedly, it also can be added with some actuators to form a tiny mechanical system. Under this case, the existence of task preemption while executing operating system will not only cost more energy for WSN nodes themselves, but also bring unacceptable system states caused by vibrations. However for these nodes, task I/O delays are inevitable due to the existence of task preemption, which will bring extra overhead for the whole system, and even bring unacceptable system states caused by vibrations. This paper mainly considers the earliest deadline first (EDF) task preemption algorithm executed in WSN OS and proposes an improved task preemption algorithm so as to lower the preemption overhead and I/O delay and then improve the system performance. The experimental results show that the improved task preemption algorithm can reduce the I/O delay effectively, so the real-time processing ability of the system is enhanced.
WSN consists of spatially distributed autonomous sensors to monitor physical or environmental conditions, such as temperature, sound, and pressure. These WSN nodes cooperatively pass their data through the network to a main location. Energy issue and system performance of WSN have always been considered because WSN nodes always work in some harsh environment. Energy is the scarcest resource for WSN nodes, and it finally determines the lifetime of WSNs. Energy consumption of the sensor nodes should be minimized since their limited energy resource determines their lifetime . For the WSN OS used in some practical application of connecting some actuators, the task preemption will inevitably bring I/O delay and even unacceptable system states caused by the vibrations . Nowadays, while WSN nodes formed a tiny mechanical system by adding actuators, how to decrease the system extra overhead and improve the system performance caused by the vibrations becomes very important.
Currently, there are many researches about improving system performance for WSN nodes; for example,  used error and kernel density approach of sleeping nodes in cluster-based WSNs;  used low energy online self-test of embedded processor in dependable WSN nodes. Reference  studied low-energy symmetric key distribution in WSN;  used a dynamic programming approach for QoS-aware power management in wireless video sensor. Reference  used virtual backbone scheduling to maximize the lifetime of WSNs. Reference  used hybrid-storage units to extend runtime of low-power WSN nodes. Reference  studied distributed tracking with energy management in wireless sensor networks. Reference  used joint routing and sleep scheduling to maximize lifetime of WSN. Thus it can be seen that most solutions are implemented by the way of utilizing extra resources. But the innovation for this paper is to improve the lifetime of WSN nodes in terms of real-time operating system itself and the task scheduling algorithm to be exact. The decrease of system overhead and the improvement of system performance are implemented by reducing the overhead of task preemptions. The most important is that this method can be combined with all of the others to achieve better system performance in tiny mechanical system composed of WSN nodes, as this improvement is focused on the real-time operating system itself.
2. EDF Task Scheduling Analysis
Compared with fixed priority task scheduling algorithm, dynamic priority algorithm allocates different priorities to every period task, so the task priority is constantly changing. EDF task scheduling algorithm has already been widely used as a classic dynamic priority scheduling algorithm in WSN .
EDF task scheduling algorithm assigns tasks with different priority according to execution deadline of task, the earlier task execution deadline, and the higher task priority. In a word, system allocates the highest priority to task having the earliest task execution.
2.1. Judging Whether the System Is Schedulable
Supposing that system has independent and preemptive period tasks (). , , and represent the execution time, relative deadline, and period of task , respectively. The sufficient condition for EDF task scheduling algorithm in single processor is given by
While task () has max block time , the above sufficient condition will be expressed as
If this formula can be met for all tasks, the system is regarded as schedulable. The all below discussions are all based on formula (2).
2.2. Task Preemption Optimization about EDF Task Scheduling Algorithm
Use the attribute set to describe a period task, where is the period of task and is the execution time of the task, while using to describe one specific job in a task, which means that the task has jobs totally. For example, supposing that there are three jobs in the task , the first one is , the second one is , and the last one is .
Suppose that there are three period tasks (2, 0.8), (3, 0.4), and (5, 2.1) in the single processor system. For these three tasks, their super period is 30.
As Figure 1(a) shows, task , , and are all released at time 0, but their execution deadline is 2, 3, and 5, so task has the highest priority and it begins to run firstly. At time 0.8, task begins to run as it has higher priority than task . Till time 1.2, task begins to run. While at time 2, task is released again, task is preempted by task then. Figure 1(a) shows the whole execution case before optimization for these three tasks during the time period .
Figure 1(a) shows that the beginning time for jobs on task , , and is , , and , respectively. We can see from the results that the jobs of task are preempted 4 times totally, and each time point of preemption is shown as in Figure 1(a).
Figure 1(b) shows the execution case after optimization during the time period ; the beginning time for jobs of tasks , , and becomes , , and , respectively. Under this case, task is preempted 2 times totally, and in the meanwhile, task and do not exceed their deadline. This is implemented by postponing the execution of some jobs for task and , which means that nonpreemptive scopes are added for some jobs in task , and the below discussion will describe the process of implementation in detail.
2.3. Extra Overhead Caused by Task Preemption
is a task preemptive set, which describes that task is executed times totally. The number of elements for is signed as , which means the times that task is preempted totally, so the total amount for all these tasks are given by
If a low priority task is preempted by another one, then the extra cost for the preemption is . While there is no preemption exists and then the extra cost is , for any task, no matter whether it is preempted, the total extra cost for the system is .
If the phase position is for the real-time task set , the extra overhead caused by task preemption during the time period is described as
So we can know that the task preemption will bring extra overhead for the whole system. As saving energy is very important for WSN nodes that formed a tiny mechanism system, how to reduce the task preemption becomes very necessary.
3. Analysis of I/O Delay for EDF Task Scheduling
3.1. Analysis of I/O Delay Caused by Task Preemption
Supposing that allocated preemptive threshold equals and ignoring the restrain of preemptive threshold time, then according to the analysis of time requirement, the max I/O delay for preemptive task scheduling of is given by where is the release time of job; then, can be calculated by
While , the above iterative calculation will end.
For task , while the release time of its one job is , the job load of higher priority can be represented as
A preemptive threshold () is assigned to task , and the I/O delay should be calculated by the preemptive part and nonpreemptive part, respectively, as below .
The max I/O delay of preemptive part for task is given by where is the max value of formula (9), and it can be calculated by the initialization value .
The max I/O delay of nonpreemptive part for task is represented as
so the max I/O delay for task based on EDF scheduling algorithm is described as
While , then
Under this case, the I/O delay is a constant value, and it is irrelevant to task attribute.
From the above formulas, we can know that is the main factor for , and the next section will describe how to assign for jobs.
3.2. Improved Task Preemption Scheduling Algorithm
In the EDF task scheduling algorithm, task is indexed by the relative time slice. For task , the bigger the index, the bigger relative time slice. So only the task with big relative time slice can block the task with smaller one and the time requirement of preemptive part for task having below restriction of preemptive time threshold . Consider
The max execution time of nonpreemptive part is for task , so the necessary condition that task can be schedulable is there is existing , which meets the below formula:
as is the detecting set, and it is given by where , and it meets the following formula:
The necessary and sufficient condition for EDF task scheduling is described as
Then can be calculated by
To make the task schedulable, the min value of is given by So to make all tasks schedulable, the min value of is represented as
From the above analyses, system allocates the to the task that has the smallest relative deadline. The value of other jobs will also be allocated by formula (21).
The system obtains block time for every task and calculates threshold of tasks whose relative time slices are larger than according to and then allocates threshold to task by Algorithm 1.
which corresponds to task release time. If several tasks are released at the same time, then the system uses the task TID having the highest priority.
At any given time , is used to express the time difference between system supplying and finishing the all jobs whose priority is no less than job during time period .
For any one task set based on EDF task scheduling algorithm, system can calculate the amount of task preemption by task attribute during the time period according to Algorithm 2.
The above algorithms describe the implementation of postponing the execution of some jobs for some tasks; at the meanwhile, nonpreemptive scope is added for some jobs in others tasks, and the below discussion will describe the experiments about the performance test.
4. Experimental Platform
In order to test the performance of the improved task scheduling algorithm, we used the hardware platform of Webit&NEU  and its operating system Webit&NEU OS which were implemented by our China Liaoning Province Embedded Technique Key Laboratory.
4.1. Hardware Platform
Webit&NEU (Atmega128L Processor) uses the basic structure of Webit2.0. It can collect and handle the data collected from the CC2520 and store the core data to data memory.
Webit2.0 (AT90S8515 Processor) is an embedded Internet device that has implemented the function about making the standard industry device that can access the Internet. Webit2.0 has successfully been developed by our China Liaoning Province Embedded Technique Key Laboratory and has been manufactured by our China Shenyang Neu-Era Information Technology Stock CO., LTD. The most important is that Webit2.0 has also achieved the China’s product patent (numbers ZL 00 2 52482.1 and ZL 01 2 29725.9) .
4.2. Software Platform
A real-time operating system must have the ability to respond to external events fast. In order to coordinate and execute tasks effectively, Webit&NEU OS system provides the following services: interrupt handlers, intertask communication facilities, task synchronization, internal memory management, timing services, task priority assignment, and so on as Table 1 shows [15, 16]. Webit&NEU OS supports up to 16 tasks, which is committed to achieve low cost application in the IoT. These tasks have 8 different priorities of 0–7. The bigger the value, and higher the priority.
All of these functions implemented by the unique design of system call can easily execute real-time applications. System call is a program supported to user by operating system, while users need to implement certain system function; then, what they need to do is to call the accordingly system call in the application program; thus, it is very convenient for users to use the system kernel.
All the system calls are written in AVR assembly language. One of the important advantage for AVR assembly language is that it can flexibly and easily manage a certain storage location in memory, even its certain bit of the storage location, so system can effectively handle task, interruption, message, timing, and so on.
All of these functions can easily implement real-time applications, so the Webit&NEU OS system can well be used to effectively manage data collection, wireless communication in the field of WSN, and it has successfully been developed by our China Liaoning Province Embedded Technique Key Laboratory.
5. Performance Analysis of Improved EDF Scheduling Algorithm
For system load , the system generates 18 period task sets totally, and each set includes 6 period tasks generated at random. Table 2 shows the case of task preemption comparison before and after algorithm optimization.
From the experimental results, we can know that the optimization scope ranges from 50.0% to 33.3%; with the increase of system load, the preemption optimization rate decreases correspondingly, which means that system can get better optimization while system load is lower [17–19].
We used the tools of logic analyzer (TLA603), arbitrary waveform generator (AWG2021), and digital storage oscilloscope (TDS1012). In the test programs, we added some control codes by transforming the value of high and low levels of pulses through I/O pin while task is preempted.
The I/O pin of Webit&NEU is connected to the digital storage oscilloscope (TDS1012). While there are the task preemptions happening, the system will alter the current value of pulses when certain task is about to be preempted; accordingly, the system will also change the current value of pulses again while the preempted task begins to execute again. So from the waveform of the experimental results in the digital storage oscilloscope, we can obtain the whole time for the whole process. Besides, we can also get the whole execution time of the preemption task . So I/O delay time can be calculated by .
Under the case of different system load, we obtained the I/O delay according to the above method, and the experimental results are shown in Figure 2.
As Figure 2 shows, while the system load is 0.05, system can achieve the best optimization rate of 50.8%; however, even the system load is 0.9 and the optimization rate can still reach 31.6%. Obviously, the proposed improved task scheduling algorithm can well decrease the I/O delay for the real-time operating system. The system I/O delay is obviously reduced because of the decrease of task preemption, which also means that the system overhead is also reduced. Consequently system real-time ability is enhanced, and at the meanwhile, energy consumption is also obviously decreased .
Table 3 shows the system kernel code size of Webit5.0 OS (the fifth version operation system for Webit2.0), Webit&NEU OS, and μC/OS-II separately. Because Webit&NEU OS supports only up to 16 tasks, it is committed to low cost application in the IoT, so its kernel code size is smaller than μC/OS-II who manages up to 64 tasks. This is just the design goal of light-weight operating systems for Webit&NEU OS.
As the code memory of Atmega128L is 128 KB, the code size of Webit&NEU OS with improved algorithm (4.031 KB) is 4.34% larger than Webit&NEU OS’s (3.856 KB); its size only occupies 3.15% of the whole code memory, so it still leaves enough space for user applications.
Compared with other current common solutions to increase the lifetime of WSN nodes, this paper aims to improve the lifetime and system performance by optimizing task scheduling algorithm when WSN nodes are applied to actuator applications. On the premise that these jobs can be executed within their execution deadline, system postpones executing some jobs to ensure that more jobs can better be executed, which can reduce task preemption greatly. By executing the improved task scheduling algorithm in the platform of Webit&NEU and Webit&NEU OS both designed and implemented by our laboratory, the experimental results show that the system I/O delay and overhead are decreased effectively and the occurrences of unacceptable system states caused by vibrations are also reduced, due to the reduction of task preemption in tiny mechanical system composed of WSN nodes.
Conflict of Interests
The authors declare that there is no conflict of interests regarding the publication of this paper.
This work is partly supported by National Natural Science Foundation of China (no. 61101121), National High Technology Research and Development Program (863 Program) (no. 2013AA102505), Key Laboratory Project Funds of Shenyang Ligong University under Grant (no. 4771004kfs03), and Educational Committee of Liaoning Province Science and Technology Research Projects under Grant (no. L2013096). The authors thank Jan Vitek, Ales Plsek, and Lei Zhao for their help during their studying at Purdue University in USA from September 2010 to September 2012. They also thank the anonymous reviewers for their valuable comments.
- W. Sun, H. Gao, and B. Yao, “Adaptive robust vibration control of full-car active suspensions with electro-hydraulic actuators,” IEEE Transactions on Control Systems Technology, vol. 21, no. 6, pp. 2417–2422, 2013.
- M. Peng, Y. Xiao, and P. P. Wang, “Error analysis and kernel density approach of scheduling sleeping nodes in cluster-based wireless sensor networks,” IEEE Transactions on Vehicular Technology, vol. 58, no. 9, pp. 5105–5114, 2009.
- A. Merentitis, N. Kranitis, A. Paschalis, and D. Gizopoulos, “Low energy online self-test of embedded processors in dependable WSN nodes,” IEEE Transactions on Dependable and Secure Computing, vol. 9, no. 1, pp. 86–100, 2012.
- K. McCusker and N. E. O'Connor, “Low-energy symmetric key distribution in wireless sensor networks,” IEEE Transactions on Dependable and Secure Computing, vol. 8, no. 3, pp. 363–376, 2011.
- A. Fallahi and E. Hossain, “A dynamic programming approach for QoS-aware power management in wireless video sensor networks,” IEEE Transactions on Vehicular Technology, vol. 58, no. 2, pp. 843–854, 2009.
- Y. Zhao, J. Wu, F. Li, and S. Lu, “On maximizing the lifetime of wireless sensor networks using virtual backbone scheduling,” IEEE Transactions on Parallel and Distributed Systems, vol. 23, no. 8, pp. 1528–1535, 2012.
- M. T. Penella and M. Gasulla, “Runtime extension of low-power wireless sensor nodes using hybrid-storage units,” IEEE Transactions on Instrumentation and Measurement, vol. 59, no. 4, pp. 857–865, 2010.
- N. Roseveare and B. Natarajan, “Distributed tracking with energy management in wireless sensor networks,” IEEE Transactions on Aerospace and Electronic Systems, vol. 48, no. 4, pp. 3494–3511, 2012.
- F. Liu, C.-Y. Tsui, and Y. J. Zhang, “Joint routing and sleep scheduling for lifetime maximization of wireless sensor networks,” IEEE Transactions on Wireless Communications, vol. 9, no. 7, pp. 2258–2267, 2010.
- J. W. S. Liu, Real-Time Systems, Higher Education Press, Beijing, China, 2003.
- W. Sun, Y. Zhao, J. Li, L. Zhang, and H. Gao, “Active suspension control with frequency band constraints and actuator input delay,” IEEE Transactions on Industrial Electronics, vol. 59, no. 1, pp. 530–537, 2012.
- J. Wang, H. Zhao, J. Xu, and Y. Bi, “Webit&NEU: an embedded device for the Internet of things,” International Journal of Distributed Sensor Networks, vol. 2014, Article ID 839540, 10 pages, 2014.
- Z. Hai and C. Yan, Pervasive Computing, Northeastern University Press, Shenyang, China, 2005.
- Intel Corporation, “iRMX 51 DISTRIBUTED CONTROL EXECUTIVE USER’S GUIDE for Release 2.0,” Intel Corporation, 1987.
- J. Wang, H. Zhao, P. Li, H. Li, and B. Li, “Analysis and comparison of five kinds of typical device-level embedded operating systems,” Journal of Software Engineering and Applications, vol. 3, no. 1, pp. 81–90, 2010.
- W. Sun, Z. Zhao, and H. Gao, “Saturated adaptive robust control for active suspension systems,” IEEE Transactions on Industrial Electronics, vol. 60, no. 9, pp. 3889–3896, 2013.
- W. Sun, H. Gao, and O. Kaynak, “Adaptive backstepping control for active suspension systems with hard constraints,” IEEE Transactions on Mechatronics, vol. 18, no. 3, pp. 1072–1079, 2013.
- W. Sun, H. Gao Sr., and O. Kaynak, “Finite frequency control for vehicle active suspension systems,” IEEE Transactions on Control Systems Technology, vol. 19, no. 2, pp. 416–422, 2011.
- R. Majumder, G. Bag, and K.-H. Kim, “Power sharing and control in distributed generation with wireless sensor networks,” IEEE Transactions on Smart Grid, vol. 3, no. 2, pp. 618–634, 2012.
Copyright © 2014 Jialiang Wang et al. This is an open access article distributed under the Creative Commons Attribution License, which permits unrestricted use, distribution, and reproduction in any medium, provided the original work is properly cited.