Do task prioritization and/or scheduling parameters have a place in std.Io?

I have a use case where I would like one task to have priority over another task:

In EtherCAT (an industrial ethernet protocol), there is a concept of cyclic data exchange and acyclic data exchange. One can accomplish this with two tasks:

  1. cyclic task, high priority. this task should send an ethernet frame every 2000 us +/- 200 us (for example). For reference, a single ethernet frame (1522 bytes), can take 124 us to transmit at 100 Mbps.
  2. acyclic task, low priority, this task has almost no timing requirements and just needs to send ethernet frames whenever it can fit in to the time left over from the cyclic task

typically I would accomplish this by setting thread priorities at the OS level (like using SCHED_FIFO on PREEMPT_RT linux).

But I am wondering if there is a place for task prioritization (as parameters to groupConcurrent)? Perhaps it only makes sense to define task prioritization in relation to other tasks (hence it only being applied to groupConcurrent)?. But you would likely want a subtask to inherit the priority of its parent task, and the same would be true for mutexes…so maybe you would need to support prioritization across the entire interface…

2 Likes

I personally think you are better off setting the thread priority yourself. There could be a helper function in the threaded Io implementation. I’d very much prefer if this option was not in the interface though.

1 Like

possibly better method of Thread itself, not the part of io

1 Like

Currently prioritization is not part of the async I/O design, and most importantly realtime support is going to be a different feature (we don’t have a roadmap on that, but Andrew has expressed interest in having support for it).

That being said it’s something that we’ll take a look sooner than later, I’m working on a discord replacement (roughly speaking), which includes dealing with audio (which does have some realtime needs), and I’m going to start porting it soon to async I/O also as an opportunity to use a real-world application to guide some design decisions for async I/O.

Andrew has expressed interest in helping with this work so we might end up learning something new as we work on it.

8 Likes