Thank you for your question.
> Is the ABT_unit_id associated to threads and tasks a number that necessarily increases as new threads/tasks are created?
No. Even in the current implementation, a ULT ID is determined when it is inquired about (e.g., `by ABT_thread_get_id()`), not when a ULT is created. This "inquiry" timing depends on configuration options. In the future, this ID can be replaced by a
"pointer". I do not recommend you rely on the ID to know when ULTs/tasks are created.
> I would like to implement a custom pool that prioritizes running older ULTs over newer ones when possible.
I do not know how strictly you want to control scheduling, but the following might be easy to implement and beneficial.
sched_run():
while (1) {
/* Check old_thread_pool first. */
if (unit = ABT_pool_pop(old_thread_pool)) {
/* If "unit" yields, it is pushed to old_thread_pool.
* If you want, you can push it to very_old_thread_pool. */
ABT_xstream_run_unit(unit, old_thread_pool);
continue;
}
/* Check new_thread_pool if old_thread_pool is empty */
if (unit = ABT_pool_pop(new_thread_pool))
/* If "unit" yields, it is pushed to old_thread_pool.
* Note that Argobots 1.1+ does not need ABT_unit_set_associated_pool()
* https://github.com/pmodels/argobots/pull/317 */
ABT_xstream_run_unit(unit, old_thread_pool);
}
}
The scheduling can cause a deadlock. Please check the solution in the discussion below.
Related discussion: https://lists.argobots.org/pipermail/discuss/2020-August/000085.html
Thanks,
Shintaro