convenience.c

Go to the documentation of this file.
00001 /*!
00002  * \file   cpu_reserve/lib/src/convenience.c
00003  * \brief  Convenience functions, such as a dump function
00004  *
00005  * \date   11/24/2004
00006  * \author Jork Loeser <jork.loeser@inf.tu-dresden.de>
00007  *
00008  */
00009 /* (c) 2004 Technische Universitaet Dresden
00010  * This file is part of DROPS, which is distributed under the terms of the
00011  * GNU General Public License 2. Please see the COPYING file for details.
00012  */
00013 #include <stdio.h>
00014 #include <l4/log/l4log.h>
00015 #include <l4/util/macros.h>
00016 #include <l4/util/macros.h>
00017 #include <l4/cpu_reserve/sched.h>
00018 #include <l4/env/errno.h>
00019 #include <stdlib.h>
00020 
00021 int l4cpu_reserve_dump(void){
00022     int err, count, i;
00023     l4_threadid_t thread, creator;
00024     int id, prio, period, deadline, wcet;
00025     char *n;
00026     
00027     if((count = l4cpu_reserve_scheds_count())<0){
00028         l4env_perror("l4cpu_reserve_scheds_count()", -count);
00029         return count;
00030     }
00031     printf("CPU Reserve: %d reservations\n", count);
00032     for(i=0;i<count;i++){
00033         if((err = l4cpu_reserve_scheds_get(i, &n, &thread, &creator, &id,
00034                                            &prio, &period, &wcet,
00035                                            &deadline))<0){
00036             l4env_perror("l4cpu_reserve_scheds_get(%d)", -err, i);
00037                     return 1;
00038         }
00039         if(period){
00040             printf(l4util_idfmt"/%d p=%#4x T=%5d C=%5d D=%5d\n",
00041                    l4util_idstr(thread), id, prio, period, wcet, deadline);
00042         } else {
00043             printf(l4util_idfmt"/%d p=%#4x delayed preemption, C=%5d\n",
00044                    l4util_idstr(thread), id, prio, wcet);
00045         }
00046         printf("  name=\"%s\", created by " l4util_idfmt ", nr=%d\n",
00047                n, l4util_idstr(creator), i);
00048         free(n);
00049     }
00050     return 0;
00051 }
00052 

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