WinCE 线程技术在多参数监护仪软件设计中的应用

作者: 王虎寅   发布日期:2006-10-20 17:01   查看数:0
中文摘要:

  由于多参数监护仪系统实时性要求较高、任务较复杂, 给设计工作带来一定的困难。在WinCE多线程及其调度机制的基础上, 一种新的适用于复杂任务的实时系统的软件架构设计方法成功地运用到设计中, 通过引入多媒体定时器技术, 以系统定时线程来协调与调度进程内部线程, 并根据任务进展的具体情况, 判断与掌握各个内部线程的合适的运行、挂起、终止的时机, 进行最佳的调度, 从而能得到较好的效率, 弥补了系统线程调度机制的局限性。本文的工作可能对同类的应用设计, 具有很强参考性,有助于快速开发与灵活设计。

英文摘要:

  The higher realtime capability requirements and the more complex tasks for Multi-param eter Monitor system present many problems to the designing. Based on the analysis on Windows CE multith read techniques and it s dispatch ing m echan ism , a new sof tw are arch itectu re design ingm ethod is presen ted and applied successfully to the design, which is suitable for the complex realtime application. With the introduction of the m u lt im edia t im er techno logy, the m ethod can coordinate and dispatch inner th reads by timer th read, and therefo re get a better system efficiency and make up the limits of OS thread dispatch. A ccording to the progressing conditions of tasks, the design can judge and decide the proper opportun it ies of running, su spending and terminating of inner threads. The design presented in this paper may bring benef its to o ther similar applications, and provide the references for a quick developing and feasible devising.


引 言
     WinCE.NET 是一个实时性比较好的嵌入式操 作系统, 它的实时性能能满足绝大多数应用的需求, 由于它继承了Windows 系列操作系统优秀的系统内 核与编程接口技术、支持网络、多媒体的高端的应用, 因此具有良好的综合性能。 快速反应的嵌入式应用常常需要对某些突发事 件在严格的瞬间时间内作出及时的反应。例如, 制造 过程控制、高速的数据采集设备、武器发射装备等。这 类实时应用系统的任务往往比较复杂, 因此常常给设 计工作带来很大的困难。 被开发的多(生理) 参数监护仪系统, 就是这样一 种实时性要求较高、任务较复杂的嵌入式应用系统。 它采用的是WinCE.NET 平台。通过对WinCE.NET 与目标系统的进一步分析, 得到了一些有益的设计方 法, 使得设计工作得以顺利进行。
2. 2 WinCE 线程技术及其调度的不足之处
     WinCE.NET 是一个抢占式的多线程的多任务 操作系统。一个进程由一个或多个线程组成。一个线 程是一个执行单元, 它控制CPU 执行进程中某一段 代码段。一个线程可以访问这个进程中所有的地址空 间和资源。一个进程最少包括一个线程来执行代码, 这个线程又叫做主线程。线程除了能够访问进程的资 源外, 每个线程还拥有自己的栈。线程主要有五种状 态, 分别为运行、挂起、睡眠、阻塞、终止。 WinCE.NET 进程之间无优先级之分, 只将线程 分为256 个优先级[ 1 ]。0 优先级最高, 255 最低, 0 到 247 优先级对应于核心态线程。248 到255 优先级对 应于用户态线程, 一般分配给普通应用程序线程使 用。251 优先级(THREAD_ PR IOR ITY_ NORMAL ) 是正常优先级。255 优先级(THREAD_ PRIOR ITY_IDLE) 为空闲优先级。249 优先级(THREAD_ PRIORITY_ HIGHEST ) 是高优先级。具体分段见表1. 由于高优先级的线程能随时中断低优先级的线 程, 而获得运行权, 这样一般情况下, 只要合理地划分 应用线程的优先级, 系统就能合理地调度这些线程, 再加上WinCE.NET 在处理中断时有较小的延迟时 间, 基本上能保障应用系统的实时性要求[ 2, 3 ]。