From 974e24aaa13b710713b1654b11ffeefafef3723e Mon Sep 17 00:00:00 2001 From: Jonathan Date: Thu, 8 Mar 2012 15:51:19 -0500 Subject: rt-graph: added parameters to tasks --- rt-graph.c | 16 +++++++++++++++- rt-graph.h | 13 +++++++++++++ rt-plot-task.c | 25 +++++++++++++++++++------ task-list.c | 2 ++ task-list.h | 1 + 5 files changed, 50 insertions(+), 7 deletions(-) diff --git a/rt-graph.c b/rt-graph.c index ecb24cb..0a72134 100644 --- a/rt-graph.c +++ b/rt-graph.c @@ -94,6 +94,8 @@ int rt_graph_check_task_param(struct rt_graph_info *rtg_info, unsigned long long *period) { struct event_format *event; + struct rt_task_params *params; + struct task_list *list; unsigned long long val; gint id; int ret = 0; @@ -127,7 +129,19 @@ int rt_graph_check_task_param(struct rt_graph_info *rtg_info, dprintf(3, "Read task_param (%d) record for task %d " "(%llu, %llu)\n", id, *pid, *wcet, *period); - add_task_hash(rtg_info->tasks, *pid); + list = add_task_hash(rtg_info->tasks, *pid); + if (!list->data) { + /* If this pid is plotted, sections of time might later + * be viewed which are after this _param event. In this + * case, that plot would never read a _param event and + * would not know about the task's wcet and deadline. + * Store them with the task to avoid this issue. + */ + params = malloc_or_die(sizeof(*params)); + params->wcet = *wcet; + params->period = *period; + list->data = params; + } if (*period > rtg_info->max_period) rtg_info->max_period = *period; diff --git a/rt-graph.h b/rt-graph.h index 052f184..aff8aca 100644 --- a/rt-graph.h +++ b/rt-graph.h @@ -12,6 +12,11 @@ #define TS_HASH_SIZE 12 struct ts_list; +struct rt_task_params { + unsigned long long wcet; + unsigned long long period; +}; + struct rt_graph_info { /* List of all real-time tasks */ @@ -105,4 +110,12 @@ void set_cpu_to_rts(struct graph_info *ginfo, void set_cpus_to_rts(struct graph_info *ginfo, unsigned long long rt_target); +static inline void nano_to_milli(unsigned long long time, + unsigned long long *msec, + unsigned long long *nsec) +{ + *msec = time / 1000000ULL; + *nsec = time % 1000000ULL; +} + #endif diff --git a/rt-plot-task.c b/rt-plot-task.c index 557bfff..57662b7 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -296,6 +296,7 @@ static int try_release(struct graph_info *ginfo, struct rt_task_info *rtt_info, &release, &deadline); if (match && pid == rtt_info->pid) { update_job(rtt_info, job); + info->release = TRUE; info->rtime = release; @@ -612,7 +613,7 @@ static int rt_task_plot_display_info(struct graph_info *ginfo, int pid, job, eid; struct record *record; struct event_format *event; - unsigned long usec, sec; + unsigned long long msec, nsec; unsigned long long release, deadline, rts; struct rt_task_info *rtt_info = plot->private; struct offset_cache *offsets; @@ -654,9 +655,9 @@ static int rt_task_plot_display_info(struct graph_info *ginfo, trace_seq_printf(s, "\nUNKNOWN EVENT %d\n", eid); } trace_seq_putc(s, '\n'); - convert_nano(time, &sec, &usec); - trace_seq_printf(s, "%lu.%06lu CPU: %03d", - sec, usec, record->cpu); + nano_to_milli(time, &msec, &nsec); + trace_seq_printf(s, "%llu.%06llu ms CPU: %03d", + msec, nsec, record->cpu); free_record(record); } @@ -740,23 +741,35 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) { struct rt_graph_info *rtg_info = &ginfo->rtg_info; struct rt_task_info *rtt_info; + struct rt_task_params *params; struct graph_plot *plot; + struct task_list *list; const char *comm; + unsigned long long wm, wn, pm, pn; char *plot_label; int len; - if (!find_task_list(rtg_info->tasks, pid)) + list = find_task_list(rtg_info->tasks, pid); + if (!list) die("Cannot create RT plot of non-RT task %d!\n", pid); + params = list->data; + if (!params) + die ("RT task %d added without RT params!\n", pid); rtt_info = malloc_or_die(sizeof(*rtt_info)); rtt_info->pid = pid; rtt_info->label = malloc_or_die(LLABEL); + nano_to_milli(params->wcet, &wm, &wn); + nano_to_milli(params->period, &pm, &pn); + /* Create plot */ comm = pevent_data_comm_from_pid(ginfo->pevent, pid); len = strlen(comm) + 100; plot_label = malloc_or_die(len); - snprintf(plot_label, len, "*%s-%d", comm, pid); + snprintf(plot_label, len, + "*%s-%d\n(%llu.%1llu, %llu.%1llu)", + comm, pid, wm, wn, pm, pn); plot = trace_graph_plot_insert(ginfo, pos, plot_label, PLOT_TYPE_RT_TASK, &rt_task_cb, rtt_info); free(plot_label); diff --git a/task-list.c b/task-list.c index 4c820bf..669020c 100644 --- a/task-list.c +++ b/task-list.c @@ -46,6 +46,7 @@ struct task_list *add_task_hash(struct task_list **tasks, int pid) list = malloc_or_die(sizeof(*list)); list->pid = pid; list->next = tasks[key]; + list->data = NULL; tasks[key] = list; return list; @@ -63,6 +64,7 @@ void free_task_hash(struct task_list **tasks) while (tasks[i]) { list = tasks[i]; tasks[i] = list->next; + free(list->data); free(list); } } diff --git a/task-list.h b/task-list.h index eb1213b..ae3dae2 100644 --- a/task-list.h +++ b/task-list.h @@ -10,6 +10,7 @@ struct task_list { struct task_list *next; gint pid; + void *data; }; struct task_list* find_task_list(struct task_list **tasks, int pid); -- cgit v1.2.2