* No thread yield when using synchronous processes?
@ 2018-12-12 22:35 Philipp Stephani
2018-12-13 9:47 ` Michael Albinus
0 siblings, 1 reply; 7+ messages in thread
From: Philipp Stephani @ 2018-12-12 22:35 UTC (permalink / raw)
To: help-gnu-emacs
Hi,
it seems like Emacs doesn't yield when using synchronous processes:
(make-thread (lambda () (call-process "sleep" nil nil nil "5s")))
⇒ Emacs freezes for 5 seconds.
Is there a reason for this behavior? The manual claims that Emacs
yields when waiting for process output, but that only seems to be the
case for asynchronous processes. It's of course possible to simulate
synchronous processes with asynchronous processes, but the
asynchronous process API is more difficult to use.
Thanks,
Philipp
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-12 22:35 No thread yield when using synchronous processes? Philipp Stephani
@ 2018-12-13 9:47 ` Michael Albinus
2018-12-13 13:45 ` Eli Zaretskii
2018-12-22 22:48 ` Philipp Stephani
0 siblings, 2 replies; 7+ messages in thread
From: Michael Albinus @ 2018-12-13 9:47 UTC (permalink / raw)
To: Philipp Stephani; +Cc: help-gnu-emacs
Philipp Stephani <p.stephani2@gmail.com> writes:
> Hi,
Hi Philipp,
> it seems like Emacs doesn't yield when using synchronous processes:
>
> (make-thread (lambda () (call-process "sleep" nil nil nil "5s")))
>
> ⇒ Emacs freezes for 5 seconds.
>
> Is there a reason for this behavior? The manual claims that Emacs
> yields when waiting for process output, but that only seems to be the
> case for asynchronous processes.
The manual is clear about this: "when waiting for ... process output
(e.g., during ‘accept-process-output’)". `accept-process-output' is used
only for asynchronous processes.
> Thanks,
> Philipp
Best regards, Michael.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-13 9:47 ` Michael Albinus
@ 2018-12-13 13:45 ` Eli Zaretskii
2018-12-22 22:50 ` Philipp Stephani
2018-12-22 22:48 ` Philipp Stephani
1 sibling, 1 reply; 7+ messages in thread
From: Eli Zaretskii @ 2018-12-13 13:45 UTC (permalink / raw)
To: help-gnu-emacs
> From: Michael Albinus <michael.albinus@gmx.de>
> Date: Thu, 13 Dec 2018 10:47:32 +0100
> Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
>
> > it seems like Emacs doesn't yield when using synchronous processes:
> >
> > (make-thread (lambda () (call-process "sleep" nil nil nil "5s")))
> >
> > ⇒ Emacs freezes for 5 seconds.
> >
> > Is there a reason for this behavior? The manual claims that Emacs
> > yields when waiting for process output, but that only seems to be the
> > case for asynchronous processes.
>
> The manual is clear about this: "when waiting for ... process output
> (e.g., during ‘accept-process-output’)". `accept-process-output' is used
> only for asynchronous processes.
Right. Though perhaps we should say that more explicitly, as "e.g."
could be interpreted like just one example, not necessarily a
representative of a class of examples.
Technically, thread switches happen when Emacs calls 'pselect', which
it does as part of its idle loop. call-process doesn't enter the idle
loop, it busy-waits until the process exits. One could think about
calling the idle loop while we wait, but this will have significant
Emacs-wide effects, which need to be considered carefully before we
decide to do it.
(Btw, pedantically, the example above doesn't really _wait_ for
process output, it explicitly discards that output.)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-13 9:47 ` Michael Albinus
2018-12-13 13:45 ` Eli Zaretskii
@ 2018-12-22 22:48 ` Philipp Stephani
2018-12-23 8:07 ` Michael Albinus
1 sibling, 1 reply; 7+ messages in thread
From: Philipp Stephani @ 2018-12-22 22:48 UTC (permalink / raw)
To: Michael Albinus; +Cc: help-gnu-emacs
Am Do., 13. Dez. 2018 um 10:47 Uhr schrieb Michael Albinus
<michael.albinus@gmx.de>:
>
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> > Hi,
>
> Hi Philipp,
>
> > it seems like Emacs doesn't yield when using synchronous processes:
> >
> > (make-thread (lambda () (call-process "sleep" nil nil nil "5s")))
> >
> > ⇒ Emacs freezes for 5 seconds.
> >
> > Is there a reason for this behavior? The manual claims that Emacs
> > yields when waiting for process output, but that only seems to be the
> > case for asynchronous processes.
>
> The manual is clear about this: "when waiting for ... process output
> (e.g., during ‘accept-process-output’)". `accept-process-output' is used
> only for asynchronous processes.
That parenthetical says "e.g." and not "i.e.", implying that there are
other situations where Emacs waits for process output. Clearly the
"read" call made by call-process is such a situation, so I'd expect
this sentence to apply to them.
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-13 13:45 ` Eli Zaretskii
@ 2018-12-22 22:50 ` Philipp Stephani
0 siblings, 0 replies; 7+ messages in thread
From: Philipp Stephani @ 2018-12-22 22:50 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: help-gnu-emacs
Am Do., 13. Dez. 2018 um 14:46 Uhr schrieb Eli Zaretskii <eliz@gnu.org>:
>
> > From: Michael Albinus <michael.albinus@gmx.de>
> > Date: Thu, 13 Dec 2018 10:47:32 +0100
> > Cc: help-gnu-emacs <help-gnu-emacs@gnu.org>
> >
> > > it seems like Emacs doesn't yield when using synchronous processes:
> > >
> > > (make-thread (lambda () (call-process "sleep" nil nil nil "5s")))
> > >
> > > ⇒ Emacs freezes for 5 seconds.
> > >
> > > Is there a reason for this behavior? The manual claims that Emacs
> > > yields when waiting for process output, but that only seems to be the
> > > case for asynchronous processes.
> >
> > The manual is clear about this: "when waiting for ... process output
> > (e.g., during ‘accept-process-output’)". `accept-process-output' is used
> > only for asynchronous processes.
>
> Right. Though perhaps we should say that more explicitly, as "e.g."
> could be interpreted like just one example, not necessarily a
> representative of a class of examples.
Yes, I think this should be much more explicit. Given that thread
yields are highly observable (buffer contents, point, etc. can
change), it would be best to explicitly document each function that
yields, and state that other functions don't yield.
>
> Technically, thread switches happen when Emacs calls 'pselect', which
> it does as part of its idle loop. call-process doesn't enter the idle
> loop, it busy-waits until the process exits. One could think about
> calling the idle loop while we wait, but this will have significant
> Emacs-wide effects, which need to be considered carefully before we
> decide to do it.
>
> (Btw, pedantically, the example above doesn't really _wait_ for
> process output, it explicitly discards that output.)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-22 22:48 ` Philipp Stephani
@ 2018-12-23 8:07 ` Michael Albinus
2018-12-23 9:58 ` Philipp Stephani
0 siblings, 1 reply; 7+ messages in thread
From: Michael Albinus @ 2018-12-23 8:07 UTC (permalink / raw)
To: Philipp Stephani; +Cc: help-gnu-emacs
Philipp Stephani <p.stephani2@gmail.com> writes:
Hi Philipp,
>> The manual is clear about this: "when waiting for ... process output
>> (e.g., during ‘accept-process-output’)". `accept-process-output' is used
>> only for asynchronous processes.
>
> That parenthetical says "e.g." and not "i.e.", implying that there are
> other situations where Emacs waits for process output. Clearly the
> "read" call made by call-process is such a situation, so I'd expect
> this sentence to apply to them.
You are right, the documentation shall say it explicitly. That's what
Eli has recommended as well.
I've pushed a fix to the emacs-26 branch. If thread switching will be
implemented also for synchronous processes, this might be adapted.
Best regards, Michael-
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: No thread yield when using synchronous processes?
2018-12-23 8:07 ` Michael Albinus
@ 2018-12-23 9:58 ` Philipp Stephani
0 siblings, 0 replies; 7+ messages in thread
From: Philipp Stephani @ 2018-12-23 9:58 UTC (permalink / raw)
To: Michael Albinus; +Cc: help-gnu-emacs
Am So., 23. Dez. 2018 um 09:07 Uhr schrieb Michael Albinus
<michael.albinus@gmx.de>:
>
> Philipp Stephani <p.stephani2@gmail.com> writes:
>
> Hi Philipp,
>
> >> The manual is clear about this: "when waiting for ... process output
> >> (e.g., during ‘accept-process-output’)". `accept-process-output' is used
> >> only for asynchronous processes.
> >
> > That parenthetical says "e.g." and not "i.e.", implying that there are
> > other situations where Emacs waits for process output. Clearly the
> > "read" call made by call-process is such a situation, so I'd expect
> > this sentence to apply to them.
>
> You are right, the documentation shall say it explicitly. That's what
> Eli has recommended as well.
>
> I've pushed a fix to the emacs-26 branch. If thread switching will be
> implemented also for synchronous processes, this might be adapted.
Thanks!
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2018-12-23 9:58 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-12-12 22:35 No thread yield when using synchronous processes? Philipp Stephani
2018-12-13 9:47 ` Michael Albinus
2018-12-13 13:45 ` Eli Zaretskii
2018-12-22 22:50 ` Philipp Stephani
2018-12-22 22:48 ` Philipp Stephani
2018-12-23 8:07 ` Michael Albinus
2018-12-23 9:58 ` Philipp Stephani
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.