(Working on win32/c++ environment)
I have a function that calls ReadFile
(synchronously) with a fixed size of one byte to read from a SOCKET
resource (of WINSOCK
).
There's multiple threads running this function.
The data is written to sockets externally, and is not on my control.
whenever the data is yet to be written, I find my exe
consuming nearly 80% of CPU, and the usage divide relatively equally among the mentioned threads (there are typically 4 of them).
as ReadFile
is an OS api, I would have expected it to be implemented asynchronously internally to avoid such as issue.
My question is why is this happening, and what can I do to avoid it.