Win32: Atomic Code Execution
I have two system calls GetSystemTime () and GetThreadTimes () that I need to calculate the CPU utilization of a given Win32 thread.
For accuracy, I must ensure that both GetSystemTime () and GetThreadTimes () are executed atomically; that is, there should be no context switch between calling GetSystemTime () and GetThreadTimes ().
The reason is that sometimes I get a percentage over 100% (~ 1 in 500).
How can I ensure that 2 function calls are made atomic?
Thanks, Sachin
+1
source to share