bug-gnu-emacs
[Top][All Lists]
Advanced

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

bug#25214: 26.0.50; Interacting with user from threads other than the pr


From: Michael Albinus
Subject: bug#25214: 26.0.50; Interacting with user from threads other than the primary
Date: Tue, 18 Sep 2018 10:21:35 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Eli Zaretskii <eliz@gnu.org> writes:

Hi Eli,

>> In order to fix the problem of reading input in a non-primary thread, we
>> need a new function which request I/O control to the current thread. It
>> needs
>>
>> * to request control for the keyboard. This could be indicated by a
>>   signal to the main thread, which is *not* an error signal but a
>>   special one, let's call it `thread-set-keyboard'.
>>
>> * to handle this signal in `thread-handle-event', by calling a
>>   respective function (let's call it `thread--set-keyboard'). This
>>   function sets the struct event thread to the thread which has
>>   delivered by the `thread-set-keyboard' signal. Next time fd_mask is
>>   prepared, the keyboard fd would be taken into account for the
>>   requesting thread.
>>
>> * to stop/recall the recent pselect for the main thread in order to free
>>   the keyboard fd. Don't know how to do this.
>>
>> * to provide a mechanism which resets the thread struct field of the
>>   keyboard fd to NULL, in order to let the main thread use the
>>   keyboard. Here I have also no idea how to do this.
>
> It's not all we need (remember all that talk about serializing access
> to the echo area?), but it's a beginning.

Exactly.

> And the crucial piece is bullet #3, because thread-signal will not
> interrupt the pselect call.  And if we are not too lucky, the pselect
> call could have been made with a long timeout.  So this is the first
> obstacle to negotiate.

Yes. There is quit_throw_to_read_char, but this would quit the (main)
thread, which is not what we want.

> So what means do we have to interrupt a pselect call from another
> thread?
>
> (I'm not sure I understand why you thought we'd need bullet #2, btw.
> Once we interrupt the pselect call, the main thread should become
> stuck trying to take the global lock, so I don't think we need any
> trickery here, because the other thread, which is running, will have
> arranged for it to be the current thread.)

Shouldn't there be several read_char calls in parallel? Bullet #2 is
just a machinery to switch to the main thread, that's all. If we could
manipulate the main thread from inside current thread, we wouldn't need this.

> Thanks.

Best regards, Michael.





reply via email to

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