本文主要是介绍fseek和fread单独使用线程安全,合在一起需要用线程安全机制,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
1、fseek和fread单独使用线程安全
fseek: "This function locks out other threads during execution and is therefore thread-safe."
http://msdn2.microsoft.com/en-us/library/75yw9bf3(VS.80).aspx
fread: "This function locks out other threads."
http://msdn2.microsoft.com/en-us/library/kt0etdcs(vs.80).aspx
2、fseek和fread联合使用需要加锁或者采用临界区
Another seek can come in between a seek-then-read operation and will need a critical section for it.
It sounds like I'll need to create a windows equivalent of pread:
int pread(handle, location, size, data*)
{enter critical sectionseekreadleave critical section
}
这篇关于fseek和fread单独使用线程安全,合在一起需要用线程安全机制的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!