User-level dial and get_html update
[akaros.git] / tests / pthread_test.c
index d5af34e..ec17604 100644 (file)
@@ -2,6 +2,7 @@
 #include <pthread.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include <sys/time.h>
 
 /* OS dependent #incs */
 #include <parlib.h>
@@ -68,14 +69,20 @@ int main(int argc, char** argv)
        if (nr_vcores) {
                /* Only do the vcore trickery if requested */
                pthread_can_vcore_request(FALSE);       /* 2LS won't manage vcores */
+               pthread_need_tls(FALSE);
                pthread_lib_init();                                     /* gives us one vcore */
                vcore_request(nr_vcores - 1);           /* ghetto incremental interface */
+               for (int i = 0; i < nr_vcores; i++) {
+                       printd("Vcore %d mapped to pcore %d\n", i,
+                              __procinfo.vcoremap[i].pcoreid);
+               }
        }
 
        /* create and join on yield */
        for (int i = 0; i < nr_yield_threads; i++) {
                printf_safe("[A] About to create thread %d\n", i);
-               assert(!pthread_create(&my_threads[i], NULL, &yield_thread, NULL));
+               if (pthread_create(&my_threads[i], NULL, &yield_thread, NULL))
+                       perror("pth_create failed");
        }
        if (gettimeofday(&start_tv, 0))
                perror("Start time error...");
@@ -96,8 +103,8 @@ int main(int argc, char** argv)
        printf("Nr context switches: %d\n", nr_ctx_switches);
        printf("Time to run: %d usec\n", usec_diff);
        if (nr_vcores == 1)
-               printf("Context switch latency: %f usec\n",
-                      (float)usec_diff / (float)nr_ctx_switches);
-       printf("Context switches / sec: %f\n\n",
-              ((float)nr_ctx_switches / (float)usec_diff) * 1000000);
+               printf("Context switch latency: %d nsec\n",
+                      (int)(1000LL*usec_diff / nr_ctx_switches));
+       printf("Context switches / sec: %d\n\n",
+              (int)(1000000LL*nr_ctx_switches / usec_diff));
 }