tensorpipe icon indicating copy to clipboard operation
tensorpipe copied to clipboard

Reusing tokens in the SHM reactor may not be a good idea

Open lw opened this issue 4 years ago • 0 comments

The SHM consists of:

  • a map from integers (known as tokens) to functions (let's call them reactions)
  • a shared-memory ringbuffer where the producers are other processes who push tokens and the consumer is the reactor look which runs the corresponding reactions.

At the moment the reactor tries to reuse and "compact" the tokens: each new reaction takes the smallest unused token (just like the kernel with file descriptors).

I've begun to wonder what happens when one reaction is unregistered and another one registered with the same token, and there are still instances of that token in the ringbuffer, intended for the old reaction. Unless I'm missing some safeguard, they should now be triggering the new reaction. This may pose problems unless all reactions are designed to be resilient to spurious wakeups.

lw avatar Apr 20 '20 15:04 lw