fseek和fread单独使用线程安全,合在一起需要用线程安全机制
2013-09-01 13:52
801 查看
翻译整理自:http://social.msdn.microsoft.com/Forums/vstudio/en-US/ce7799c2-52e0-4b14-b59b-30357ccb3db2/file-seek-then-read-threadsafety?forum=vcgeneral
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:
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 section seek read leave critical section }
相关文章推荐
- 逆序存储文件(二)——使用c标准库函数fopen,fseek,fread,fwrite
- fopen/fwriite/fseek/ftell/fread/fclose等函数的使用方法
- fopen/fwriite/fseek/ftell/fread/fclose等函数的使用方法
- C语言函数fseek, fread, ftell的使用
- 在使用django框架搭建web中如果需要单独运行py脚本出现AppRegistryNotReady("Apps aren't loaded yet.")问题
- file文件流中的fopen,fread,fseek,fclose,ftell函数使用
- 写高质量OC代码52建议总结:45.使用dispatch_once来执行只需要运行一次的线程安全代码
- 文件处理函数fopen、fread、fseek、fclose的使用实例介绍
- fseek,fwrite,fread使用
- 文件处理函数fopen、fread、fseek、fclose的使用实例介绍
- FILE文件流的中fopen、fread、fseek、fclose的使用
- FILE文件流的中fopen、fread、fseek、fclose的使用
- C/C++之FILE文件流的中fopen、fread、fseek、fclose的使用
- FILE文件流的中fopen、fread、fseek、fclose的使用
- FILE文件流的中fopen、fread、fseek、fclose的使用
- VC中fread,fwrite,fseek,ftell的使用
- FILE文件流的中fopen、fread、fseek、fclose的使用
- 使用fwrite,fread需要注意的问题
- fopen/fwriite/fseek/ftell/fread/fclose等函数的使用方法
- fopen\fread\fwrite\fscanf\fprintf\fseek\feof\rewind\fgets\fputc等系列函数使用总结