Adding test case for multproducer async calls.
[akaros.git] / tests / arsc_test.c
1 #include <parlib.h>
2 #include <vcore.h>
3 #include <ros/syscall.h>
4 #include <arc.h>
5 #include <stdio.h>
6
7 syscall_desc_t* sys_cputs_async(const char *s, size_t len,                                             
8                      void (*cleanup_handler)(void*), void* cleanup_data)
9 {                                                                                                                     
10     // could just hardcode 4 0's, will eventually wrap this marshaller anyway                                         
11         syscall_desc_t* desc;
12     syscall_req_t syscall = {REQ_alloc, cleanup_handler, cleanup_data,
13                                                         SYS_cputs,{(uint32_t)s, len, [2 ... (NUM_SYSCALL_ARGS-1)] 0} };                          
14     syscall.cleanup = cleanup_handler;                                                                                  
15     syscall.data = cleanup_data;                                                                                        
16     async_syscall(&syscall, &desc);
17         return desc;
18 }
19
20 int main(int argc, char** argv){
21         int pid = sys_getpid();
22         char testme = 't';
23         printf ("single thread - init arsc \n");
24         syscall_desc_t* sysdesc[2];
25         syscall_rsp_t sysrsp;
26         init_arc(&SYS_CHANNEL);
27
28         printf ("single thread - init complete \n");
29         // cprintf_async(&desc1, "Cross-Core call 1, coming from process %08x\n", pid);
30         sysdesc[0] = sys_cputs_async(&testme, 1, NULL, NULL);
31         sysdesc[1] = sys_cputs_async(&testme, 1, NULL, NULL);
32
33         printf ("single thread - call placed \n");
34         waiton_syscall(sysdesc[0], &sysrsp);
35         waiton_syscall(sysdesc[1], &sysrsp);
36         printf ("single thread - dummy call \n");       
37 }