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  * \file   cpu_reserve/lib/src/startperiodic.c
00009  * \brief  Helper functions to start periodic execution of threads
00010  *
00011  * \date   11/30/2004
00012  * \author Jork Loeser <jork.loeser@inf.tu-dresden.de>
00013  *
00014  */
00015 /* (c) 2004 Technische Universitaet Dresden
00016  * This file is part of DROPS, which is distributed under the terms of the
00017  * GNU General Public License 2. Please see the COPYING file for details.
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         /* periodic mode start failed. */
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     /* child is ready. Start periodic mode. */
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         /* periodic mode not started. release the client from its NP IPC. */
00064         l4_thread_longjmp(child, *jmpbuf, err);
00065         return err;
00066     }
00067     return 0;
00068 }

CPU reservation server Reference Manual, written by Jork Loeser  © 2004