Commit 412d12e0 authored by yoogx's avatar yoogx

* Include monitoring API in PolyORB-HI/C runtime and build

          infrastructure

          For issue #5
parent f1ff3ef4
......@@ -185,9 +185,12 @@ AC_OUTPUT([
src/Makefile
src/drivers/Makefile
src/drivers/configuration/Makefile
src/monitoring/Makefile
src/monitoring/cheddar_scheduling/Makefile
include/Makefile
include/drivers/Makefile
include/drivers/configuration/Makefile
include/monitoring/Makefile
examples/Makefile
examples/aadlv1/Makefile
examples/aadlv1/d3.1.3-1/Makefile
......
AUTOMAKE_OPTIONS = no-dependencies
SUBDIRS=drivers
SUBDIRS=drivers monitoring
EXTRA_DIST = $(srcdir)/po_hi_common.h \
$(srcdir)/po_hi_debug.h \
$(srcdir)/po_hi_marshallers.h \
......
......@@ -129,9 +129,32 @@ __po_hi_request_t* __po_hi_gqueue_get_most_recent_value
const __po_hi_local_port_t local_port);
__po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id, const __po_hi_local_port_t local_port, const uint8_t destination_number);
__po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id,
const __po_hi_local_port_t local_port,
const uint8_t destination_number);
uint8_t __po_hi_gqueue_get_destinations_number (const __po_hi_task_id task_id, const __po_hi_local_port_t local_port);
uint8_t __po_hi_gqueue_get_destinations_number (const __po_hi_task_id task_id,
const __po_hi_local_port_t local_port);
/*
* Access the size of a port. The first argument is the task
* identifier in the local process. The second argument is the port
* identifier for the local thread.
*/
__po_hi_int8_t __po_hi_gqueue_get_port_size(const __po_hi_task_id id,
const __po_hi_local_port_t port);
/*
* Access the used size of a port. The first argument is the task
* identifier in the local process. The second argument is the port
* identifier for the local thread.
*/
__po_hi_int8_t __po_hi_gqueue_used_size( __po_hi_task_id id, __po_hi_local_port_t port);
__po_hi_int8_t po_hi_gqueues_queue_is_empty(__po_hi_task_id id);
__po_hi_request_t* __po_hi_gqueues_get_request(__po_hi_task_id id, __po_hi_local_port_t port);
#endif /* __PO_HI_GQUEUE_H__ */
AUTOMAKE_OPTIONS = no-dependencies
SUBDIRS=drivers
SUBDIRS=drivers monitoring
C_FILES = $(srcdir)/po_hi_task.c \
$(srcdir)/po_hi_main.c \
......
......@@ -37,7 +37,9 @@
#include <native/mutex.h>
#endif
#if defined (MONITORING) /* Headers from run-time verification */
#include <trace_manager.hh>
#endif
#define __PO_HI_GQUEUE_OUT_PORT constant_out_identifier
/* give a default value to the out port */
......@@ -225,7 +227,6 @@ void __po_hi_gqueue_init (__po_hi_task_id id,
#endif
}
void __po_hi_gqueue_store_out (__po_hi_task_id id,
__po_hi_local_port_t port,
__po_hi_request_t* request)
......@@ -238,8 +239,6 @@ void __po_hi_gqueue_store_out (__po_hi_task_id id,
__PO_HI_DEBUG_DEBUG ("__po_hi_gqueue_store_out() from task %d on port %d\n", id, port);
}
__po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
__po_hi_local_port_t port,
__po_hi_request_t* request)
......@@ -354,6 +353,7 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
return __PO_HI_SUCCESS;
}
void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
__po_hi_local_port_t* port)
{
......@@ -424,6 +424,7 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
__DEBUGMSG ("[GQUEUE] Gogo kiki\n");
*port = __po_hi_gqueues_global_history[id][__po_hi_gqueues_global_history_offset[id]];
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_mutex_unlock (&__po_hi_gqueues_mutexes[id]);
#elif defined (XENO_NATIVE)
......@@ -442,6 +443,7 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
}
int __po_hi_gqueue_get_count( __po_hi_task_id id, __po_hi_local_port_t port)
{
if (__po_hi_gqueues_sizes[id][port] == __PO_HI_GQUEUE_FIFO_INDATA)
......@@ -454,6 +456,7 @@ int __po_hi_gqueue_get_count( __po_hi_task_id id, __po_hi_local_port_t port)
}
}
int __po_hi_gqueue_get_value (__po_hi_task_id id,
__po_hi_local_port_t port,
__po_hi_request_t* request)
......@@ -495,6 +498,7 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_cond_wait (&__po_hi_gqueues_conds[id],
&__po_hi_gqueues_mutexes[id]);
#elif defined (XENO_NATIVE)
rt_cond_wait (&__po_hi_gqueues_conds[id], &__po_hi_gqueues_mutexes[id], TM_INFINITE);
#elif defined (RTEMS_PURE)
......@@ -512,9 +516,14 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
}
}
#if defined (MONITORING)
update_sporadic_dispatch (id, port);
#endif
if (__po_hi_gqueues_used_size[id][port] == 0)
{
memcpy (request, ptr, sizeof (__po_hi_request_t));
//update_runtime (id, port, ptr);
}
else
{
......@@ -525,28 +534,6 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
__PO_HI_DEBUG_INFO ("[GQUEUE] Task %d get a value on port %d\n", id, port);
/*
* As this part of the code is now considered as stable, we don't print debug output
*
__DEBUGMSG ("RECEIVED vars in gqueue: |");
{
int s;
int i;
uint8_t* tmp;
tmp = (unsigned int*) &request->vars;
s = sizeof (request->vars);
for (i = 0 ; i < s ; i++)
{
printf("%x", *tmp);
tmp++;
fflush (stdout);
}
}
__DEBUGMSG ("|\n");
#endif
*/
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
pthread_mutex_unlock (&__po_hi_gqueues_mutexes[id]);
#elif defined (XENO_NATIVE)
......@@ -570,7 +557,6 @@ int __po_hi_gqueue_next_value (__po_hi_task_id id, __po_hi_local_port_t port)
rtems_status_code ret;
#endif
/* incomplete semantics, should discriminate and report whether
there is a next value or not */
......@@ -649,3 +635,38 @@ __po_hi_port_t __po_hi_gqueue_get_destination (const __po_hi_task_id task_id, co
{
return (__po_hi_gqueues_destinations[task_id][local_port][destination_number]);
}
__po_hi_int8_t __po_hi_gqueue_get_port_size( __po_hi_task_id id, __po_hi_local_port_t port)
{
return __po_hi_gqueues_sizes[id][port];
}
__po_hi_int8_t __po_hi_gqueue_used_size( __po_hi_task_id id, __po_hi_local_port_t port)
{
return __po_hi_gqueues_used_size[id][port];
}
__po_hi_int8_t po_hi_gqueues_queue_is_empty( __po_hi_task_id id)
{
return __po_hi_gqueues_queue_is_empty[id];
}
__po_hi_request_t*
__po_hi_gqueues_get_request(__po_hi_task_id id, __po_hi_local_port_t port)
{
__po_hi_request_t* request;
__po_hi_request_t* ptr;
if (__po_hi_gqueues_used_size[id][port] == 0)
{
memcpy (request, ptr, sizeof (__po_hi_request_t));
//update_runtime (id, port, ptr);
}
else
{
ptr = ((__po_hi_request_t *) &__po_hi_gqueues[id][port]) + __po_hi_gqueues_first[id][port] + __po_hi_gqueues_offsets[id][port];
memcpy (request, ptr, sizeof (__po_hi_request_t));
} return request;
}
......@@ -8,7 +8,6 @@
* Copyright (C) 2010-2014 ESA & ISAE.
*/
#include <deployment.h>
/* included files from the generated code */
......@@ -22,6 +21,11 @@
#include <po_hi_utils.h>
/* included files from PolyORB-HI-C */
#if defined (MONITORING)
#include <trace_manager.hh>
#endif
/* Headers from run-time verification */
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
#include <pthread.h>
/* POSIX files */
......@@ -284,6 +288,14 @@ int __po_hi_initialize ()
}
#endif
/*!
* Initialize the monitoring trace if needed
*/
#if defined (MONITORING)
trace_initialize ();
#endif
return (__PO_HI_SUCCESS);
}
......
......@@ -48,6 +48,11 @@
#include <po_hi_utils.h>
/* Header files in PolyORB-HI */
#if defined (MONITORING)
#include <trace_manager.hh>
#endif
/* Headers from run-time verification */
#include <deployment.h>
/* Header files from generated code */
......@@ -90,6 +95,7 @@ __po_hi_task_t tasks[__PO_HI_NB_TASKS];
HANDLE __po_hi_tasks_array[__PO_HI_NB_TASKS];
#endif
void __po_hi_wait_for_tasks ()
{
#if defined (RTEMS_POSIX) || defined (POSIX) || defined (XENO_POSIX)
......@@ -170,12 +176,21 @@ int __po_hi_compute_next_period (__po_hi_task_id task)
#endif
}
int __po_hi_wait_for_next_period (__po_hi_task_id task)
{
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
int ret;
__PO_HI_INSTRUMENTATION_VCD_WRITE("0t%d\n", task);
__po_hi_task_delay_until (&(tasks[task].timer), task);
/*!
* Entry ports monitoring at dispatch if MONITORING is defined
*/
#if defined (MONITORING)
update_periodic_dispatch(task);
#endif
if ( (ret = __po_hi_compute_next_period (task)) != 1)
{
return (__PO_HI_ERROR_CLOCK);
......@@ -355,6 +370,7 @@ pthread_t __po_hi_posix_create_thread (__po_hi_priority_t priority,
return tid;
}
int __po_hi_posix_initialize_task (__po_hi_task_t* task)
{
if (pthread_mutex_init (&(task->mutex), NULL) != 0)
......@@ -452,7 +468,6 @@ RT_TASK __po_hi_xenomai_create_thread (__po_hi_priority_t priority,
}
#endif
int __po_hi_create_generic_task (const __po_hi_task_id id,
const __po_hi_time_t* period,
const __po_hi_priority_t priority,
......@@ -511,6 +526,7 @@ int __po_hi_create_generic_task (const __po_hi_task_id id,
return (__PO_HI_SUCCESS);
}
int __po_hi_create_periodic_task (const __po_hi_task_id id,
const __po_hi_time_t* period,
const __po_hi_priority_t priority,
......@@ -518,6 +534,14 @@ int __po_hi_create_periodic_task (const __po_hi_task_id id,
const __po_hi_int8_t core_id,
void* (*start_routine)(void))
{
/*
* Send Task type to trace manager, if there is monitoring.
*/
#if defined (MONITORING)
periodic_task_creation(id);
#endif
if (__po_hi_create_generic_task( id, period , priority , stack_size, core_id, start_routine, NULL) != 1)
{
__DEBUGMSG ("ERROR when creating generic task (task id=%d)\n", id);
......@@ -565,6 +589,13 @@ int __po_hi_create_sporadic_task (const __po_hi_task_id id,
const __po_hi_int8_t core_id,
void* (*start_routine)(void) )
{
/*
* Send Task type to trace manager, if there is monitoring.
*/
#if defined (MONITORING)
sporadic_task_creation(id);
#endif
/*
* Create generic task which will execute the routine given in the
* last parameter. Typically, a sporadic thread will wait on a
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment