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

  • Home
  • SEARCH
  • 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 7871251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T01:50:54+00:00 2026-06-03T01:50:54+00:00

I would like to ask a fundamental question about when is it useful to

  • 0

I would like to ask a fundamental question about when is it useful to use a system call like fsync. I am beginner and i was always under the impression that write is enough to write to a file, and samples that use write actually write to the file at the end.

So what is the purpose of a system call like fsync?

Just to provide some background i am using Berkeley DB library version 5.1.19 and there is a lot of talk around the cost of fsync() vs just writing. That is the reason i am wondering.

  • 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-03T01:50:55+00:00Added an answer on June 3, 2026 at 1:50 am

    Think of it as a layer of buffering.

    If you’re familiar with the standard C calls like fopen and fprintf, you should already be aware of buffering happening within the C runtime library itself.

    The way to flush those buffers is with fflush which ensures that the information is handed from the C runtime library to the OS (or surrounding environment).

    However, just because the OS has it, doesn’t mean it’s on the disk. It could get buffered within the OS as well.

    That’s what fsync takes care of, ensuring that the stuff in the OS buffers is written physically to the disk.

    You may typically see this sort of operation in logging libraries:

    fprintf (myFileHandle, "something\n");  // output it
    fflush (myFileHandle);                  // flush to OS
    fsync (fileno (myFileHandle));          // flush to disk
    

    fileno is a function which gives you the underlying int file descriptor for a given FILE* file handle, and fsync on the descriptor does the final level of flushing.

    Now that is a relatively expensive operation since the disk write is usually considerably slower than in-memory transfers.

    As well as logging libraries, one other use case may be useful for this behaviour. Let me see if I can remember what it was. Yes, that’s it. Databases! Just like Berzerkely DB. Where you want to ensure the data is on the disk, a rather useful feature for meeting ACID requirements 🙂

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

Sidebar

Related Questions

I would like to ask a question. Now i'm training about iPhone Programming. I'm
I use c#, linq and EF4 I would like ask your help. My question:
I would like to ask what's the use of System.property in this source code?
I would like to ask about .XSD document. I cannot find anything about creating
I would like to ask about the performance and memory usage of instantiating an
I would like to ask about how can I add different overlays to my
I would like to ask a question in Titanium mobile. I am finding the
I would like to ask about php's preg_match_all. suppose we have the sample string
Would like to ask about how do I write a preg_replace in PHP to
I would like to ask a really simple question. I am just passing a

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.