public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: dancol@dancol.org
To: "\"Ondřej Bílka\"" <neleai@seznam.cz>
Cc: dancol@dancol.org, "Florian Weimer" <fweimer@redhat.com>,
	libc-alpha@sourceware.org
Subject: Re: [RFC] Toward Shareable POSIX Signals
Date: Thu, 08 Mar 2018 21:50:00 -0000	[thread overview]
Message-ID: <b8b2c73b8aebd55661abf6de0e66dcb3.squirrel@dancol.org> (raw)
In-Reply-To: <20180308212108.GA14490@domone>

> On Thu, Mar 08, 2018 at 12:22:05PM -0800, dancol@dancol.org wrote:
>> > For asynchronously delivered signals (such as subprocess termination),
>> > the signal mechanism may not be entirely appropriate anyway.
>>
>> It beats wait. Which part of my proposed mechanism would operate
>> improperly?
>>
> Basic problem is that if you combine signals, threads and locks you get
> a big mess.
>
> It is hard to write handler doing something complex, you
> couldn't take any lock because thread you interrupted could have that
> lock. Introducing signal leads to unexpected race conditions(for example
> what happens when interrupt is interrupted?).

Writing a robust handler requires some understanding of the subtleties
involved, but it's in no way impossible or even particularly difficult.
It's the moral equivalent of writing the top half of an interrupt handler.
People do that all the time.

Besides: people are _already_ using signals for this purpose. Practically
every high-performance language runtime already hooks various signal
handlers, and for good reason. There's no reason it should be hard for
these systems to coexist in the same process, and something like glib does
nothing to help sharing.

I'm proposing making existing use cases more portable and more robust.

>> > For those,
>> > standardizing on a single event loop looks like the right solution,
>> and
>> > glib has largely taken over there.
>>
>> The libevent and Qt people might disagree. I don't think standardizing
>> on
>> a single event loop is realistic considering that various event loop
>> libraries have been around for many years and not achieved any kind of
>> fixation.
>>
>
> Original answer to use event loop, doesn't matter which one.

Nobody will agree on a single event loop library. There is, for example,
_zero_ chance that popular mobile operating systems will adopt glib as the
primary event dispatching mechanism. In any case, an event loop doesn't
help with the synchronous signal sharing use cases --- the ones, for
example, a SIGSEGV-using high-performance runtime might require. (See the
first of my use cases on my original post.)

> Async signals should be handled as separate thread which has event loop
> to serially handle arrived signals. That would remove most difficulties
> of signal handlers.
>
> Reason why this isn't default is performance and putting this to another
> event loop is compromise.


It's not performance. It's that certain events, particularly those related
to memory errors, _need_ to be addressed immediately and synchronously.
Even if you were to use something like the Mach ports mechanism and send a
message instead of pushing a stack frame, you'd still have to
synchronously block a faulting thread, which could be anywhere, thus
giving you the same atomicity constraints.


  reply	other threads:[~2018-03-08 21:50 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-08 17:53 Daniel Colascione
2018-03-08 20:09 ` Florian Weimer
2018-03-08 20:22   ` dancol
2018-03-08 21:21     ` Ondřej Bílka
2018-03-08 21:50       ` dancol [this message]
2018-03-09  8:17         ` Ondřej Bílka
2018-03-09 10:51           ` Daniel Colascione
2018-03-09  9:19     ` Florian Weimer
2018-03-09 10:43       ` Daniel Colascione
2018-03-09 16:41         ` Rich Felker
2018-03-09 16:58           ` Florian Weimer
2018-03-09 17:14             ` Rich Felker
2018-03-09 17:36               ` Paul Eggert
2018-03-09 19:34               ` Daniel Colascione
2018-03-09 19:28           ` Daniel Colascione
2018-03-09 19:30           ` Zack Weinberg
2018-03-09 20:06             ` Daniel Colascione
2018-03-09 20:25             ` Rich Felker
2018-03-09 20:54               ` Daniel Colascione
2018-03-09 21:10                 ` Rich Felker
2018-03-09 21:27                   ` dancol
2018-03-09 21:05               ` Zack Weinberg
2018-03-10  7:56               ` Florian Weimer
2018-03-10  8:41                 ` dancol
2018-03-11 18:07 ` Zack Weinberg
2018-03-11 18:56   ` Daniel Colascione
2018-03-12 15:17     ` Zack Weinberg
2018-03-12 19:47       ` Daniel Colascione

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=b8b2c73b8aebd55661abf6de0e66dcb3.squirrel@dancol.org \
    --to=dancol@dancol.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=neleai@seznam.cz \
    /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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).