// Wait on all syscalls within this async call. TODO - timeout or something? int waiton_group_call(async_desc_t* desc, async_rsp_t* rsp) { syscall_rsp_t syscall_rsp; syscall_desc_t* d; int retval = 0; int err = 0; if (!desc) { errno = EINVAL; return -1; } while (!(TAILQ_EMPTY(&desc->syslist))) { d = TAILQ_FIRST(&desc->syslist); err = waiton_syscall(d); // TODO: processing the retval out of rsp here. might be specific to // the async call. do we want to accumulate? return any negative // values? depends what we want from the return value, so we might // have to pass in a function that is used to do the processing and // pass the answer back out in rsp. //rsp->retval += syscall_rsp.retval; // For example retval = MIN(retval, err); // remove from the list and free the syscall desc TAILQ_REMOVE(&desc->syslist, d, next); POOL_PUT(&syscall_desc_pool, d); } // run a cleanup function for this desc, if available if (desc->cleanup) desc->cleanup(desc->data); // free the asynccall desc POOL_PUT(&async_desc_pool, desc); return err; }
int main(int argc, char** argv){ int pid = sys_getpid(); char testme = 't'; printf ("single thread - init arsc \n"); syscall_desc_t* sysdesc[2]; syscall_rsp_t sysrsp; init_arc(&SYS_CHANNEL); printf ("single thread - init complete \n"); // cprintf_async(&desc1, "Cross-Core call 1, coming from process %08x\n", pid); sysdesc[0] = sys_cputs_async(&testme, 1, NULL, NULL); sysdesc[1] = sys_cputs_async(&testme, 1, NULL, NULL); printf ("single thread - call placed \n"); //ignore return value assert(-1 != waiton_syscall(sysdesc[0])); assert(-1 != waiton_syscall(sysdesc[1])); printf ("single thread - dummy call \n"); }
void *syscall_thread(void* arg) { char testme ='a'; char buf[20] = {0}; sprintf(buf, "%d", (pthread_self()->id % 10) ); char tid = buf[0]; syscall_desc_t* sysdesc; sysdesc = sys_cputs_async(&tid, 1, NULL, NULL); assert (-1 != waiton_syscall(sysdesc)); }