Posted: Sun Feb 13, 2011 8:16 pm Post subject: More Cpu time?
Which takes more cpu time?
1) Switching between two processes.
2) Switching a process from user mode to kernel mode.
Considering the fact that switching between two process is done by cpu..
Joined: 17 Feb 2008 Posts: 524 Location: Inside the Intel CET shadow stack
Posted: Sun Feb 20, 2011 7:28 am Post subject:
Your question is a little vague. Are we just talking about a context switch triggered by the thread manager? If so, switching between user and kernel space probably takes a couple extra cycles - but nothing noticeable even if we were to switch a few thousand times a second. The extra cycles account for switching the processor's active ring number (i.e. ring3 -> ring0 in this case) and performing whatever checks the OS likes to do.
If you're talking about manual invokation of code through direct call or an event, it depends on a lot of factors:
How are you switching? A mutex is slower than two WaitForSingleObject wakeups on a global event.
Are you performing direct calls? CreateRemoteThread should be a little faster than DeviceIoControl or a syscall.
If I remember correctly, sometimes higher priority IO will cause a user->kernel dispatch to be delayed, or even allocated to be sent by DPC at a later time.
Give some more details and we can probably help more. _________________
It's not fun unless every exploit mitigation is enabled.
Please do not reply to my posts with LLM-generated slop; I consider it to be an insult to my time.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum