如何获取进程信息?
在我的操作系统课程中,我们用C语言编程,我们覆盖了定时器中断,之后从我们编写的定时器中断中我们必须处理4个进程,但是我们需要获取进程的上下文,如指令指针、数据段等等。我们如何从 c 中获取这些信息?如果没有,我们是否还需要在 C 代码中使用 ASM?谢谢 :D
我正在使用 Windows XP 32 位虚拟机,并使用 DOS 16 位虚拟机
In my Operating System class we are programming in C and we overrode the Timer Interrupt, after that from the timer interrupt we wrote we have to handle 4 processes, but we need to get the context of the process, like the instruction pointer, data segment, etc. How can we get that information from c? if not, do we need to use also ASM inside the C code? thanks :D
I'm using virtual box with Windows XP 32 bits, and using the DOS 16 bit virtual machine
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
是的,您几乎需要至少一点汇编语言。典型的起点是
pusha
。这保留了主要的通用寄存器,因此您可以在不破坏任何关键内容的情况下工作。如果您支持 FPU,您可能需要查看fsave
。您可以分别使用popa
和frestore
恢复它们。Yes, you pretty much need at least a little bit of assembly language. A typical starting point is
pusha
. That preserves the main general purpose registers so you have someplace to work without destroying anything critical. If you're supporting the FPU, you'll probably want to look atfsave
. You restore those withpopa
andfrestore
respectively.您可能需要使用汇编代码来执行上下文保存/恢复,除非您已经实现了诸如
getcontext
/setcontext
之类的库例程。You probably need to use assembly code to do the context save/restore, unless you have library routines like
getcontext
/setcontext
already implemented.我相信这种技术不适用于 EIP 和 EFLAGS,因为它们只能通过特殊指令进行访问。
我不知道 DOS 16 位的 movl 的等价物,但我想你明白了。
I believe this technique won't work for EIP and EFLAGS since they can only be accessed through special instructions.
I don't know the equivalent of movl for DOS 16 bit, but I think you get the idea.