Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9210629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:07:22+00:00 2026-06-18T01:07:22+00:00

I was looking at how a syscall read/write was done in linux, and i

  • 0

I was looking at how a syscall read/write was done in linux, 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.file);  // <-- lock file struct
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.file);  // <-- unlock file struct
...

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

If my understanding is correct, linux doesn’t use any locking mechanism to protect the offset, is this POSIX compliant ?

I did look at the POSIX specification, and found nothing about this case.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T01:07:23+00:00Added an answer on June 18, 2026 at 1:07 am

    Linux doesn’t use any locking mechanism to protect multithread writing to a file.

    You have to use your own mutex to protect your file.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Looking through this C++ BigInt library and found the BigInt.cpp file. At the top
Looking at this css file ( especially the last 5 lines ): #page section
Looking for C# class which wraps calls to do the following: read and write
I am trying to understand how the linux syscall sched_setaffinity() works. This is a
Looking to do a bit of refactoring... Using NHibernate I have this query currently
Looking for best advice on how to do this: I have an insert like
Looking for a way to get path of file (and then process it in
looking into multi file - drag and drop - upload scripts. we were using
Looking for a command that will return the single most recent file in a
I'm working on a little debugger under Linux 64bits and I'm having trouble looking

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.