中国科学技术大学学报 ›› 2017, Vol. 47 ›› Issue (8): 635-643.DOI: 10.3969/j.issn.0253-2778.2017.08.002

• 论著 • 上一篇    下一篇

一种Linux用户态实时多任务调度框架

张旭,顾乃杰,苏俊杰,   

  1. 1. 中国科学技术大学计算机科学与技术学院,安徽合肥 230027;2. 安徽省计算与通信软件重点实验室,安徽合肥 230027;
    3.中国科学技术大学先进技术研究院,安徽合肥 230027
  • 收稿日期:2016-09-11 修回日期:2017-04-11 出版日期:2017-08-31 发布日期:2017-08-31
  • 通讯作者: 顾乃杰
  • 作者简介:张旭,男,1990年生,博士研究生.研究方向:计算机网络协议设计、网络服务操作系统优化. E-mail: jessexz@mail.ustc.edu.cn

A real-time multi-task scheduling framework in Linux user space

ZHANG Xu, GU Naijie, SU Junjie,   

  1. 1. School of Computer Science and Technology, University of Science and Technology of China, Hefei 230027, China;
    2.Anhui Province Key Laboratory of Computing and Communication Software, Hefei 230027, China;
    3. Institute of Advanced Technology, University of Science and Technology of China, Hefei 230027, China
  • Received:2016-09-11 Revised:2017-04-11 Online:2017-08-31 Published:2017-08-31

摘要: Linux内核调度器的调度开销巨大,无法满足实时应用需求.为此设计并实现了基于多核Linux的用户态实时多任务调度框架ULight.ULight共包括三个核心模块:多任务调度模块、定时器模块以及用户态中断处理模块.多任务调度模块在Linux 用户态提供基于优先级可抢占的实时多任务调度方案,旨在减少任务调度和切换开销;定时器模块则为多任务调度提供高精度的定时服务,以支持分时调度和任务休眠,并提供更多的抢占点;用户态中断处理模块通过在内核态和用户态之间构造中断处理的快速通道,使用户态任务可以直接处理硬件中断,保证中断处理的实时性和高效性.实验表明,ULight的任务切换效率明显优于Linux的线程切换效率;定时系统可以提供精度为20 μs的稳定的定时服务;用户态中断处理模块能够在用户态完成对硬件中断的快速响应.

关键词: 多任务调度, 实时性, 高精度定时器, 用户态中断处理

Abstract: Task scheduling in Linux kernel has tremendous overhead, and thus cannot fulfill the requirement of real-time applications. ULight, a real-time multi-task scheduling framework running in Linux user space was proposed to conquer this problem. ULight consists of three core modules: multi-task scheduling module, timer module and user-mode interrupt handling module. The multi-task scheduling module provides priority-based preemptive scheduling in Linux user space to reduce the overhead of task switch and scheduling; the timer module introduces a high-resolution timer system to support time-sharing scheduling, enable task sleep and increase preemption points; the user-mode interrupt handling module builds up an channel between kernel and user space, which enables user-mode threads to handle interrupts directly and efficiently in Linux user space. The experiment results show that, ULight brings much less overhead than Linux Pthread in terms of task scheduling; and keeps the precision of the timer stable within 20 μs; and can response to interrupts rapidly in user space.

Key words: user-mode task scheduling, real-time, high-resolution timer, user-mode interrupt handling

中图分类号: