Patent ID: 7681199

Claim:
A method for use in calculating time in a computing device, comprising: allocating, by program instructions executing in the computing device, a memory space to a thread executing on a first processor, wherein the memory space is to be used to communicate with an operating system; saving a context switch count, an offset, and a scale factor, received from the operating system, in the memory space that is part of a memory, wherein the context switch count is a count of context switches of the thread, and wherein the offset and scale factor are for use along with a counter of the first processor to calculate the time, wherein the scale factor is used to scale a count of the counter, and the offset is added to account for when the counter started; copying the context switch count, the offset, and the scale factor to local variables associated with the thread; the thread performing context switching from the first processor to a second processor after copying the context switch count, the offset, and the scale factor to the local variables; comparing the context switch count saved in the memory space to the context switch count copied to a corresponding one of the local variables, wherein the context switch count saved in the memory space not being equal to the context switch count copied to the one local variable is an indication of the context switching from the first processor to the second processor; and in response to determining that the context switch count saved in the memory space is not equal to the context switch count copied to the one local variable, re-calculating the time using an offset, a scale factor, and a counter of the second processor.