计算机与现代化

• 应用与开发 • 上一篇    下一篇

临界区机制剖析与自定义实现

  

  1.  
    (西北工业大学计算机学院,陕西 西安 710072
  • 收稿日期:2013-10-12 出版日期:2014-02-14 发布日期:2014-02-14
  • 作者简介:石效存(1982-),男,陕西西安人,西北工业大学计算机学院硕士研究生,研究方向:实时操作系统的改造; 张鑫诚(1989-),男,陕西兴平人,硕士研究生,研究方向:分布式计算与虚拟试验支撑环境。

 
Critical Section Mechanism Analysis and Custom Implementation

  1.  
    (School of Computer Science, Northwestern Polytechnical University, Xi’an 710072, China)
  • Received:2013-10-12 Online:2014-02-14 Published:2014-02-14

摘要: 在Windows操作系统扩展过程中,由于自定义调度需要自定义的线程同步,因此需要定制同步机制。经过剖析原有临界区的实现机制,设计实现了自定义临界区。在自定义临界区中,利用内核驱动程序提供调度;用无符号整数原子操作,保证内核对象操作原子性;应用内存映射机制将内核对象地址映射为用户态地址,使得操作可在用户态完成从而提高操作效率。实验结果表明,自定义的临界区可以实现线程同步。

关键词: 临界区, 内存映射, 原子操作, 优先级

Abstract: In the process of Windows operating system extended, because using the custom scheduling, it required custom synchronization of threads, we need to customize synchronization mechanism. After analyzing the original implementation mechanism of critical section, we design a custom critical section. In the custom critical section design, we provide scheduling by using kernel driver development. Atomic operation of unsigned integer is used to guarantee the kernel object atomic operation. Memory mapping mechanism is applied to make kernel object address mapping for the user address, so that the operation can be completed in user mode and raise the operation efficiency. The experimental results show that the custom critical section can achieve the synchronization of threads.

Key words: critical section, memory-mapped, atomic operation, priority

中图分类号: