Signal with different u_ctx if current_uthread set
authorKevin Klues <klueska@cs.berkeley.edu>
Sat, 7 Jun 2014 02:49:19 +0000 (19:49 -0700)
committerKevin Klues <klueska@cs.berkeley.edu>
Sat, 7 Jun 2014 02:51:02 +0000 (19:51 -0700)
When current uthread is set, we should not use the ctx attached to the
uthread, but rather the one stored in the vcpd.

user/pthread/pthread.c

index c039a33..192dfb8 100644 (file)
@@ -74,10 +74,17 @@ static void __pthread_trigger_posix_signal(pthread_t thread, int signo,
                                            struct siginfo *info)
 {
        int vcoreid = vcore_id();
+       struct user_context *ctx;
+       if (current_uthread) {
+               struct preempt_data *vcpd = vcpd_of(vcoreid);
+        ctx = &vcpd->uthread_ctx;
+       } else {
+               ctx = &thread->uthread.u_ctx;
+       }
+
        void *temp_tls_desc = get_tls_desc(vcoreid);
-       struct uthread *uthread = (struct uthread*)thread;
-       set_tls_desc(uthread->tls_desc, vcore_id());
-       trigger_posix_signal(signo, info, &uthread->u_ctx);
+       set_tls_desc(thread->uthread.tls_desc, vcoreid);
+       trigger_posix_signal(signo, info, ctx);
        set_tls_desc(temp_tls_desc, vcoreid);
 }