3 ms·
This feels mostly right to me. I think that you get into interesting things in the margins (is a memory read blocking? No, except when it is because it's readin
by rtpg 2y ago
This feels mostly right to me. I think that you get into interesting things in the margins (is a memory read blocking? No, except when it is because it's reading from a memory-mapped file!) that make this definition not 100% production ready.
But ultimately if everyone in the stack agrees enough on a definition of blocking, then you can apply annotations and have those propagate.
- kevincox 2y ago> except when it is because it's reading from a memory-mapped file Where "memory mapped file" includes your program executable. Or any memory if you have swap space available. And any operations can be "blocking" if your thread is preempted which can happen at basically any point. So yes, everything is blocking. It is just shades of grey.
- rtpg 2y agoBut this isn’t hemming to the definition brought up by GP. “I will now, of my own accord, sleep so the OS scheduler takes over” is fairly precise. And it’s different from both just doing an operation that takes time… and different from the program doing an operation that, incidentally, the OS sees and then forces a sleep due to some OS-internal abstraction But you think about this too much and you can easily get to “well now none of my code is blocking”, because of how stuff is implemented. Or, more precisely, “exactly one function blocks, and that function is select()” or something.