4 ms·
I'd say that the commonly accepted definition for a blocking call is one that may depend on I/O to complete, releasing control of the CPU core while waiting. B
by vanviegen 5y ago
I'd say that the commonly accepted definition for a blocking call is one that may depend on I/O to complete, releasing control of the CPU core while waiting.
By that definition, getpid() is definitely nonblocking, though it doesn't have an upper bound in execution time. POSIX does not offer hard realtime guarantees.
close() in general would probably be blocking (as a filesystem may need to do I/O), but I'd expect it to behave nonblocking in most cases, especially when operating on virtual files opened read-only. Unfortunately, I don't think those kinds of behavioral details are documented.
- dagmx 5y agoA function that sleeps for 5 seconds is blocking. No IO involved. Blocking just means that you're blocking your current code till you return out of the called function. Anything else regarding a function call is an assumption unless you know the exact implementation.