From mboxrd@z Thu Jan 1 00:00:00 1970 From: moharaka@gmail.com (Karaoui mohamed lamine) Date: Tue, 29 Jan 2013 18:25:19 +0100 Subject: thread concurrent file operation In-Reply-To: <20130129155602.GA991@aurora> References: <20130129155602.GA991@aurora> Message-ID: To: kernelnewbies@lists.kernelnewbies.org List-Id: kernelnewbies.lists.kernelnewbies.org 2013/1/29 Tobias Boege > 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); > This function is supposed to return the file reference, does do the locking ? It seems that i can't find the lock instruction( with all those rcu instructions, i am little lost), can you guide me throught ? > > Regards, > Tobi > > > _______________________________________________ > 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/20130129/141d7296/attachment.html