Re: thread concurrent file operation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 29 Jan 2013, Karaoui mohamed lamine wrote:
> 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 ?
> 

Look some lines above:

	struct fd f = fdget(fd);

Regards,
Tobi


_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux