freenode/#sbcl - IRC Chatlog
Search
21:07:43
jeosol
I just posed a question over at #lisp channel but since it's sbcl specific, I figure this channel is more specific.
21:09:09
jeosol
basically, i have X threads performing some calculations, one of them acquires a lock on a resource and an error results while perform calculation and the lock is not released and the other threads wait. I run on the shell and would like to just kill that thread so the others can proceed
21:12:33
pkhuong
jeosol: use a call-with-foo wrapper to always release the lock when you unwind / return.
21:13:13
pkhuong
that still leaves you open to broken state invariants if you crash in the middle of a critical section.
21:15:15
jeosol
thanks for the suggestions. What you are suggesting is to have some kind of combination of a wrapper and unwind-protect to ensure things are released in the event of an error?
21:16:42
jeosol
Not sure by what you mean by SBCL or CL specific. The calculations are still being performed within CL/SBCL. It's just that in some instances, I get inconsistent arithmetic operations (.e.g, (/ 0 0)) and others I am still catching
21:20:06
dougk_
jeosol: pkhuong means, I think, that it's not a good idea to expect that externally killing a thread that had a acquired a lock is either (1) possible at all; (2) going to release the lock; (3) not mess up invariants guarded by the lock; (4) going to anything sane whatsoever. Some combination of that.
21:21:42
jeosol
dougk_: thanks. I guess that is why I have not been able to resolve it when things stall. I will try to modify workflow to use the suggestion above.
21:21:51
dougk_
Xach: i'm able to compile hu.dwim.delico with a hack I just pushed; will write them an email
21:23:15
pkhuong
the immediate solution to the problem is to use (call-)with-foo; using scoped mutex locks is a standard good idea, not just in CL.
21:24:38
pkhuong
and the solution is to avoid (large) critical sections that can fail... which is also language-independent advice.
21:34:37
jeosol
pkhoung: thanks for the suggestions. Did some quick googling and I understand better.
21:36:00
jeosol
if anyone is interested on scoped locks I found this somewhat old paper (though in C++) http://www.cs.wustl.edu/~schmidt/PDF/ScopedLocking.pdf