Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
PolyORB-HI-C
Commits
7b32281d
Commit
7b32281d
authored
May 24, 2018
by
yoogx
Browse files
* Add more basic monitoring API
For openaadl/polyorb-hi-c#5
parent
886ec175
Changes
9
Hide whitespace changes
Inline
Side-by-side
include/monitoring/Makefile.am
View file @
7b32281d
...
...
@@ -4,7 +4,7 @@ SUBDIRS=
EXTRA_DIST
=
$(srcdir)
/hash.hh
$(srcdir)
/meta.hh
$(srcdir)
/state.hh
\
$(srcdir)
/trace.hh
$(srcdir)
/local_configuration.hh
\
$(srcdir)
/remote_configuration.hh
$(srcdir)
/state_types.hh
\
$(srcdir)
/trace_manager.h
h
$(srcdir)
/trace_manager.h
CLEANFILES
=
*
~
...
...
include/monitoring/trace_manager.h
0 → 100644
View file @
7b32281d
#include
<deployment.h>
#include
<request.h>
#include
<po_hi_time.h>
/** Nature of the task traced */
typedef
enum
{
PERIODIC
=
1
,
SPORADIC
=
-
1
,
ANY
=
0
,
}
events
;
/** Step in which the traced-task is */
typedef
enum
{
/* The task has just been creatd */
CREATION
=
0
,
STORE_OUT
=
1
,
TRANSPORT_SEND
=
2
,
WAIT_FOR
=
3
,
GET_VALUE
=
4
,
}
steps
;
/** Structure stored when an event is recorded */
typedef
struct
characteristics
characteristics
;
struct
characteristics
{
events
event
;
steps
status
;
__po_hi_task_id
task_id
;
__po_hi_port_t
global_port_src
;
__po_hi_port_t
global_port_dest
;
__po_hi_local_port_t
loc_port_src
;
__po_hi_local_port_t
loc_port_dest
;
__po_hi_time_t
mytime
;
__po_hi_request_t
*
p_request
;
};
/** Function initializing the mutex */
void
trace_initialize
();
/** Function used to trace a task. */
/* The stored events (under the form of "characteristics" structures) are sent in an array
* and written in the history.txt file.
* t_id is the task_id.
* p_src and p_dest are the GLOBAL source and destination ports if they exists / are retrievable.
* port_src and port_dest are the LOCAL source and destination ports if they exists / are retrievable.
* p_req is a pointer toward the request if it exists and is retrievable.
* CONVENTION :
* If an operation is made without movement, that is to say with no source or destination (such as waiting for an event),
* the concerned port is stored in the "src" port.
*/
int
record_event
(
int
event
,
int
status
,
__po_hi_task_id
t_id
,
__po_hi_port_t
p_src
,
__po_hi_port_t
p_dest
,
__po_hi_local_port_t
port_src
,
__po_hi_local_port_t
port_dest
,
__po_hi_request_t
*
p_req
);
share/make/Makefile.common.in
View file @
7b32281d
...
...
@@ -183,18 +183,15 @@ check-linuxtaste:
ifeq
($(MONITORING), true)
MONITORING_OBJS
=
trace_manager.o remote_configuration.o
PO_HI_CPPOBJS
+=
$(MONITORING_OBJS)
PO_HI_OBJS
+=
um_threads.o
MONITORING_OBJS
=
trace_manager.o
PO_HI_OBJS
+=
$(MONITORING_OBJS)
CFLAGS
+=
-DMONITORING
INCLUDE
+=
-I
$(LOCAL_RUNTIME_PATH)
/src
\
-I
$(LOCAL_RUNTIME_PATH)
/src/monitoring
\
-I
$(LOCAL_RUNTIME_PATH)
/include
\
-I
$(LOCAL_RUNTIME_PATH)
/include/monitoring
\
-I
$(LOCAL_RUNTIME_PATH)
/src/monitoring/cheddar_scheduling
CPPFLAGS
+=
-std
=
c++1y
-g
@BOOST_CPPFLAGS@
LDFLAGS
+=
-lstdc
++
endif
hyperperiod-cheddar
:
...
...
src/monitoring/Makefile.am
View file @
7b32281d
AUTOMAKE_OPTIONS
=
no-dependencies
SUBDIRS
=
cheddar_scheduling
CPP_FILES
=
$(srcdir)
/trace_manager.c
c
\
CPP_FILES
=
$(srcdir)
/trace_manager.c
\
$(srcdir)
/remote_configuration.cc
PYTHON_FILES
=
$(srcdir)
/make_cheddar.py
\
...
...
src/monitoring/trace_manager.c
0 → 100644
View file @
7b32281d
#include
<trace_manager.h>
//#include <assert.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<request.h>
//#include <pthread.h>
#include
<deployment.h>
#include
<string.h>
#include
<po_hi_debug.h>
#include
<po_hi_task.h>
#include
<po_hi_protected.h>
#include
<po_hi_gqueue.h>
#include
<po_hi_returns.h>
#include
<activity.h>
#include
<request.h>
#define MAX_STRUCT 10
__po_hi_mutex_t
__po_hi_c_trace_mutex
;
/** Array receiving all tasks */
characteristics
task_log
[
MAX_STRUCT
];
/** Integer allowing to move in the task_log array */
int
nb_struct
=
0
;
/** Initializing the mutex in the main.c */
void
trace_initialize
(){
__po_hi_mutex_init
(
&
__po_hi_c_trace_mutex
,
__PO_HI_MUTEX_REGULAR
,
0
);
}
/** Recording all events, trace_managing */
int
record_event
(
int
event
,
int
stat
,
__po_hi_task_id
t_id
,
__po_hi_port_t
p_src
,
__po_hi_port_t
p_dest
,
__po_hi_local_port_t
port_src
,
__po_hi_local_port_t
port_dest
,
__po_hi_request_t
*
p_req
){
/** CREATION OF STREAM */
printf
(
"IN PROGRAM"
);
FILE
*
history
=
NULL
;
/** CREATION OF THE STRUCTURE TO BE SENT TO TASK_LOG */
characteristics
my_task
;
characteristics
*
p_my_task
=
&
my_task
;
/** EVENT */
events
ev
=
event
;
p_my_task
->
event
=
ev
;
/** STATUS */
steps
step
=
stat
;
p_my_task
->
status
=
step
;
/** TASK ID */
p_my_task
->
task_id
=
t_id
;
/** GLOBAL PORT SRC */
p_my_task
->
global_port_src
=
p_src
;
/** GLOBAL PORT DEST */
p_my_task
->
global_port_dest
=
p_dest
;
/** PORT LOCAL SRC */
p_my_task
->
loc_port_src
=
port_src
;
/** PORT LOCAL DEST */
p_my_task
->
loc_port_dest
=
port_dest
;
/** TIME */
__po_hi_time_t
time
;
int
gettime
=
__po_hi_get_time
(
&
time
);
if
(
gettime
==
__PO_HI_SUCCESS
){
p_my_task
->
mytime
=
time
;
}
else
{
printf
(
"Can't get the time, break"
);
return
__PO_HI_UNAVAILABLE
;
}
/** REQUEST */
p_my_task
->
p_request
=
malloc
(
sizeof
(
__po_hi_request_t
));
if
(
p_req
!=
NULL
){
memcpy
(
p_my_task
->
p_request
,
p_req
,
sizeof
(
__po_hi_request_t
));
}
/** LOCKING THE MUTEX */
printf
(
"lock"
);
__po_hi_mutex_lock
(
&
__po_hi_c_trace_mutex
);
printf
(
"locked"
);
/** IF the log array is complete */
if
(
nb_struct
>=
10
){
/* A stream is opened */
printf
(
"open"
);
history
=
fopen
(
"history.txt"
,
"a+"
);
if
(
history
==
NULL
){
printf
(
"no history file is opened or created"
);
return
__PO_HI_INVALID
;
}
printf
(
"close"
);
fseek
(
history
,
0
,
SEEK_END
);
/* The copying is done */
for
(
int
i
=
0
;
i
<
10
;
i
++
){
fprintf
(
history
,
"event = %d; age_status = %d; task_id = %d; port_src_id = %d; port_dest_id = %d; local_port_src_id = %d; dest_src_id = %d; time : sec = %d, nsec = %d"
,
task_log
[
i
].
event
,
task_log
[
i
].
status
,
task_log
[
i
].
task_id
,
task_log
[
i
].
global_port_src
,
task_log
[
i
].
global_port_dest
,
task_log
[
i
].
loc_port_src
,
task_log
[
i
].
loc_port_dest
,
(
task_log
[
i
].
mytime
).
sec
,
(
task_log
[
i
].
mytime
).
nsec
);
fprintf
(
history
,
", request = "
);
fwrite
(
task_log
[
i
].
p_request
,
sizeof
(
__po_hi_request_t
),
1
,
history
);
fprintf
(
history
,
"
\n
"
);
}
/* The index is returned back to 0 */
nb_struct
=
0
;
/* The stream is closed */
fclose
(
history
);
}
/** If the log array isn't complete, write in it */
if
(
nb_struct
<
10
){
task_log
[
nb_struct
]
=
my_task
;
nb_struct
+=
1
;
}
/** UNLOCKING THE MUTEX */
__po_hi_mutex_unlock
(
&
__po_hi_c_trace_mutex
);
return
__PO_HI_SUCCESS
;
}
src/po_hi_gqueue.c
View file @
7b32281d
...
...
@@ -43,7 +43,7 @@
#endif
#if defined (MONITORING)
/* Headers from run-time verification */
#include
<trace_manager.h
h
>
#include
<trace_manager.h>
#endif
#define __PO_HI_GQUEUE_OUT_PORT constant_out_identifier
...
...
@@ -168,6 +168,12 @@ void __po_hi_gqueue_store_out (__po_hi_task_id id,
ptr
=
&
__po_hi_gqueues_most_recent_values
[
id
][
port
];
memcpy
(
ptr
,
request
,
sizeof
(
__po_hi_request_t
));
__PO_HI_DEBUG_DEBUG
(
"__po_hi_gqueue_store_out() from task %d on port %d
\n
"
,
id
,
port
);
#if defined (MONITORING)
printf
(
"record_event"
);
record_event
(
ANY
,
STORE_OUT
,
id
,
invalid_port_t
,
invalid_port_t
,
port
,
invalid_local_port_t
,
request
);
#endif
}
__po_hi_port_id_t
__po_hi_gqueue_store_in
(
__po_hi_task_id
id
,
...
...
@@ -266,7 +272,12 @@ void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
*
port
=
__po_hi_gqueues_global_history
[
id
][
__po_hi_gqueues_global_history_offset
[
id
]];
/** Releasing only the mutex of the semaphore*/
#if defined (MONITORING)
printf
(
"record_event"
);
record_event
(
SPORADIC
,
WAIT_FOR
,
id
,
invalid_port_t
,
invalid_port_t
,
*
port
,
invalid_local_port_t
,
NULL
);
#endif
/** Releasing only the mutex of the semaphore*/
int
res
=
__po_hi_sem_mutex_release_gqueue
(
__po_hi_gqueues_semaphores
,
id
);
__DEBUGMSG
(
"GQUEUE_SEM_MTUEX_RELEASE %d %d
\n
"
,
id
,
res
);
assert
(
res
==
__PO_HI_SUCCESS
);
...
...
@@ -323,7 +334,8 @@ int __po_hi_gqueue_get_value (__po_hi_task_id id,
}
#if defined (MONITORING)
update_sporadic_dispatch
(
id
,
port
);
printf
(
"record_event"
);
record_event
(
ANY
,
GET_VALUE
,
id
,
invalid_port_t
,
invalid_port_t
,
port
,
invalid_local_port_t
,
request
);
#endif
if
(
__po_hi_gqueues_used_size
[
id
][
port
]
==
0
)
...
...
src/po_hi_main.c
View file @
7b32281d
...
...
@@ -23,7 +23,7 @@
/* included files from PolyORB-HI-C */
#if defined (MONITORING)
#include
<trace_manager.h
h
>
#include
<trace_manager.h>
#endif
/* Headers from run-time verification */
...
...
@@ -290,7 +290,9 @@ int __po_hi_initialize ()
/*!
* Initialize the monitoring trace if needed
*/
printf
(
"soon monitoring
\n
"
);
#if defined (MONITORING)
printf
(
"trace_init"
);
trace_initialize
();
#endif
...
...
src/po_hi_task.c
View file @
7b32281d
...
...
@@ -61,7 +61,7 @@
/* Header files in PolyORB-HI */
#if defined (MONITORING)
#include
<trace_manager.h
h
>
#include
<trace_manager.h>
#endif
/* Headers from run-time verification */
...
...
@@ -249,7 +249,8 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task)
* Entry ports monitoring at dispatch if MONITORING is defined
*/
#if defined (MONITORING)
update_periodic_dispatch
(
task
);
// XXX ?
printf
(
"record_event"
);
record_event
(
PERIODIC
,
WAIT_FOR
,
task
,
invalid_port_t
,
invalid_port_t
,
invalid_local_port_t
,
invalid_local_port_t
,
NULL
);
#endif
#if defined (POSIX) || defined (RTEMS_POSIX) || defined (XENO_POSIX)
...
...
@@ -655,13 +656,6 @@ 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
)
{
...
...
@@ -701,6 +695,18 @@ int __po_hi_create_periodic_task (const __po_hi_task_id id,
}
#endif
tasks
[
id
].
task_category
=
TASK_PERIODIC
;
/*
* Send Task type to trace manager, if there is monitoring.
*/
#if defined (MONITORING)
printf
(
"record_event"
);
//__DEBUGMSG ("Periodic_task_creation\n");
record_event
(
PERIODIC
,
CREATION
,
id
,
invalid_port_t
,
invalid_port_t
,
invalid_local_port_t
,
invalid_local_port_t
,
NULL
);
#endif
return
(
__PO_HI_SUCCESS
);
}
...
...
@@ -720,13 +726,6 @@ 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
...
...
@@ -753,6 +752,17 @@ int __po_hi_create_sporadic_task (const __po_hi_task_id id,
}
#endif
tasks
[
id
].
task_category
=
TASK_SPORADIC
;
/*
* Send Task type to trace manager, if there is monitoring.
*/
#if defined (MONITORING)
printf
(
"record_event"
);
//__DEBUGMSG ("Sporadic_task_creation\n");
record_event
(
SPORADIC
,
CREATION
,
id
,
invalid_port_t
,
invalid_port_t
,
invalid_local_port_t
,
invalid_local_port_t
,
NULL
);
#endif
return
(
__PO_HI_SUCCESS
);
}
...
...
src/po_hi_transport.c
View file @
7b32281d
...
...
@@ -26,6 +26,10 @@
#include
<activity.h>
#include
<request.h>
#if defined (MONITORING)
#include
<trace_manager.h>
#endif
/*
* The following arrays are declared in the generated header
* deployment.h.
...
...
@@ -164,7 +168,14 @@ int __po_hi_transport_send (__po_hi_task_id id, __po_hi_port_t port)
}
}
#endif
/** The trace_managing is done for every step of the for loop */
#if defined (MONITORING)
printf
(
"record_event"
);
record_event
(
ANY
,
TRANSPORT_SEND
,
id
,
port
,
destination_port
,
local_port
,
__po_hi_get_local_port_from_global_port
(
destination_port
),
request
);
#endif
}
request
->
port
=
__PO_HI_GQUEUE_INVALID_PORT
;
#ifdef __PO_HI_DEBUG
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment