startperiodic.c
Go to the documentation of this file.00001 #include <l4/sys/ipc.h>
00002 #include <l4/sys/rt_sched.h>
00003 #include <l4/util/setjmp.h>
00004 #include <l4/cpu_reserve/sched.h>
00005 #include <l4/log/l4log.h>
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 int l4cpu_reserve_wait_periodic(l4_threadid_t parent){
00021 l4_msgdope_t result;
00022 int err;
00023 l4_thread_jmp_buf jmpbuf;
00024
00025 if((err=l4_thread_setjmp(jmpbuf))==0){
00026 #if 0
00027 l4_umword_t dummy;
00028 err = l4_ipc_call(l4_next_period_id(parent), L4_IPC_SHORT_MSG,
00029 0, (l4_umword_t)&jmpbuf,
00030 L4_IPC_SHORT_MSG, &dummy,&dummy,
00031 L4_IPC_RECV_TIMEOUT_0, &result);
00032 #else
00033 err = l4_ipc_send(l4_next_period_id(parent), L4_IPC_SHORT_MSG,
00034 0, (l4_umword_t)&jmpbuf,
00035 L4_IPC_RECV_TIMEOUT_0, &result);
00036 #endif
00037 if(err==L4_IPC_RETIMEOUT) return 0;
00038 return -err;
00039 } else {
00040
00041 return err;
00042 }
00043 }
00044
00045 int l4cpu_reserve_wait_periodic_ready(int mode,
00046 l4_threadid_t child,
00047 l4_kernel_clock_t clock){
00048 l4_msgdope_t result;
00049 l4_umword_t dummy;
00050 l4_thread_jmp_buf *jmpbuf;
00051 int err;
00052
00053 if((err = l4_ipc_receive(child, L4_IPC_SHORT_MSG, &dummy,
00054 (l4_umword_t*)&jmpbuf,
00055 L4_IPC_NEVER, &result))!=0){
00056 return -err;
00057 }
00058
00059 if(mode==L4_RT_BEGIN_PERIODIC)
00060 err = l4cpu_reserve_begin_strictly_periodic(child, clock);
00061 else err = l4cpu_reserve_begin_minimal_periodic(child, clock);
00062 if(err!=0){
00063
00064 l4_thread_longjmp(child, *jmpbuf, err);
00065 return err;
00066 }
00067 return 0;
00068 }