[Unison-hackers] mutex
Benjamin Pierce
bcpierce at cis.upenn.edu
Wed Apr 19 05:11:42 EDT 2006
> There is a crash using the Mac GUI that seems to occur when one thread
> updates a reconItem (actually stateItem.whatHappened), and another
> thread reads from it at the same time (try scrolling up with the
> up-arrow through the reconitem table while a sync is in progress). It
> should be easily fixable with a mutex, available as part of the ocaml
> threads libraries. However, I see that significant effort has gone
> into avoiding use of those libraries in Unison, and using lwt/*
> instead. Is there an alternative mutex implementation or workaround I
> can use?
The history of the lightweight threads (lwt) stuff is like this.
Originally, Unison was completely single-threaded. When we began
using it seriously, we found that the transfer speed was
unsatisfactory because of all the handshaking involved in our (rather
simple and paranoid) data transfer protocol. So we tried
multithreading the transfer phase. Unfortunately, we discovered (as
so many have before) that trying to add threads to an application
that was not designed to be threadsafe from the start was just too
hard for us (even too hard for Jerome, which is saying something!).
So we moved to an intermediate position where we rolled our own
"lightweight" thread package that does its own, non-preemptive
scheduling.
My guess is that protecting the Unison thread(s) from the GUI thread
with a regular mutex should work well.
Regards,
Benjamin
More information about the Unison-hackers
mailing list