thread concurrent file operation

Karaoui mohamed lamine moharaka at gmail.com
Tue Jan 29 10:35:13 EST 2013


Hello,

I was looking at how a syscall read/write was done, and i found this :

   ....
   loff_t pos = file_pos_read(f.file);
   ret = vfs_read(f.file, buf, count, &pos);
   file_pos_write(f.file, pos);
   fdput(f);
   ...

My questions are :

Where did the locking go? I would have imaginated something like :

   ....
   *lock(f);*
   loff_t pos = file_pos_read(f.file);
   ret = vfs_read(f.file, buf, count, &pos);
   file_pos_write(f.file, pos);
   fdput(f);
   *unlock(f);*
   ...

If multiple threads try to read/write at the same time, they could
read/write at the same offset ?

If my understanding are correct, is this POSIX compliant ?


thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130129/82cbbe88/attachment.html 


More information about the Kernelnewbies mailing list