thread concurrent file operation

Jimmy Pan dspjmt at gmail.com
Wed Feb 6 17:58:29 EST 2013


actually i dont see why there is a need to ptovide a lock by the kernel.
the locking should be at userspace.
you can test it by massive write to a file, that would demonstrat the
kernel
didnt confer a lock

sent from my samsung
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.


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies at kernelnewbies.org
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20130207/d9e3410e/attachment.html 


More information about the Kernelnewbies mailing list