I know you can limit the uses of limited resources with semaphores, but how can I make it apply to the CPU (or the kernel, if that's a wise thing to do).
I have multiple threads running at the same time on a single processor. But on one of the threads I want to run a piece of code where I send a signal and I need to time how long it takes for the signal to gets back. The signals seem very distorted, whereas in the past these signals have been fine. I'm positive the hardware is working fine, so I believe that adding these extra threads have made the timing of the response pulse inaccurate. It's a very weak cpu. I'd like to try and block the cpu from doing anything but retrieving and timing the return pulse; that should be possible I believe.
Here's a quick rundown on what I'm trying to achieve:
-multiple threads are running
-on the thread with the pulse signaling a pulse has been sent
--> stop cpu from processing other threads
--> return pulse has been received
--> cpu is now free to continue it's work
I will insert sleep() methods between pulses so the cpu doesn't become locked out for the other threads.
I know how the semaphore works, question is, how do I make it work on the cpu?