I understand that, in a endless loop or somewhere else, you could sleep(0) to leave the OS to perform a context-switching and execute another thread (if there is and it is ready to execute). Now, I saw a bunch of code where people use sleep(1) instead of sleep(0).
Is this optimal?
Where may I found documentation about it?
If you're implementing something like 'check for the existence of a file, repeat until it exists, then continue', it's better to do a sleep(some_small_positive_number), so you don't use up 100% of CPU time.
Polling loops like this are almost always a sign of improper planning when used in a program, but are used often in command line scripts.