▲ | jstimpfle 3 days ago | |||||||||||||||||||||||||||||||
> For example, you can't specify a timeout when opening a file, reading from a file, or closing a file, which are all potentially blocking operations. No they're not. Not really, unless you consider disk access and interacting with the page cache/inode cache inside the kernel to be blocking. But if you do that, you should probably also consider scheduling and really any CPU instruction to be blocking. (If the system is too loaded, anything can be slow). To be fair, network requests can be considered non-blocking in a similar way, but they're depending on other systems that you generally can't control or inspect. In practice you'll see network timeouts. Note that you (at least normally -- there might be tricky exceptions) won't see EINTR from read() to a filesystem file. But you can see EINTR for network sockets. The difference is that, in Unix terminology, disks are not considered "slow devices". | ||||||||||||||||||||||||||||||||
▲ | jcalvinowens a day ago | parent | next [-] | |||||||||||||||||||||||||||||||
> No they're not. Not really, unless you consider disk access and interacting with the page cache/inode cache inside the kernel to be blocking. The important point is that the kernel takes locks during all those operations, and will wait an unbounded amount of time if those locks are contended. So really and truly, yes, any synchronous syscall can schedule out for an arbitrary amount of time, no matter what you do. It's sort of semantic. The word "block" isn't a synonym for "sleep", it has a specific meaning in POSIX. In that meaning, you're correct, they never "block". But in the generic way most people use the term "block", they absolutely do. | ||||||||||||||||||||||||||||||||
▲ | jcelerier 3 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
I'd consider "blocking" anything that given same inputs, state and cpu frequency, may take variable time. That means pretty much every system call and entering the system scheduler, doing something that leads to a page fault, etc. Pretty much only pure math in total functions and function calls to paged functions are acceptable. | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
▲ | surajrmal 2 days ago | parent | prev | next [-] | |||||||||||||||||||||||||||||||
In a data center, networks can have lower latency than disk (even ssd). Now the real place this all falls on its head is page faults. That there are definitely places where you need to have granular control over what can and cannot stall a thread from making progress. | ||||||||||||||||||||||||||||||||
▲ | Joker_vD 3 days ago | parent | prev [-] | |||||||||||||||||||||||||||||||
> disks are not considered "slow devices". And neither are the tapes. But the pipes, apparently, are. Well, unfortunately, disk^H^H^H^H large persistent storage I/O is actually slow, or people wouldn't have been writing thread-pools to make it look asynchrnous, or sometimes even process-pools to convert disk I/O to pipe I/O, for the last two decades. | ||||||||||||||||||||||||||||||||
|