On Thu, Feb 2, 2017 at 12:12 AM, Nadav Har'El <n...@scylladb.com> wrote:

> +        sched::with_all_threads([&](sched::thread &t) {
>
>> +            if (t.id() == tid && t.get_status() !=
>> sched::thread::status::terminated) {
>> +                    th_finished = "0";
>> +            }
>> +        });
>>
>
> Thanks. This would work but is inefficient (O(N) in the number of threads
> in the system), which is worrying when you consider that you'll probably
> poll this function many times to figure out when the thread exited (and
> usually get a response that it didn't).
>
> We have the sched::thread::find_by_id(tid) function which is much more
> efficient (O(1)) in finding the thread with the given id.
> But a drawback of that function is that theoretically it can return a
> thread which will exit before you get around to testing it.
>
> I think the solution is to create a function 
> sched::thread::with_thread_by_id(tid,
> func) which, like with_all_threads holds the thread_map_mutex while running
> the given function, and use that.
>

Hi,

I just sent to the mailing list a patch adding a function
sched::with_thread_by_id() like I suggested above.

Can you please see that it does what you need, and confirm it actually
works for you?

Thanks!
Nadav.

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to