Install timer/clock ISR on Windows - Asynchronous call in a single threaded environment

﹥>﹥吖頭↗ 提交于 2019-12-06 05:26:10

You'll definitely need to replace tick_isr and and context_switch_isr, since they're implementing context-switching for a DOS environment. There's no way the existing code will do anything meaningful in Windows, even if you could sensibly execute it.

Since, in the original code, the context switches are preemptive, you could probably just eliminate that logic altogether and use Windows threads instead. Presumably the existing code has some routines for creating and removing contexts, and these can be replaced with corresponding Windows API thread functions.

If you need to ensure that only one thread is running at a time, you could use SetProcessAffinityMask to tie the process to a single CPU.

Alternatively, you could use the debugging functions GetThreadContext and SetThreadContext to implement your own context switching. In this situation you would have one thread for the main program code and a second thread running the context switcher.

See the wikipedia entry on BIOS interrupts; it says:

08h​ IRQ0: Implemented by the system timing component; called 18.2 times per second (once every 55 ms) by the programmable interval timer

On Windows 7, you will need to create kernel mode drivers to access interrupts, though.

You may be able to emulate interrupts for your scheduler using Windows user mode scheduling and fibers.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!