Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thread sleep/wakeup (#31510 updated) #32029

Merged
merged 2 commits into from
May 24, 2019
Merged

Thread sleep/wakeup (#31510 updated) #32029

merged 2 commits into from
May 24, 2019

Conversation

vtjnash
Copy link
Member

@vtjnash vtjnash commented May 14, 2019

This works towards integrating partr scheduler more closely with Julia.

@vtjnash vtjnash added the multithreading Base.Threads and related functionality label May 14, 2019
@vtjnash vtjnash requested review from JeffBezanson and kpamnany May 14, 2019 20:02
@vtjnash vtjnash force-pushed the jn/kp/threadsleep branch from 2fa1969 to 604668c Compare May 14, 2019 21:27
base/task.jl Outdated
@@ -184,6 +184,7 @@ end

# NOTE: you can only wait for scheduled tasks
function wait(t::Task)
t === current_task() && error("deadlock detected")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
t === current_task() && error("deadlock detected")
t === current_task() && error("Possible deadlock detected: Cannot wait on current task")

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's certain deadlock, saying "possible" seems odd

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about user-error, where someone literally does wait(current_task()). But in the end I only care that it is clear which action is not allowed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I ran into this because I did foreach(wait, tasks), then corrupted a huge amount of memory (basically, I just dropped all GC roots) which put current_task into tasks.

In full assertion mode, we could even expand this to check that donenotify forms a DAG, this just constitutes a simple (e.g. inexpensive) subset of the general case. I think other systems do something similar to that, but on a timer?

src/partr.c Outdated Show resolved Hide resolved
src/partr.c Show resolved Hide resolved
src/partr.c Outdated Show resolved Hide resolved
@vtjnash vtjnash force-pushed the jn/kp/threadsleep branch from 604668c to 78017b7 Compare May 16, 2019 15:54
src/partr.c Outdated Show resolved Hide resolved
src/task.c Outdated Show resolved Hide resolved
@vtjnash vtjnash force-pushed the jn/kp/threadsleep branch from b917c98 to 204c29a Compare May 16, 2019 20:31
@JeffBezanson JeffBezanson force-pushed the jn/kp/threadsleep branch 2 times, most recently from 991ab79 to 0c6cac8 Compare May 22, 2019 23:07
@JeffBezanson
Copy link
Member

OK I think this is ready to merge.

@JeffBezanson JeffBezanson merged commit 07364f0 into master May 24, 2019
@StefanKarpinski StefanKarpinski deleted the jn/kp/threadsleep branch May 24, 2019 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
multithreading Base.Threads and related functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants