po_hi_gqueue.h 5.8 KB
Newer Older
1 2 3 4 5
/*
 * 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.
 *
yoogx's avatar
yoogx committed
6
 * For more informations, please visit http://taste.tuxfamily.org/wiki
7
 *
8
 * Copyright (C) 2007-2009 Telecom ParisTech, 2010-2017 ESA & ISAE.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
 */

#ifndef __PO_HI_GQUEUE_H__
#define __PO_HI_GQUEUE_H__

#define __PO_HI_GQUEUE_FULL      10

#define __PO_HI_GQUEUE_FIFO_INDATA    -1
#define __PO_HI_GQUEUE_FIFO_OUT       -2

#define __PO_HI_GQUEUE_INVALID_PORT invalid_port_t
#define __PO_HI_GQUEUE_INVALID_LOCAL_PORT invalid_local_port_t

#include <deployment.h>
#include <request.h>
#include <po_hi_types.h>

void __po_hi_gqueue_init (__po_hi_task_id       id,
27
			  __po_hi_port_id_t     nb_ports,
28
			  __po_hi_port_t        queue[],
29 30 31 32 33
			  __po_hi_port_id_t     sizes[],
			  __po_hi_port_id_t     first[],
			  __po_hi_port_id_t     offsets[],
			  __po_hi_port_id_t     woffsets[],
			  __po_hi_port_id_t     n_dest[],
34
			  __po_hi_port_t*       destinations[],
35
			  __po_hi_port_id_t     used_size[],
36 37
			  __po_hi_local_port_t  history[],
			  __po_hi_request_t     recent[],
38 39
			  __po_hi_port_id_t     empties[],
			  __po_hi_uint32_t      total_fifo_size);
40 41 42 43 44 45
/*
 * Initialize a global queue. In a distributed system, each task has
 * its own global queue. This function is invoked by each thead to
 * create its global queue, according to its information (number of
 * ports, destination of each port ...).
 *
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
 *
 * id : id of the task associated to this queue
 * nb_ports : number of ports for task 'id'
 * queue : XXX
 * sizes : size of the FIFO for each port, or __PO_HI_GQUEUE_FIFO_OUT
 *         if this is an out port;
 * first
 * ofssets: offset position for each queue in the global
 *          queue
 * woffsets :
 * n_dest : number of destinations for each port;
 * destinations : destination for each port;
 * used_size : XXX
 * history : XXX
 * recent : XXX
 * empties : XXX
 * total_fifo_sizes: XXX
63 64
 */

65 66
void __po_hi_gqueue_store_out (__po_hi_task_id id,
                               __po_hi_local_port_t port,
67 68 69 70 71 72 73 74
                               __po_hi_request_t* request);
/* Store a value for an OUT port.
 *
 * The id argument correspond to the task-id which own the global
 * queue. The second argument is the port that store the value. The
 * last argument is the request to store in the queue.
 */

75
/*
76
int __po_hi_gqueue_send_output (__po_hi_task_id id,
77
                                 __po_hi_port_t port);
78
*/
79
/*
80
 * Send a value for an out port.
81 82 83 84 85 86 87
 *
 * The first argument is the id of the task which have the global
 * queue. The second argument is the number of port that will send the
 * data
 */


88 89
int __po_hi_gqueue_get_value(__po_hi_task_id id,
			     __po_hi_local_port_t port,
90 91
			     __po_hi_request_t* request);
/*
92
 * Get the value on the specified port.
93 94 95 96 97 98 99 100
 *
 * The id parameter corresponds to the task-id in the local
 * process. The port argument is the number of the port that received
 * the data. The request argument is a pointer to store the received
 * data. If the port is an output, this function will return nothing,
 * but will not produce an error.
 */

101
int __po_hi_gqueue_next_value(__po_hi_task_id id,
102 103 104 105 106 107 108 109
			      __po_hi_local_port_t port);
/*
 * Dequeue the value on a port. The argument id is the task identifier
 * in the local process. The second argument is the port number for
 * the thread. This function should not be called several times, until
 * you know what you do.
 */

110
int __po_hi_gqueue_get_count(__po_hi_task_id id,
111 112 113 114 115 116 117
			     __po_hi_local_port_t port);
/*
 * Return the number of events that are pending of a port. The first
 * argument is the task identifier in the local process. The second
 * argument is the port identifier (or port number) for the thread.
 */

118
void __po_hi_gqueue_wait_for_incoming_event(__po_hi_task_id id,
119 120 121 122 123 124 125 126 127
					    __po_hi_local_port_t* port);
/*
 * Wait until an event is received on any port for a given thread. The
 * first argument is the thread identifier in the local process. The
 * second argument is a pointer to a port value. When the function
 * returns, the port argument will contrain the port-id that received
 * the event.
 */

128
__po_hi_port_id_t __po_hi_gqueue_store_in (__po_hi_task_id id,
129
					 __po_hi_local_port_t port,
130 131 132 133 134 135 136 137
					 __po_hi_request_t* request);
/*
 * Store a value in a IN port. The first argument is the task
 * identifier in the local process. The second argument is the port
 * identifier for the local thread. The request argument contrains the
 * request that will be stored in the queue.
 */

138
__po_hi_request_t*  __po_hi_gqueue_get_most_recent_value
139 140 141 142
         (const __po_hi_task_id task_id,
          const __po_hi_local_port_t local_port);


143 144 145
__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);
146

147 148
uint8_t __po_hi_gqueue_get_destinations_number (const __po_hi_task_id task_id,
                                                const __po_hi_local_port_t local_port);
149

150 151 152 153 154 155
/*
 * 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.
 */

156
__po_hi_port_id_t __po_hi_gqueue_get_port_size(const __po_hi_task_id id,
157 158 159 160 161 162 163 164
                                            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.
 */

165
__po_hi_port_id_t __po_hi_gqueue_used_size( __po_hi_task_id id, __po_hi_local_port_t port);
166

167
__po_hi_port_id_t  po_hi_gqueues_queue_is_empty(__po_hi_task_id id);
168 169

__po_hi_request_t* __po_hi_gqueues_get_request(__po_hi_task_id id, __po_hi_local_port_t port);
170

171
#endif /* __PO_HI_GQUEUE_H__ */