Hi - In this commit:
> From 6fa0076f2d4459dcb80e284b97e542696b548252 Mon Sep 17 00:00:00 2001 > From: Christopher Koch <[email protected]> > Date: Thu, 4 Aug 2016 18:31:03 -0700 > Subject: Moved IDs and added list of threads in uthreads. > > IDs are moved from pthreads to uthreads and uthreads now maintain a list of > current threads. > > Change-Id: I87310e765ad0ead25a45f41074e09f74835383df > Signed-off-by: Christopher Koch <[email protected]> > diff --git a/user/parlib/uthread.c b/user/parlib/uthread.c > index 520c94b4d2a8..a396482abe2d 100644 > --- a/user/parlib/uthread.c > +++ b/user/parlib/uthread.c > @@ -55,8 +61,18 @@ static void uthread_init_thread0(struct uthread *uthread) > /* need to track thread0 for TLS deallocation */ > uthread->flags |= UTHREAD_IS_THREAD0; > uthread->notif_disabled_depth = 0; > - /* setting the uthread's TLS var. this is idempotent for SCPs (us) */ > + /* setting the uthread's TLS var. this is idempotent for SCPs (us) */ > __vcoreid = 0; > + uthread_assign_id(uthread); > +} This will have issues as soon as you link in a 2LS that isn't thread0. The reason is that init_thread0 is called twice, once for thread0, and then again for any other 2LS that links in (e.g. pthreads). If you run uthread_assign_id, it'll assign a new ID for the same old thread and, even worse, free the first thread0 while it is still on the list. Instead of assigning the ID with the helper, go into uthread_track_thread0(). In the if branch of this code: /* We might have a basic uthread already installed (from a prior call), so * free it before installing the new one. */ if (current_uthread) free(current_uthread); Before freeing, you can remove the old current_uthread from the list. I'd also just manually assign the thread ID (0, preferably), instead of getting another from uthread_assign_id(), so the thread ID doesn't change depending on which 2LS we're using. > +static void uthread_assign_id(struct uthread *uthread) > +{ > + /* Assign a thread ID and add to thread list. */ > + spin_pdr_lock(&thread_list_lock); > + uthread->id = __get_next_tid(); This is the only time that __get_next_tid() is called. We can just move that helper directly into here. > + LIST_INSERT_HEAD(&all_uthreads, uthread, entry); > + spin_pdr_unlock(&thread_list_lock); > } > -- You received this message because you are subscribed to the Google Groups "Akaros" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. For more options, visit https://groups.google.com/d/optout.
