I have a program which runs in windows explorer. Ordinarily, if no other programs are running, it will use 2-3% CPU (Hence explorer.exe will show 2-3% in the resource monitor). When my program is not running and another program that does not increase explorer.exe CPU usage is running (say for example FireFox), explorer.exe CPU usage will be negligible.
However when my program and another program, like that described above, are running simultaneously, explorer.exe will increase to 8-10% CPU usage.
I've noticed this same thing happen with other programs that operate in windows explo开发者_如何学Crer.
Is anyone aware of why this is occurring? Is it something inherent in Windows or are there other programs which may cause this?
P.S This has nothing to do with Internet Explorer (iexplorer.exe)
This is because of task-switching (and maybe additionally paging). If there is only one prgram that needs a lot of CPU-time and/or memory-accesses it will be given many CPU-time-slices and thus will be able to run un-interrupted for a "long" time. On the other hand if multiple processes need a lot of CPU-time, Windows will task-switch frequently between them and thus introduce additional overhead (because it needs to store/load process-state on every task-switch). If you have 2 CPUs this is less problematic but still measurable because background-processes also need attention albeit less frequent.
See here for more information:
http://en.wikipedia.org/wiki/Context_switch
Insert Sleep(10) calls into your program; your program should get longer but less-frequent time-slices:
http://msdn.microsoft.com/en-us/library/ms686298%28VS.85%29.aspx
explorer subscribes to file-system events in order to update its display when files change size, date, new files created, etc.
If another process is touching a lot of files, it could increase the work explorer has to do, and therefore explorer's CPU utilization.
精彩评论