0

How to add a delay without relinquishing the CPU Cycle in C. Sleep actually relinquishes the CPU cycle from the current thread, but is there a way to make it wait without using sleep?

buddy
  • 805
  • 1
  • 15
  • 30

1 Answers1

0

Blocking calls are not "busy waiting" or "spin locks". Blocking calls are sleepable -- that means the CPU would work on other task, no cpu are wasted.

As to delay without relinquishing the CPU cycle in linux

Blocking calls are easier -- they are easy to understand, easier to develop, easier to debug.

But they are resource hog. If you don't use thread, it would block other clients; If you use thread, each thread would take up memory and other system resource. Even if you have plenty of memory, switching thread would make the cache cold and reduce the performance.

This is a trade off -- faster development and maintainability? or scalability. Through this we can delay it.