Why does DOS use 100% CPU under Virtual PC?
2009-02-05 22:43
295 查看
From time to time someone notices that when they run DOS under Virtual PC it uses 100% of the host CPU to do absolutely nothing, and wonder why this is the case. The answer is relatively simple - and it is: 'DOS is never actually doing nothing'.
Most modern operating systems are designed with the concept of being able to 'do nothing'. That is - if the user is not actively providing input, and no programs are demanding attention - most operating systems will tell the CPU to 'do nothing' (usually through a HLT command - or through some more advanced power state commands).
DOS does not do this.
So when DOS is sitting at the command prompt 'doing nothing' it is actually in a very tight loop of code which is responsible for blinking the cursor and checking for new user input. As we operate at a very low level - there is no way for us to tell if DOS is actually doing something productive with the CPU or just 'running around in circles'. To help deal with this - there is a utility called 'IDLE.COM' that is part of the Virtual Machine Additions for DOS - which is able to send 'HLT' commands when it detects that DOS is 'doing nothing'. However if you start any program (like EDIT) then your CPU usage will go up to 100% again.
So at the end of the day - if you are using DOS under Virtual PC you are pretty much going to have to learn to live with the fact that it will try to use as much CPU as possible at all times.
Cheers,
Ben
为什么虚拟机运行dos下的程序读COM不能获得数据,我想也是这样 VPC获得太多cpu资源,HOST system得不到cpu资源就没时间去处理COM的读写请求了把? 猜测
不过还好host跑在Dual Core上,我尝试的用SetProcessAffinityMask设置vpc process只用一个cpu, Bingo~~~ 一切都好了 :)
Most modern operating systems are designed with the concept of being able to 'do nothing'. That is - if the user is not actively providing input, and no programs are demanding attention - most operating systems will tell the CPU to 'do nothing' (usually through a HLT command - or through some more advanced power state commands).
DOS does not do this.
So when DOS is sitting at the command prompt 'doing nothing' it is actually in a very tight loop of code which is responsible for blinking the cursor and checking for new user input. As we operate at a very low level - there is no way for us to tell if DOS is actually doing something productive with the CPU or just 'running around in circles'. To help deal with this - there is a utility called 'IDLE.COM' that is part of the Virtual Machine Additions for DOS - which is able to send 'HLT' commands when it detects that DOS is 'doing nothing'. However if you start any program (like EDIT) then your CPU usage will go up to 100% again.
So at the end of the day - if you are using DOS under Virtual PC you are pretty much going to have to learn to live with the fact that it will try to use as much CPU as possible at all times.
Cheers,
Ben
为什么虚拟机运行dos下的程序读COM不能获得数据,我想也是这样 VPC获得太多cpu资源,HOST system得不到cpu资源就没时间去处理COM的读写请求了把? 猜测
不过还好host跑在Dual Core上,我尝试的用SetProcessAffinityMask设置vpc process只用一个cpu, Bingo~~~ 一切都好了 :)
相关文章推荐
- Why does DOS use 100% CPU under Virtual PC?
- DOS Under Microsoft Virtual PC 2007
- What is virtual memory, how is it implemented, and why do operating systems use it?
- Why does a statically built Qt use the dynamic Visual Studio runtime libraries ? Do I need to deploy
- [导入]Why does my Windows Form project not use visual styles in XP even when I call Application.EnableVisualStyles?
- Why does a virtual function get hidden?
- why we use _MainText_ST and what does the mean of TRANSFORM_TEX
- what is the virtual machine, when and why we need use it ?
- Your CPU does not support long mode.Use a 32bit distribution.
- Why Does Qt Use Moc for Signals and Slots(QT官方的解释:GUI可以是动态的)
- 虚拟机启动提示Your CPU does not support long mode. Use a 32bit distribution
- Mac Bug之二 UserEventAgent占用内存20G、CPU 100%
- Your CPU does not support long mode. Use a 32 bit distribution.
- 用Virtual装CentOS出现please use a kernel appropriate for your CPU
- 解决android - Why does use of multiDexEnabled (true) allow the app to build but constantly crash?
- Why does Quora use MySQL as the data store instead of NoSQLs such as Cassandra, MongoDB, CouchDB etc?
- 为什么奇巧需要使用isValidFragment的?(Why does Kit Kat require the use of the isValidFragment?)
- About install linux ON virtual PC by use of VMware
- 修复VirtualBox "This kernel requires the following features not present on the CPU: pae Unable to boot – please use a kernel appropriate for your CPU"
- Why does a destructor in base class need to be declared virtual?