The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: "Mihai Donțu" <mihai.dontu@gmail.com>
To: Xin Tong <xerox.time.tech@gmail.com>
Cc: linux-kernel <linux-kernel@vger.kernel.org>
Subject: Re: futex system call in write
Date: Sun, 3 Jun 2012 12:16:03 +0300	[thread overview]
Message-ID: <20120603121603.047c86c4@mdontu-l> (raw)
In-Reply-To: <CALKntY1xQ7v5VRKxqT3A3G+W3s3CK_JtqWB5GkBcN08J6Hn=-A@mail.gmail.com>

On Sun, 3 Jun 2012 01:58:55 -0400 Xin Tong wrote:
> I am a program with 2 threads, each of which calling printf in a loop.
> when i strace this programs. i see besides write() gets calls a good
> number of times. futex gets call many times as well. it seems to be
> related to the write system call ? how is the futex system call used
> here ? maybe write() is blocking and futex is used to wait the thread
> up when the write finishes ? if that is the case, what about other
> blocking system calls ?
> 

You should probably ask this question on a glibc mailing list.

What you're seeing is the effect of using the locking version of the
standard IO calls, where before each output a mutex is acquired to
ensure thread safety. Thus futex() has nothing to do with write(), it
is merely the underlaying system call for pthread_mutex_xxxx() calls.

-- 
Mihai Donțu

      reply	other threads:[~2012-06-03  9:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-06-03  5:58 futex system call in write Xin Tong
2012-06-03  9:16 ` Mihai Donțu [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120603121603.047c86c4@mdontu-l \
    --to=mihai.dontu@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xerox.time.tech@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox