Commit 70e2ea61 authored by julien.delange's avatar julien.delange
Browse files

* po-hi-c/include/po_hi_debug.h

   - Automatically flush stderr when writing debug infos

 * po-hi-c/src/po_hi_task.c
   po-hi-c/include/po_hi_task.h
   - Add the __po_hi_tasks_killall function to terminate
     all application threads.

 * po-hi-c/src/po_hi_main.c
   - Force threads to be cancellable so that we are able
     to terminate them when a given period of time is reached.
 
 * po-hi-c/src/po_hi_gqueue.c
   - More debug information

 * po-hi-c/share/make/Makefile.common
   - Add more information about the RTEMS_MAKEFILE_PATH
     variable

 * po-hi-c/src/drivers/po_hi_driver_linux_serial.c
   - Fix bug #0000028




git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@1485 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 69f21a5f
......@@ -5,16 +5,17 @@
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2007-2010, European Space Agency (ESA).
*/
#ifndef __PO_HI_DEBUG_H__
#include <po_hi_config.h>
#include <po_hi_time.h>
#ifdef __PO_HI_DEBUG
#include <stdio.h>
#define __DEBUGMSG(s, args...) fprintf(stderr, s, ##args)
#define __DEBUGMSG(s, args...) fprintf(stderr, s, ##args); fflush (stderr);
#else
#define __DEBUGMSG(s, args...)
#endif
......
......@@ -5,8 +5,7 @@
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2008, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency.
* Copyright (C) 2010, European Space Agency (ESA).
*/
#ifndef __PO_HI_TASK_H__
......@@ -150,4 +149,10 @@ int __po_hi_wait_for_next_period (__po_hi_task_id task);
*/
int __po_hi_compute_next_period (__po_hi_task_id task);
/*
* Delete all the tasks that were created within the system.
*/
void __po_hi_tasks_killall ();
#endif /* __PO_HI_TASK_H__ */
# It detect if networking functions have to be compiled
/*
* This is a part of PolyORB-HI-C distribution, a minimal
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency (ESA).
*/
# With the generated code.
all: build-node
......@@ -173,7 +182,7 @@ endif
check-rtems:
if [ ! -d $$RTEMS_MAKEFILE_PATH/make ]; then \
echo "Please define the RTEMS_MAKEFILE_PATH variable" && exit 2 ; \
echo "Please define the RTEMS_MAKEFILE_PATH variable [currently set to \"$(RTEMS_MAKEFILE_PATH)\"]" && exit 2 ; \
fi
......
......@@ -3,7 +3,9 @@
* middleware written for generated code from AADL models.
* You should use it with the Ocarina toolsuite.
*
* Copyright (C) 2010, European Space Agency
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2010, European Space Agency (ESA).
*/
#include <drivers/po_hi_driver_linux_serial.h>
......@@ -288,7 +290,7 @@ void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
}
else
{
__DEBUGMSG ("[LINUX SERIAL] Device successfully opened, fd=%d\n", po_hi_c_driver_serial_fd_serial);
__DEBUGMSG ("[LINUX SERIAL] Device successfully opened, fd=%d\n", po_hi_c_driver_serial_fd_read);
}
tcgetattr (po_hi_c_driver_serial_fd_read, &oldtio); /* save current serial port settings */
......@@ -371,7 +373,6 @@ void __po_hi_c_driver_serial_linux_init (__po_hi_device_id id)
int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task_id, __po_hi_port_t port)
{
int n;
int tmp;
int ts;
unsigned long* swap_pointer;
unsigned long swap_value;
......@@ -412,4 +413,3 @@ int __po_hi_c_driver_serial_linux_sender (__po_hi_task_id task_id, __po_hi_port
#endif
#endif
......@@ -5,8 +5,7 @@
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency
* Copyright (C) 2010, European Space Agency (ESA).
*/
#include <po_hi_config.h>
......@@ -188,6 +187,7 @@ void __po_hi_gqueue_store_out (__po_hi_task_id id,
request->port = __PO_HI_GQUEUE_OUT_PORT;
ptr = &__po_hi_gqueues_most_recent_values[id][port];
memcpy (ptr, request, sizeof (*request));
__DEBUGMSG ("__po_hi_gqueue_store_out() from task %d on port %d\n", id, port);
}
......@@ -405,14 +405,14 @@ rtems_id __po_hi_gqueues_barriers[__PO_HI_NB_TASKS];
(void *)&__po_hi_gqueues[id][port] + ( __po_hi_gqueues_first[id][port] + __po_hi_gqueues_offsets[id][port] )* sizeof (__po_hi_request_t),
sizeof (__po_hi_request_t));
}
__DEBUGMSG ("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
*
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Task %d get a value on port %d\n", id, port);
__DEBUGMSG ("RECEIVED vars in gqueue: |");
{
int s;
......@@ -525,4 +525,3 @@ __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]);
}
......@@ -5,8 +5,7 @@
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2010, European Space Agency (ESA)
* Copyright (C) 2010, European Space Agency (ESA).
*/
......@@ -120,6 +119,17 @@ int __po_hi_initialize ()
int __po_hi_wait_initialization ()
{
#if defined (POSIX) || defined (RTEMS_POSIX)
int cstate;
if (pthread_setcancelstate (PTHREAD_CANCEL_ENABLE, &cstate) != 0)
{
__DEBUGMSG ("[MAIN] Cannot modify the cancel state\n");
}
if (pthread_setcanceltype (PTHREAD_CANCEL_ASYNCHRONOUS, &cstate) != 0)
{
__DEBUGMSG ("[MAIN] Cannot modify the cancel type\n");
}
if (pthread_mutex_lock (&mutex_init) != 0)
{
return (__PO_HI_ERROR_PTHREAD_MUTEX);
......@@ -156,16 +166,23 @@ int __po_hi_wait_initialization ()
#ifdef __PO_HI_USE_GPROF
void __po_hi_wait_end_of_instrumentation ()
{
#ifdef RTEMS_PURE
rtems_task_wake_after (10000000 / _TOD_Microseconds_per_tick);
#else
#include <po_hi_time.h>
#include <unistd.h>
__po_hi_time_t now;
__po_hi_get_time (&now);
__po_hi_delay_until (__po_hi_add_times (now, __po_hi_seconds (10)));
#endif
__DEBUGMSG ("Call exit()\n");
__po_hi_tasks_killall ();
exit (1);
__DEBUGMSG ("exit() called\n");
#ifdef RTEMS_PURE
rtems_task_delete (rtems_self ());
#endif
}
#endif
......@@ -5,7 +5,7 @@
*
* For more informations, please visit http://ocarina.enst.fr
*
* Copyright (C) 2007-2009, GET-Telecom Paris.
* Copyright (C) 2007-2010, European Space Agency (ESA).
*/
#if defined (RTEMS_POSIX) || defined (POSIX)
......@@ -43,6 +43,7 @@ typedef struct
pthread_cond_t cond;
#elif defined(RTEMS_PURE)
rtems_id ratemon_period;
rtems_id rtems_id;
#endif
} __po_hi_task_t;
/*
......@@ -175,7 +176,7 @@ pthread_t __po_hi_posix_create_thread (__po_hi_priority_t priority,
int policy;
pthread_t tid;
pthread_attr_t attr;
struct sched_param param;
struct sched_param param;
if (pthread_attr_init (&attr) != 0)
{
......@@ -259,22 +260,24 @@ int __po_hi_posix_initialize_task (__po_hi_task_t* task)
#ifdef RTEMS_PURE
int __po_hi_rtems_create_thread (__po_hi_priority_t priority,
__po_hi_stack_t stack_size,
void* (*start_routine)(void))
rtems_id __po_hi_rtems_create_thread (__po_hi_priority_t priority,
__po_hi_stack_t stack_size,
void* (*start_routine)(void))
{
rtems_id id;
if (rtems_task_create (rtems_build_name( 'T', 'A', nb_tasks, ' ' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &id) != RTEMS_SUCCESSFUL)
rtems_id rid;
if (rtems_task_create (rtems_build_name( 'T', 'A', nb_tasks, ' ' ), 1, RTEMS_MINIMUM_STACK_SIZE, RTEMS_DEFAULT_MODES, RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &rid) != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("ERROR when creating the task\n");
return __PO_HI_ERROR_CREATE_TASK;
}
if (rtems_task_start( id, (rtems_task_entry)start_routine, 0 ) != RTEMS_SUCCESSFUL)
if (rtems_task_start (rid, (rtems_task_entry)start_routine, 0 ) != RTEMS_SUCCESSFUL)
{
__DEBUGMSG ("ERROR when starting the task\n");
return __PO_HI_ERROR_CREATE_TASK;
}
return __PO_HI_SUCCESS;
return rid;
}
#endif
......@@ -309,7 +312,7 @@ int __po_hi_create_generic_task (__po_hi_task_id id,
my_task->tid = __po_hi_posix_create_thread (priority, stack_size, start_routine);
__po_hi_posix_initialize_task (my_task);
#elif defined (RTEMS_PURE)
__po_hi_rtems_create_thread (priority, stack_size, start_routine);
my_task->rtems_id = __po_hi_rtems_create_thread (priority, stack_size, start_routine);
#else
return (__PO_HI_UNAVAILABLE);
#endif
......@@ -392,3 +395,19 @@ int __po_hi_task_delay_until (__po_hi_time_t time, __po_hi_task_id task)
#endif
return (__PO_HI_UNAVAILABLE);
}
void __po_hi_tasks_killall ()
{
int i;
for (i = 0; i < __PO_HI_NB_TASKS; i++)
{
__DEBUGMSG ("Kill task %d\n", i);
#ifdef RTEMS_PURE
rtems_task_delete (tasks[i].rtems_id);
#endif
#if defined (POSIX) || defined (RTEMS_POSIX)
pthread_cancel (tasks[i].tid);
__DEBUGMSG ("[TASKS] Cancel thread %d\n", (int) tasks[i].tid);
#endif
}
}
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