Commit d4b319f7 authored by julien.delange's avatar julien.delange
Browse files

* remove dependency between sockets and generated variables

   introduce dedicated functions


git-svn-id: https://tecsw.estec.esa.int/svn/taste/trunk/po-hi-c@548 129961e7-ef38-4bb5-a8f7-c9a525a55882
parent 42cbee65
......@@ -59,13 +59,6 @@
#define __PO_HI_NB_NODES 1
#endif
/*
* The following extern variables are declared in the generated code
* See the files deployment.h and deployment.c.
*/
extern __po_hi_node_t entity_table[__PO_HI_NB_ENTITIES];
/*
* Add the definition of __po_hi_queue_put, defined in
* po_hi_transport.c This function is not defined in the header file,
......@@ -257,7 +250,7 @@ int __po_hi_driver_sockets_send (__po_hi_entity_t from,
int optval = 0;
socklen_t optlen = 0;
node = entity_table[to];
node = __po_hi_transport_get_node_from_entity (to);
if (nodes[node].socket == -1 )
{
......
......@@ -59,7 +59,7 @@ pthread_cond_t __po_hi_gqueues_conds[__PO_HI_NB_TASKS];
pthread_mutexattr_t __po_hi_gqueues_mutexes_attr[__PO_HI_NB_TASKS];
pthread_condattr_t __po_hi_gqueues_conds_attr[__PO_HI_NB_TASKS];
void __po_hi_gqueue_init ( __po_hi_task_id id,
void __po_hi_gqueue_init (__po_hi_task_id id,
__po_hi_uint8_t nb_ports,
__po_hi_port_t queue[],
__po_hi_int8_t sizes[],
......@@ -114,6 +114,7 @@ void __po_hi_gqueue_init ( __po_hi_task_id id,
for (tmp=0;tmp<nb_ports;tmp++)
{
__po_hi_gqueues_used_size[id][tmp] = 0;
if ( (sizes[tmp] != __PO_HI_GQUEUE_FIFO_INDATA)
&& (sizes[tmp] != __PO_HI_GQUEUE_FIFO_OUT))
{
......@@ -154,6 +155,8 @@ void __po_hi_gqueue_store_out (__po_hi_task_id id,
memcpy (ptr, request, sizeof (*request));
}
__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)
......@@ -206,65 +209,7 @@ __po_hi_uint8_t __po_hi_gqueue_store_in (__po_hi_task_id id,
return __PO_HI_SUCCESS;
}
/*
int __po_hi_gqueue_send_output (__po_hi_task_id id, __po_hi_port_t port)
{
__po_hi_msg_t msg;
__po_hi_request_t* request;
__po_hi_port_t* destinations;
__po_hi_uint8_t ndest;
__po_hi_uint8_t i;
__po_hi_local_port_t local_port;
int error;
local_port = __po_hi_port_global_to_local[(int)port];
request = &(__po_hi_gqueues_most_recent_values[id][local_port]);
if (request->port == -1)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send output task %d, port %d : no value to send\n",
id, port);
#endif
return __PO_HI_SUCCESS;
}
destinations = __po_hi_gqueues_destinations[id][local_port];
ndest = __po_hi_gqueues_n_destinations[id][local_port];
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("Send value, emitter task %d, emitter port %d, emitter entity %d, destination ports :\n", id, port, __po_hi_port_global_to_entity[port]);
#endif
for (i=0;i<ndest;i++)
{
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\t%d (entity=%d)\n",
destinations[i],
__po_hi_port_global_to_entity[destinations[i]]);
#endif
__po_hi_msg_reallocate (&msg);
request->port = (__po_hi_port_t) destinations[i];
__po_hi_marshall_request (request, &msg);
error =__po_hi_protocols_send
(__po_hi_port_global_to_entity[port],
__po_hi_port_global_to_entity[destinations[i]],
&msg);
if (error != __PO_HI_SUCCESS)
{
return error;
}
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
#ifdef __PO_HI_DEBUG
__DEBUGMSG ("\n");
#endif
return __PO_HI_SUCCESS;
}
*/
void __po_hi_gqueue_wait_for_incoming_event( __po_hi_task_id id,
void __po_hi_gqueue_wait_for_incoming_event (__po_hi_task_id id,
__po_hi_local_port_t* port)
{
pthread_mutex_lock (&__po_hi_gqueues_mutexes[id]);
......@@ -332,7 +277,7 @@ int __po_hi_gqueue_get_value( __po_hi_task_id id,
return 0;
}
int __po_hi_gqueue_next_value( __po_hi_task_id id, __po_hi_local_port_t port)
int __po_hi_gqueue_next_value (__po_hi_task_id id, __po_hi_local_port_t port)
{
/* incomplete semantics, should discriminate and report whether
there is a next value or not */
......
......@@ -46,7 +46,10 @@ int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
__po_hi_uint8_t ndest;
__po_hi_uint8_t i;
__po_hi_local_port_t local_port;
#if __PO_HI_NB_NODES > 1
int error;
#endif
local_port = __po_hi_port_global_to_local[(int)port];
request = &(__po_hi_gqueues_most_recent_values[id][local_port]);
......@@ -74,16 +77,20 @@ int __po_hi_transport_send_default (__po_hi_task_id id, __po_hi_port_t port)
__po_hi_port_global_to_entity[destinations[i]]);
#endif
__po_hi_msg_reallocate (&msg);
request->port = (__po_hi_port_t) destinations[i];
__po_hi_marshall_request (request, &msg);
error =__po_hi_driver_sockets_send
(__po_hi_port_global_to_entity[port],
#if __PO_HI_NB_NODES > 1
error =__po_hi_driver_sockets_send (__po_hi_port_global_to_entity[port],
__po_hi_port_global_to_entity[destinations[i]],
&msg);
if (error != __PO_HI_SUCCESS)
{
return error;
}
#endif
}
request->port = __PO_HI_GQUEUE_INVALID_PORT;
......
Supports Markdown
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