优先级继承运用于Linux内核信号量的研究与实现.pdfVIP

  • 4
  • 0
  • 约1.89万字
  • 约 6页
  • 2015-10-16 发布于重庆
  • 举报

优先级继承运用于Linux内核信号量的研究与实现.pdf

优先级继承运用于Linux内核信号量的研究与实现

2010 年 第 19 卷 第 11 期 计 算 机 系 统 应 用 优先级继承运用于Linux 内核信号量的 研究与实现① 王亚军 ( 中国人民武装警察部队学院 河北 廊坊 065000) 摘 要: 运用优先级继承协议解决 Linux 内核信号量操作中存在的优先级倒转问题,是将 Linux 运用于实时系 统的重要手段。在具体分析 Linux 内核信号量操作源代码的基础上,针对优先级倒转问题修改内核实 现基本优先级继承协议,并在 PCM-3350 嵌入式计算机系统上测试通过。 关键词: 优先级倒转; 优先级继承; 信号量; 实时性; 嵌入式系统 Research and Realization of Priority Inheritance Applied in Linux Kernel Semaphore WANG Ya-Jun (Chinese People’s Armed Police Forces Academy, Langfang 065000, China) Abstract: It is very important to solve the problem of priority inversion by means of priority inheritance when applying Linux in real-time embedded system. Based on the analysis of the Linux source codes about kernel semaphore operation, this paper realizes the base priority inheritance protocol by modifying the Linux kernel, and passes the test on the embedded system of PCM-3350. Keywords: priority inversion; priority inheritance; semaphore; real-time; embedded system 1 引言 为内核信号量提供了几组不同的 P 和 V 操作函数,其 为了避免多个进程同时进入临界区,Linux 内核 中以 down()和 up()函数最有代表性。down()和 up() 采取了严格的同步机制,信号量就是其中之一。如果 函数是在 include/ asm-i386/ semaphore.h 文件 一个进程试图获得一个已经被占用的内核信号量,该 中 定 义 的 , 函 数 头 如 下 : static inline void 进程就会被推进一个等待队列进入“睡眠”状态,从 down(struct semaphore * sem) static inline 而释放处理器,使处理器可以执行其它进程的代码。 void up(struct semaphore * sem) 当持有信号量的进程释放信号量以后,在等待队列中 其中 down()操作先使 sem-count 减 1,减后 睡眠的进程将被唤醒,并再次试图获得该信号量以进 的结果若为非负数,表明当前进程可以进入临界区, 入临界区[1]。下面以 Linux-2.6.10 内核为例,在分 则 down()操作结束;减后的结果若为负数,表明进程 析内核信号量操作源代码的基础上,基于实时应用实

文档评论(0)

1亿VIP精品文档

相关文档