ControlCore-Project / concore

Framework for Closed-Loop peripheral neuromodulation control systems
https://control-core.readthedocs.io
GNU Lesser General Public License v2.1
9 stars 20 forks source link

Expensive nodes might skip over inputs #64

Closed CGDogan closed 1 year ago

CGDogan commented 1 year ago

Consider:


 ┌►A─-
 │   │
 │   │
 |─B◄┘
   │
   │
   ▼
   X
   │
   │
   ▼
   out

(A and B form a loop, X takes input from the loop)

When X is an expensive operation, it misses some inputs. This should be documented since perhaps that's not what all researchers want.

This seems to not contradict with the relevant text in the research paper:

Later, concore assumes that only one of three things happens: 1) the file is identical to the last time it was read (and so the polling continues); 2) the file’s contents have changed (and so the polling stops); or 3) the file has zero bytes because the file has been reopened for write but has not yet been overwrit- ten (and again the polling continues). If this assumption is satisfied, concore synchronizes the nodes correctly

There are two ways to solve this: block the loop (globally, when incrementing the delta, which is inefficient or locally) when a writing is happening without the previous output having been read, or queue it.

I discovered this while working on [2] A real-time computing support for concore., so I can tackle this along with the rest of the task this summer.

What I propose is two new functions, for read and write, where read empties a file once it's read, and write delays writing until the file being written to is empty (to be used for any edges the user chooses).

CGDogan commented 1 year ago

Weird, I tried it today as well and wasn't able to reproduce it today.

EDIT: I have no clue how I managed to see it skip over inputs: