Kernel alarms pass the alarm ID
[akaros.git] / tests / arsc_mt.c
index e5fee5e..218e545 100644 (file)
@@ -1,4 +1,5 @@
-#include <rstdio.h>
+#ifdef CONFIG_ARSC_SERVER
+#include <stdio.h>
 #include <stdlib.h>
 #include <pthread.h>
 #include <unistd.h>
@@ -8,7 +9,7 @@
 #include <arc.h>
 #include <stdio.h>
 
-#define NUM_THREADS 4 
+#define NUM_THREADS 4
 
 pthread_t t1;
 
@@ -17,26 +18,18 @@ async_desc_t desc1;
 syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
                      void (*cleanup_handler)(void*), void* cleanup_data)
 {                                                                                                                     
-    // could just hardcode 4 0's, will eventually wrap this marshaller anyway                                         
-       syscall_desc_t* desc;
-    syscall_req_t syscall = {REQ_alloc, cleanup_handler, cleanup_data,
-                                                       SYS_cputs,{(uint32_t)s, len, [2 ... (NUM_SYSCALL_ARGS-1)] 0} };                          
-    syscall.cleanup = cleanup_handler;                                                                                  
-    syscall.data = cleanup_data;
-    async_syscall(&syscall, &desc);
-       return desc;
+       return arc_call(SYS_cputs, s, len);
 }
 
 void *syscall_thread(void* arg)
-{      
+{
        char testme ='a';
        char buf[20] = {0};
-       sprintf(buf, "%d", pthread_self()->id );
+       sprintf(buf, "%d", (pthread_self()->id % 10) );
        char tid = buf[0];
        syscall_desc_t* sysdesc;
-       syscall_rsp_t sysrsp;
        sysdesc = sys_cputs_async(&tid, 1, NULL, NULL);
-       waiton_syscall(sysdesc, &sysrsp);
+       assert (-1 != waiton_syscall(sysdesc));
 }
 
 int main(int argc, char** argv){
@@ -48,9 +41,12 @@ int main(int argc, char** argv){
        for (int i = 0; i < NUM_THREADS ; i++)
                pthread_create(&my_threads[i], NULL, &syscall_thread, NULL);
        
-       for (int i = 0; i < NUM_THREADS; i++)
+       for (int i = 0; i < NUM_THREADS; i++){
                pthread_join(my_threads[i], NULL);
+       }
 
        printf("multi thread - end\n");
 }
-
+#else
+int main(){};
+#endif