monitor.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include <stdio.h>
00014 #include <l4/env/errno.h>
00015 #include <l4/util/macros.h>
00016 #include "monitor.h"
00017 #include "sched.h"
00018
00019 int enable_rt_mon;
00020
00021 static inline int thread_equal(l4_threadid_t a, l4_threadid_t b){
00022 return a.id.lthread == b.id.lthread &&
00023 a.id.task == b.id.task;
00024 }
00025
00026
00027
00028
00029
00030 int monitor_start(const sched_t *sched, const l4_threadid_t *thread){
00031 int i;
00032
00033
00034
00035 lock_scheds();
00036 for(i=0;i<sched_cur_threads;i++){
00037 if(thread_equal(scheds[i]->thread, *thread) &&
00038 scheds[i]->id == 1 && !is_dp(scheds[i])){
00039
00040
00041 char name[RT_MON_NAME_LENGTH];
00042 snprintf(name, sizeof(name), "DL: %s", scheds[i]->name);
00043 scheds[i]->dl_hist = rt_mon_hist_create(0, scheds[i]->wcet,
00044 300,
00045 name, "us", "occ.",
00046 RT_MON_THREAD_TIME);
00047 unlock_scheds();
00048 return 0;
00049 }
00050 }
00051 unlock_scheds();
00052 return -L4_ENOTFOUND;
00053 }
00054
00055
00056
00057
00058
00059
00060
00061 void monitor_thread_dl(l4_threadid_t *thread, l4_cpu_time_t time){
00062 int i;
00063
00064
00065
00066 lock_scheds();
00067 for(i=0;i<sched_cur_threads;i++){
00068 if(thread_equal(scheds[i]->thread, *thread) &&
00069 scheds[i]->id == 1 && !is_dp(scheds[i]) &&
00070 scheds[i]->dl_hist){
00071
00072 if(scheds[i]->dl_old){
00073 rt_mon_hist_insert_data(scheds[i]->dl_hist,
00074 time-scheds[i]->dl_old,1);
00075 }
00076 scheds[i]->dl_old = time;
00077 goto e_back;
00078 }
00079 }
00080 e_back:
00081 unlock_scheds();
00082 }
00083
00084