views:

95

answers:

2

I have recently discovered the existence of _nolock functions, and I am surprised by how little info I can find on these. It says it increases performance, but I can't find any benchmark. It also says they can be used in a multi-threaded program if the program does its own locking, but what has to be locked? Should all CRT calls go through the same lock? One per function? One per group of functions? If so, what defines groups?

Could you point me to some detailed information about these functions? Thanks :-)

+1  A: 

You need to lock access to the file if you are accessing it from multiple threads. Otherwise, one thread could write right in the middle of another one. Try them out by printing to stdio to see the effects.

Judge Maygarden
A: 

If you follow the links to the individual functions, you'll see the following line:

Use this function only in thread-safe contexts such as single-threaded applications or where the calling scope already handles thread isolation.

The only way to benchmark the performance difference would be to create a small program and test it out. As monjardin pointed out, you need to lock access to the file you're accessing with the function (unless, as noted in the documentation, you are in a single-threaded environment).

Harper Shelby