Macaulay2 / Macaulay2/M2

taskResult within schedule causes freezing

Open
#4,157 2 comments 1 reaction 0 assignees View on GitHub
threads
Dominant language
Macaulay2
Stars
435
Forks
297
Avg merge
4d 20h
Merged PRs (30d)
11

Description

I believe this experiment indicates a critical problem in how tasks are handled:
```m2
notify = true
allowableThreads = 5
apply(
apply(allowableThreads,
i -> schedule(() -> (
sleep 1;
taskResult schedule(() -> nanosleep 100)))
),
taskResult)
```
Result:
```m2
i3 : apply(
apply(allowableThreads,
i -> schedule(() -> (
sleep 1;
taskResult schedule(() -> nanosleep 100)))
),
taskResult)
--task 1 started
--task 2 started
--task 3 started
--task 4 started
[frozen]
```
In a sensible system, once a thread handling one of the 5 tasks encounters "taskResult" on an _unassigned_ task, the thread should assign itself to the inner task until its finished, then return one level higher to finish the main task.

Here, the freeze happens because there are idle threads that are waiting for other _unassigned_ tasks to finish, rather than switching over to finish those tasks.

In practice this is very easy to encounter whenever you have tasks that depend on other tasks.

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by reproducing the Macaulay2 snippet in the issue and tracing how the scheduler handles taskResult when the inner task is unassigned. The work is done when dependent tasks complete without freezing and the outer task resumes afterward.

Written by the indexing model from the issue text.

Assessment

Domain
distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.