与RTX相关的进程与线程基础知识

本文详细介绍了RTSS和Win32环境下的进程与线程概念,包括进程的构成、创建与退出条件,以及线程的创建、同步和调度。在RTSS中,线程优先级更高,而Win32进程可通过RTAPI调用来交互。文章还讨论了不同环境下线程优先级的映射关系,并提出了Win32应用中考虑GUI性能的问题。
摘要由CSDN通过智能技术生成

进程与线程

进程由地址空间(address space),目标句柄(object handles),一条以上可执行的线程(threads)。线程多用于响应中断,或用来同步事件(handle asynchronous process-related events in thread context)。RTSS的进程与线程函数与Win32下的很相似。但是RTSS和Win32下的进程或者线程仅能在自己的环境中运行,不能相互访问。(RTSS and Win32 processes and threads can access processes and threads only within their own environment.,原文中是这样一句话,不知道自己理解的是否正确,但是就现实来看,Win32进程和RTSS进程之间可以通过共享内存来实现数据交换,那么这种情况就和文档中所描述的是矛盾的,以后有进一步理解后可以对这段东西进行修正)。

Win32进程与RTSS进程之间的关系可以用以下一张图来进行表述:

以下描述会大量饮用英文原文,对于重要的地方会用汉语进行注解

RTSS环境下的进程:

A process running in the RTSS environment consists of a set of handles to objects, process address space,at least one thread, andan executable(这个executable应该指一段可执行程序. When a process is created, RTSS performs the following tasks:

  • Loads the executable as a driver

  • Allocates process heap from the non-paged pool

  • Creates the primary thread

A process can be started by either one of these methods:

  • Loading it as a device driver during system boot (using the RTSSrun /b utility)

  • Running the RTSS executable from the command line

  • Starting the RTSS process from Win32 applications(这种方案是最实用,最常用的方案)

A process exits under one of these conditions:

  • The last thread has exited(这种情况我也遇到过,当主进程关闭时,所有的定时器进程也就关闭了)

  • One thread calls ExitProcess

  • The process is killed with the RTSSkill utility or the RTSS Task Manager(开始->Adrence->RTX->Tools->Rtss Task Managers)

The maximum number of processes that can exist concurrently in the RTSS environment is equal to the number of RTSS process slots in the registry (the default is 10).

其设置的位置如下图所示:

Win32环境下的进程:

A process running in the Win32 environment starts interacting with RTX when it makes an RTAPI call. RTX then may allocate resources for this process, alter its priorities, and perform other operations related to its Win32 process status. The number of Win32 processes that can interact with RTX is dynamic; it depends on your system's configuration and resources.

 

Using Threads

The CreateThread function createseither an RTSS or a Win32 thread, depending on the current execution environment of the process. You can specify the stack size of subsequently created threads of that process usingCreateThread. The returned handle and thread ID are valid only in theCreateThread caller's environment. For instance, a Win32 process cannot manipulate the priority of an RTSS thread because the handle for the thread is valid only in the RTSS environment. You can, however, use the RTX Interprocess Communication (IPC) mechanisms (such asmutex objects,semaphores, events, andshared memory) tosynchronize and com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值