Visual Studio fread "blocks other threads." There is an alternative version of _fread_nolock that reads “without blocking other threads”, which should be used only “in thread-safe contexts, such as single-threaded applications or where the call area already processes thread isolation”.
Even after reading the other several important discussions on these two issues, I am confused if the implementation of the blocking fread is on a specific FILE structure, a specific actual file, or on all fread calls on completely different files.
If you are using nolock versions, what level of lock do you need to provide? Can multiple threads read separate files in parallel without blocking? Can multiple threads write separate files in parallel without blocking? Or are there global or static variables that would be corrupted?
So, using nolock versions, you can potentially achieve better I / O bandwidth (if you don't need to move the heads, for example, when reading individual disks or an SSD), or this is a potential gain by simply reducing redundant locks to one lock (which should be negligible.)
Does VS 'ifstream.read function the same as regular fread? (I do not see its night version.)
source share