RTOS 的进程控制块类型是什么?
我正在设计一个 RTOS,它使用基于优先级的抢占式调度程序。 PCB 包含什么?我只能提出这些项目
1)PID 2)优先级 3)程序计数器 4)状态寄存器 5)一些标志
我还应该包括截止日期吗?或任何其他字段
Im designing an RTOS which uses a priority based preemptive scheduler. What would the PCB contain? Ive only been able to come up with these items
1)PID
2)Priority
3)Program counter
4)Status registers
5)Some flags
Should I also include a deadline?Or any other fields
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这在某种程度上取决于您编写此代码的架构。
您需要所有寄存器[1],而不仅仅是状态寄存器。
堆栈指针。也许堆栈大小。
中断屏蔽状态
如果您的操作系统支持浮点并且您的 CPU 有浮点单元,请不要忘记也保存这些寄存器。
[1] 除非您是为 ARM 之类的东西编写此代码,因为它有多个寄存器组。此时,您只需保存正常操作时使用的银行即可。
This is somewhat dependent on the architecture you are writing this for.
You need all the registers[1], not just the status registers.
Stack pointer. Perhaps stack size.
Interrupt mask state
If your OS supports floating point and your CPU has a floating point unit, don't forget to save those registers also.
[1] Unless you are writing this for something like ARM, which has several banks of registers. In that case, you only need to save the bank used in normal operation.
完整的寄存器组通常保存在线程的堆栈上,这意味着您可能只需要一个堆栈指针来存储程序计数器、状态寄存器以及需要上下文切换的任何其他寄存器。
是我几个月前开源的 RTOS 的真实示例 TCB/PCB (Atomthreads):
以下 从堆栈指针来看,我需要的关键元素如下:
这不是唯一的方法。当您开始设计 RTOS 并实现各种操作系统原语(信号量、队列等)时,您会发现自己的特定需求变得清晰。
The full register set is often saved on the thread's stack, which means that one stack pointer may be all you need to store the program counter, status registers, and any other registers which need to be context-switched.
Here is a real-world example TCB/PCB from an RTOS I open-sourced a few months ago (Atomthreads):
Apart from the stack pointer, the key elements I needed were as follows:
This is not the only way to do it. You will find that your own particular requirements become clear as you set out on the design of the RTOS, and implement the various OS primitives (semaphores, queues etc).