Re: data structures for use in signal handlers

2021-02-09 Thread Eric Wong
Bruno Haible wrote: > Eric Wong wrote: > > > How would setting up a pipe or eventfd help with a communication > > > problem between threads in the same process? I thought these were > > > for communication between processes. > > > > The "self-pipe trick" is a common idiom in Unix for signal > >

Re: data structures for use in signal handlers

2021-02-09 Thread Ben Pfaff
On Tue, Feb 9, 2021 at 6:07 PM Bruno Haible wrote: > Maybe I didn't describe accurately the situation I am asking for. > I'm not attempting to transform a program to an event-based engine. > I'm looking to let signal handlers (SIGTERM, SIGSEGV, SIGWINCH, etc.) > read and traverse data structures

Re: data structures for use in signal handlers

2021-02-09 Thread Paul Eggert
On 2/9/21 5:21 PM, Eric Wong wrote: I know the (C)Ruby VM uses it internally (or eventfd on Linux); I think CPython's GVL does, too. GNU Make does too. It's where I learned of the trick.

Re: data structures for use in signal handlers

2021-02-09 Thread Bruno Haible
Eric Wong wrote: > > How would setting up a pipe or eventfd help with a communication > > problem between threads in the same process? I thought these were > > for communication between processes. > > The "self-pipe trick" is a common idiom in Unix for signal > handling; especially when

Re: data structures for use in signal handlers

2021-02-09 Thread Ben Pfaff
On Tue, Feb 9, 2021 at 5:01 PM Bruno Haible wrote: > > Ben Pfaff wrote: > > Building an RCU implementation isn't necessarily difficult (I have done it, > > but the implementation isn't suitable for gnulib). > > > > There is a liburcu that is under LGPL v2.1: https://liburcu.org/ > > Thanks for

Re: data structures for use in signal handlers

2021-02-09 Thread Eric Wong
Bruno Haible wrote: > Hi Eric, > > Eric Wong wrote: > > I would've recommended just using a pipe, socket or eventfd; > > How would setting up a pipe or eventfd help with a communication > problem between threads in the same process? I thought these were > for communication between processes.

Re: data structures for use in signal handlers

2021-02-09 Thread Bruno Haible
Hi Eric, Eric Wong wrote: > I would've recommended just using a pipe, socket or eventfd; How would setting up a pipe or eventfd help with a communication problem between threads in the same process? I thought these were for communication between processes. Bruno

Re: data structures for use in signal handlers

2021-02-09 Thread Bruno Haible
Ben Pfaff wrote: > On Sun, Feb 7, 2021 at 2:57 PM Bruno Haible wrote: > > (2) Let the signal handler work only on immutable copies of the data > > structure. Whenever the other code manipulates the data structure, > > it creates an immutable copy of it, for the signal handler

Re: data structures for use in signal handlers

2021-02-08 Thread Eric Wong
Bruno Haible wrote: > Hi Marc, Ben, > > I need your expertise regarding data structures. > > Assume a program has a signal handler, which needs to share some data > structure with the rest of the program. > > There are two cases: > > (A) Assume that the program is single-threaded. > Then

Re: data structures for use in signal handlers

2021-02-07 Thread Ben Pfaff
On Sun, Feb 7, 2021 at 2:57 PM Bruno Haible wrote: > (2) Let the signal handler work only on immutable copies of the data > structure. Whenever the other code manipulates the data structure, > it creates an immutable copy of it, for the signal handler to use. > Use an