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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:19:38+00:00 2026-05-25T11:19:38+00:00

Suppose two processes (or threads) both call write on a pipe/socket/terminal whose buffer is

  • 0

Suppose two processes (or threads) both call write on a pipe/socket/terminal whose buffer is full, thus blocking. Is there any guarantee as to who gets to write first when buffer space becomes available? Is it FIFO order? Globally, or within a given priority level, and ordered first by priority? Or is it completely random/indeterminate?

What about starved reads? Will the first to call read get the data when it becomes available?

I’m asking specifically on Linux and as far as I know POSIX has nothing to say about these issues, but I’d also be interested if I’m wrong on that and POSIX does mandate particular behaviors.

  • 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-25T11:19:39+00:00Added an answer on May 25, 2026 at 11:19 am

    Within the kernel, the pipe_wait() function is used by both pipe readers and writers to block. This function uses the DEFINE_WAIT() macro to define a wait queue, which sets the .flags member of the wait queue to zero.

    They are woken up with a call to wake_up_interruptible_sync_poll(), which calls down to __wake_up_common(). You can see that if the .flags member does not have the WQ_FLAG_EXCLUSIVE bit set (as in this case), then all waiters are unceremoniously made runnable.

    The scheduler will then use its normal heuristics to pick the runnable processes to run next. In particular, a later waiter with a higher priority will get to go first – but note that if you have more than one processor core available, multiple waiters can start to run simultaneously, and which one actually gets to touch the pipe first depends entirely on which one manages to grab the pipe lock first.

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

Sidebar

Related Questions

Suppose you have two seperate ASP.NET Web Application projects that both need to use
Suppose I have two classes that both contain a static variable, XmlTag. The second
Suppose we run two processes back to back say :- $ grep abc abc.txt
suppose we have multi processor machine and multi threaded application. If two threads have
Suppose there are two types of messages, QUOTE and TRADE. Both have different fields.
Suppose a header file defines a function template. Now suppose two implementation files #include
Suppose that two tables exist: users and groups . How does one provide simple
Suppose I have two applications written in C#. The first is a third party
Suppose there are two scripts Requester.php and Provider.php, and Requester requires processing from Provider
Suppose you have two models, User and City, joined by a third model CityPermission:

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.