[Top][All Lists]

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

Re: try-this-for ?

From: tomas
Subject: Re: try-this-for ?
Date: Thu, 18 Jan 2018 13:43:37 +0100
User-agent: Mutt/1.5.21 (2010-09-15)

Hash: SHA1

On Thu, Jan 18, 2018 at 01:00:49PM +0100, Emanuel Berg wrote:
> tomas wrote:
> > Up to now, Emacs Lisp's model of concurrency
> > seems to be explicitly cooperative.
> "seems to be explicitly" :) ?

(seems to be (explicitly cooperative))

With explicitly I meant that control is not
taken away behind a process's back, but the
process has to explicitly yield control.

> True concurrency isn't possible even for
> multicore architectures IIUC.

To a certain extent yes: the processors/cores have
to cooperate to access common resources (e.g. memory),
but as long as they are operating e.g. from local
cache they do run in parallel.

> The perceived concurrency, how does that work
> if it isn't Unix-style preemptive with
> priorities and a scheduler etc.?

As far as I know, the only (implicit) yield point
in Emacs is the event loop, but many things fit
in there: waiting for key events, waiting for file
descriptors to become readable/writable (e.g.
communicating with (operating system) subprocesses,
reacting to POSIX signals, the idle timer, etc.

> For example, with `list-processes', is that
> really all cooperative stuff handled by the
> idle timer?

Not really the idle timer: this one is (probably?)
triggered from the central event loop, as the others.

But the great Eli has answered that already in emacs
devel some moons ago [1]. Turns out that what I call
"event loop" is called the "input queue". If you have
a lengthy calculation and want the other things (user
input, but also file notifications, communication
via sockets, etc) to "keep running", you have to
explicitly (that's the "explicit" part in what I
labeled as "explicitly cooperative") give a chance
to this input queue to run from time to time.
Perhaps (sit-for 0) is your friend (it would
trigger a redisplay), perhaps something else.


- -- tomás
Version: GnuPG v1.4.12 (GNU/Linux)


reply via email to

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