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 6215645
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T07:05:41+00:00 2026-05-24T07:05:41+00:00

I have two process each writing large buffer of data, and I want to

  • 0

I have two process each writing large buffer of data, and I want to control synchronize those processes’ writes to one file.

process 1 writing buffer A including (A1, A2, A3) and process 2 writing buffer B including (B1, B2, B3). when we use write() system call to write these buffers to disk to the same file(whole buffer at one time: write(fd, A, sizeof(A))) , How is the file schema?

  • Is it like this: A, B or B, A maybe?
  • or it could be like this: A1, A2, B1, A3, …

I’m asking this because system calls are atomic. what happens if the data buffer we are writing is too large. Is it like pipes for regular disk files?

  • 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-05-24T07:05:42+00:00Added an answer on May 24, 2026 at 7:05 am

    If you want the contents of both buffers to be present, you have to open the files with the O_APPEND flag set. The append flag seeks to the end of the file before writing. Without this set, it’s possible that both processes will be pointing to the same or overlapping areas of the file and whoever writes last will overwrite what the other has written.

    Each call to write will write up to the number of bytes requested. If your process is interrupted by a signal, then you can end up with a partial write — the actual number of bytes written is returned. Whether you get all of your bytes written or not, you’ll have written one contiguous section of the file. You don’t get the interleaving effect you mentioned as your second possibility (e.g. A1,B1,A2,B2,…).

    If you only get a partial write, how you proceed is up to you. You can either continue writing (offset from the buffer start by the number of bytes previously written), or you can abandon the rest of your write. Only in this way could you potentially get the interleaving effect.

    If it’s important to have the contents of one write complete before the other process writes, then you should look into locking the file for exclusive write access (which both processes will have to check for) before attempting to write any data.

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

Sidebar

Related Questions

I have two running processes in Windows, and each process has a pipe to
I have created two processes using fork(). The child process is producing and writing
I have two processes - a user process and a root-level LaunchDaemon. I'd like
I have two completely different forms in one template. How to process them in
I have two unrelated processes that use .NET assemblies as plugins. However, either process
We have a vxWorks design which requires one task to process messages from two
I have two VC++ 6 apps writing/updating data in a common Access 2000 database
I have two process and a shared memory zone, my workflow is like this.
I have two ASP.NET sites (they can not run in the same process) and
I have Process objects that are monitored from two different views. A Windows.Forms.ListView (actually

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.