On Wed, May 10, 2023 at 12:47 PM Nadav Har'El <[email protected]> wrote:

>
>     sched::thread *t;
>     if (pid == 0) {
>         t = sched::thread::current();
>     } else {
>         t = sched::thread::find_by_id(pid);
>         if (!t) {
>             errno = ESRCH;
>             return -1;
>         }
>         // TODO: After the thread was found, if it exits the code below
>         // may crash. Perhaps we should have a version of find_by_id(),
>         // with_thread_by_id(pid, func), which holds thread_map_mutex while
>         // func runs.
>     }
>
I think you can just use exactly that code, as is (I guess with the same
> TODO, which is still valid).
>

I looked again, and we actually have a function exactly like I wished for
in the TODO :-)
with_thread_by_id() from include/osv/sched.hh. I added it in commit
f142ccf42f5d4465e827e3ff0a330b62d070755d
six years ago - I guess I fulfilled my own wish but then forgot to go back
to where I wanted to use it.

So you should probably use the with_thread_by_id() function.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osv-dev/CANEVyjuBGKp1i1ED7rUgETxb2yw2dvujhv5HsJ-M61j5rcviEw%40mail.gmail.com.

Reply via email to