From e9c069dd94c45e768bbcc65e4232fdde688a7e37 Mon Sep 17 00:00:00 2001 From: schnorr Date: Sat, 24 Mar 2012 18:08:12 +0100 Subject: [PATCH 1/1] new functions for the MSG API (set/get task category) details: - only works if HAVE_TRACING is enabled --- include/msg/msg.h | 3 +++ src/msg/msg_gos.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/include/msg/msg.h b/include/msg/msg.h index eed0d313c5..89b94fff3b 100644 --- a/include/msg/msg.h +++ b/include/msg/msg.h @@ -206,6 +206,9 @@ XBT_PUBLIC(MSG_error_t) XBT_PUBLIC(int) MSG_task_listen_from(const char *alias); +XBT_PUBLIC(void) MSG_task_set_category (m_task_t task, const char *category); +XBT_PUBLIC(const char *) MSG_task_get_category (m_task_t task); + /************************** Task handling ************************************/ XBT_PUBLIC(MSG_error_t) MSG_mailbox_get_task_ext(msg_mailbox_t mailbox, m_task_t * task, diff --git a/src/msg/msg_gos.c b/src/msg/msg_gos.c index cec273dd3b..7043c047d4 100644 --- a/src/msg/msg_gos.c +++ b/src/msg/msg_gos.c @@ -874,6 +874,45 @@ int MSG_task_listen_from(const char *alias) return MSG_process_get_PID(task->simdata->sender); } +/** \ingroup msg_gos_functions + * + * See \ref tracing_tracing for details on how to trace + * the (categorized) resource utilization. + * + * \brief Sets the tracing category of a task. + * + * \param task the task that is going to be categorized + * \param category the name of the category to be associated to the task + * + * \see MSG_task_get_category, TRACE_category, TRACE_category_with_color + */ +void MSG_task_set_category (m_task_t task, const char *category) +{ +#ifdef HAVE_TRACING + TRACE_msg_set_task_category (task, category); +#endif +} + + +/** \ingroup msg_gos_functions + * + * \brief Gets the current tracing category of a task. + * + * \param task the task to be considered + * + * \see MSG_task_set_category + * + * \return Returns the name of the tracing category of the given task, NULL otherwise + */ +const char *MSG_task_get_category (m_task_t task) +{ +#ifdef HAVE_TRACING + return task->category; +#else + return NULL; +#endif +} + #ifdef MSG_USE_DEPRECATED /** \ingroup msg_gos_functions * -- 2.20.1