Re: [PATCH v2 00/23] All-stop on top of non-stop

Pedro Alves
2015-04-13T16:23:12Z

On 04/13/2015 05:16 PM, Yao Qi wrote:
> Pedro Alves <palves@redhat.com> writes:
>
> Pedro,
> I can't apply this patch cleanly, so unable to test it for
> aarch64-linux. I'll give a test once your V3 is posted, in which this
> patch is included, I assume.

Oh, sorry for not being clearer, I didn't meant for you to try
the patch, only to say that I got a handle in the issue, to avoid you
wasting any time trying to debug it, in case you felt compelled to do
that. I'll post something testable once I clean things up a bit more.

>
>> + /* If we have events pending, go through handle_inferior_event
>> + again, picking up a pending event at random. This avoids
>> + thread starvation. */
>> + pending = iterate_over_threads (resumed_thread_with_pending_status,
>> + NULL);
>
> A quick question, I don't see how pending events are picked up at
> random. Do you mean target_ops->to_wait, such as linux_nat_wait, can
> get event at random?
>

It's done in do_target_wait. So we go back to the event loop,
and end up in fetch_inferior_event again. In the series/branch, that
fetch_inferior_event calls do_target_wait instead of target_wait directly:

/* Wrapper for target_wait that first checks whether threads have
pending status to report before actually asking the target for more
events. */

static ptid_t
do_target_wait (ptid_t ptid, struct target_waitstatus *status, int options)
{

which calls random_pending_event_thread, and that is what takes care
of the randomization.

Thanks,
Pedro Alves