# Is it possible to enforce scheduler to instantly yield to specific task?

**URL:** <https://discourse.julialang.org/t/is-it-possible-to-enforce-scheduler-to-instantly-yield-to-specific-task/123133>\
**Category:** General Usage\
**Tags:** multithreading\
**Created:** [November 27, 2024, 12:13am UTC](https://discourse.julialang.org/t/is-it-possible-to-enforce-scheduler-to-instantly-yield-to-specific-task/123133 "2024-11-27T00:13:27Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pedro](https://avatars.discourse-cdn.com/v4/letter/p/919ad9/32.png) [@Pedro](https://discourse.julialang.org/u/Pedro)\
**Post date:** [November 27, 2024, 12:13am UTC](https://discourse.julialang.org/t/is-it-possible-to-enforce-scheduler-to-instantly-yield-to-specific-task/123133/1 "2024-11-27T00:13:27Z")

</div>

I writing a program with the aim of real-time and low-latency data processing that have multiple tasks running on a single thread. For two of those tasks, let’s call them `A` and `B`, I need a very tight synchronization on scheduler. If task A performs certain operation, it puts a data into the `c::Channel` and `yield()`. Task `B` is already running and always wait for incoming data from `c::Channel` in the line with `take!(c)`. I need task `B` to be scheduled as next just after task `A` yields.

For visualization, when `A` puts data into channel, I am getting tasks executed by scheduler in the following order: `A`, `C`, `D`, `E`, `F`, `B`. There are always tasks run between `A` and `B`. I need the order to look like this: `A`, `B`, …

Is it possible to achieve such behavior in Julia?

From the docs, functions `yield(t::Task)` and `yieldto(t::Task)` looked promising, but I can not successfully use them.

I am running x86\_64 Linux (Glibc) and Julia v1.11.1 if that matters.
