You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
writer comes in and would like to take the write lock, while it cant, since there is already reader here. thus writer has to wait for the condition, without releasing the main lock
reader now finish work, and want to return the read lock, but it cant, since the main lock is already taken by writer
include("ReadWriteLocks.jl")
using.ReadWriteLocks
functionreaderTask(rwLock)
rLock =read_lock(rwLock)
lock!(rLock)
tryprintln("$(current_task()): using read lock")
finallyunlock!(rLock)
endendfunctionwriterTask(rwLock)
wLock =write_lock(rwLock)
lock!(wLock)
tryprintln("$(current_task()): using write lock")
finallyunlock!(wLock)
endendfunctionmain()
l =ReadWriteLock()
tasks =Array{Task, 1}(undef, 3)
# freeze everyonelock!(write_lock(l))
try
tasks[1] = Threads.@taskreaderTask(l)
tasks[2] = Threads.@taskreaderTask(l)
tasks[3] = Threads.@taskwriterTask(l)
schedule.(tasks)
finally# now releaseunlock!(write_lock(l))
end
(l, tasks)
end
(l, t) =main()
istaskstarted.(t)
istaskdone.(t)
run with julia -t 2 main.jl
juliaversion: 1.8.0-rc1
expected output: all tasks should be finished, program exits immediately
actual output: program hangs
The text was updated successfully, but these errors were encountered:
the scenario is,
starts at line 80
and here is the mre(or i'm using it wrong?)
run with
julia -t 2 main.jl
juliaversion: 1.8.0-rc1
expected output: all tasks should be finished, program exits immediately
actual output: program hangs
The text was updated successfully, but these errors were encountered: