On a single-processor machine, I need to measure the time cost for two threads alternate switch using a mutex lock.

And your question is...?

The answer may depend on the target processor and OS in question. In a desktop environment the attempt is probably doomed since a non-realtime scheduler is by no means deterministic, and besides your threads/process there will be much else going on besides.