emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Multithreading, again and again


From: Stefan Monnier
Subject: Re: Multithreading, again and again
Date: Thu, 20 Oct 2011 14:33:32 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.0.90 (gnu/linux)

> If you want all threads to run freely, then you have to make the Emacs C
> code atomic with respect to any globally-visible change.  I just have no
> confidence that it is this way right now.

Could be.  But even if we don't use true concurrency and only switch at
QUIT we still have the problem of higher-level synchronization: making
every primitive atomic might save us from core dumps but it won't be
sufficient to make the Elisp code work right.  Instead we'll have to
make sure the Elisp code uses proper synchronization, at which point
true concurrency should not be significantly harder.

I think I'm beginning to understand what you mean: you assume an Elisp
concurrency where synchronization is based on locking, so lack of locks
(i.e. an Elisp error) means that one thread can access a slot while
another is modifying it.  In that case, indeed, we'd want to make sure
that a mere Elisp error should not lead to core dumps.

But I assume a system where no matter how buggy the Elisp code, there
a thread will never be able to access a memory slot while it's being
modified by some other thread.

> I think cooperativeness doesn't really eliminate the need for locks,

I hope it will.

> especially because I plan to allow context switches at I/O (and some
> other blocking operations, like mutex acquisition).

Yes, I/O has a yield.  From where I stand a lock is a mutex is a lock.
And I can't think of any reason why you'd want mutexes if you have
cooperative multithreading.


        Stefan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]