]> rtime.felk.cvut.cz Git - frescor/frsh.git/commitdiff
Corrected use of the thread wrapper in AQuoSA frsh implementation.
authorPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 20 Jan 2009 23:20:46 +0000 (00:20 +0100)
committerPavel Pisa <pisa@cmp.felk.cvut.cz>
Tue, 20 Jan 2009 23:20:46 +0000 (00:20 +0100)
Same as for cgroup

resources/cpu_aquosa/lib/frsh_aqcpu.c
resources/cpucg/lib/frsh_cpucg.c

index d1d0e24ca391eff729489fa47c9099e2b2da8a11..16cb1a0cb1e598a8084ee6e6aa084bac76014fe8 100644 (file)
@@ -194,17 +194,23 @@ static void* wrapper_pthread(void *arg)
 {
        wrapper_pthread_arg_t* pth = (wrapper_pthread_arg_t*) arg;      
        frsh_thread_id_t* thread_id = pth->thread_id;   
+       void *thread_arg = pth->pthread_arg;
+       frsh_thread_code_t thread_code = pth->pthread_code;
+       int  errcode;
        
        *thread_id = fosa_thread_self();
        /* bind this thread to vres */
-       pth->errcode = frsh_thread_bind(pth->vres, *thread_id);
+       errcode = frsh_thread_bind(pth->vres, *thread_id);
+       pth->errcode = errcode;
        
        sem_post(pth->stopper); 
-       if (pth->errcode) /* vres binding was not successful */
+       /* No access to pth is allowed after this point, it can vanish already */
+
+       if (errcode) /* vres binding was not successful */
                return NULL;
 
        /* execute thread function */   
-       return pth->pthread_code(pth->pthread_arg);
+       return thread_code(thread_arg);
 }
 
 /*
index 0913e5b0e0c6e0ca4b4be760d5b500f98003878e..1cf3f91123698bf490df7795be70649d7998ff9a 100644 (file)
@@ -208,7 +208,7 @@ static void* wrapper_pthread(void *arg)
        wrapper_pthread_arg_t* pth = (wrapper_pthread_arg_t*) arg;      
        frsh_thread_id_t* thread_id = pth->thread_id;   
        void *thread_arg = pth->pthread_arg;
-       frsh_thread_code_t pthread_code = pth->pthread_code;
+       frsh_thread_code_t thread_code = pth->pthread_code;
        int  errcode;
        
        *thread_id = fosa_thread_self();
@@ -223,7 +223,7 @@ static void* wrapper_pthread(void *arg)
                return NULL;
 
        /* execute thread function */   
-       return pthread_code(thread_arg);
+       return thread_code(thread_arg);
 }
 
 /*