- Fix: avoid infinite loop on mulitcast read thread if no data to read

Pre-ci test passed

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4000 818b1a75-f10b-46b9-bf7c-635c3b92a50f
This commit is contained in:
Cedric Roux
2013-06-25 09:05:02 +00:00
commit 56c66c09aa
4111 changed files with 2133103 additions and 0 deletions
+567
View File
@@ -0,0 +1,567 @@
/***************************************************************************
Job_list.c - description
-------------------
-------------------
AUTHOR : Lionel GAUTHIER, Mohamed Said MOSLI BOUKSIAA
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr, mosli@eurecom.fr
***************************************************************************/
//#define LIST_C
//#define NULL 0
#include "pad_list.h"
#include <stdio.h>
#include <stdlib.h>
//#include <mpi.h>
void job_list_init (Job_List * listP) {
int i = 0;
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
}
void event_list_init (Event_List * listP) {
int i = 0;
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
}
void pkt_list_init (Packet_OTG_List * listP) {
int i = 0;
listP->tail = NULL;
listP->head = NULL;
listP->nb_elements = 0;
}
//-----------------------------------------------------------------------------
void job_list_free (Job_List * listP) {
Job_elt *le;
while ((le = job_list_remove_head (listP))) {
free(le);
}
}
void event_list_free (Event_List * listP) {
Event_elt *le;
while ((le = event_list_remove_head (listP))) {
free(le);
}
}
void pkt_list_free (Packet_OTG_List * listP) {
Packet_otg_elt *le;
while ((le = pkt_list_remove_head (listP))) {
free(le);
}
}
//-----------------------------------------------------------------------------
Job_elt * job_list_get_head (Job_List * listP) {
return listP->head;
}
Event_elt * event_list_get_head (Event_List * listP) {
return listP->head;
}
Packet_otg_elt * pkt_list_get_head (Packet_OTG_List * listP) {
return listP->head;
}
//-----------------------------------------------------------------------------
/*
* remove an element from head of a list
* @param pointer on targeted list
* @return pointer on removed Job_elt
*/
Job_elt * job_list_remove_head (Job_List * listP) {
// access optimisation
Job_elt *head;
head = listP->head;
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
} else {
//msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name);
}
return head;
}
Event_elt * event_list_remove_head (Event_List * listP) {
// access optimisation
Event_elt *head;
head = listP->head;
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
} else {
//msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name);
}
return head;
}
Packet_otg_elt * pkt_list_remove_head (Packet_OTG_List * listP) {
// access optimisation
Packet_otg_elt *head;
head = listP->head;
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
} else {
//msg("[MEM_MGT][WARNING] remove_head_from_list(%s) no elements\n",listP->name);
}
return head;
}
//-----------------------------------------------------------------------------
Job_elt * job_list_remove_element (Job_elt * elementP, Job_List * listP) {
// access optimisation;
Job_elt *head;
if (elementP != NULL) {
// test head
head = listP->head;
if (listP->head == elementP) {
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
}
} else {
while (head) {
if (head->next == elementP) {
head->next = elementP->next;
listP->nb_elements = listP->nb_elements - 1;
if (listP->tail == elementP) {
listP->tail = head;
}
return elementP;
} else {
head = head->next;
}
}
}
}
return elementP;
}
Event_elt * event_list_remove_element (Event_elt * elementP, Event_List * listP) {
// access optimisation;
Event_elt *head;
if (elementP != NULL) {
// test head
head = listP->head;
if (listP->head == elementP) {
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
}
} else {
while (head) {
if (head->next == elementP) {
head->next = elementP->next;
listP->nb_elements = listP->nb_elements - 1;
if (listP->tail == elementP) {
listP->tail = head;
}
return elementP;
} else {
head = head->next;
}
}
}
}
return elementP;
}
Packet_otg_elt * pkt_list_remove_element (Packet_otg_elt * elementP, Packet_OTG_List * listP) {
// access optimisation;
Packet_otg_elt *head;
if (elementP != NULL) {
// test head
head = listP->head;
if (listP->head == elementP) {
// almost one element
if (head != NULL) {
listP->head = head->next;
listP->nb_elements = listP->nb_elements - 1;
// if only one element, update tail
if (listP->head == NULL) {
listP->tail = NULL;
} else {
head->next = NULL;
}
}
} else {
while (head) {
if (head->next == elementP) {
head->next = elementP->next;
listP->nb_elements = listP->nb_elements - 1;
if (listP->tail == elementP) {
listP->tail = head;
}
return elementP;
} else {
head = head->next;
}
}
}
}
return elementP;
}
//-----------------------------------------------------------------------------
/*
* add an element to the beginning of a list
* @param pointer on targeted list
* @return pointer on removed Job_elt
*/
void job_list_add_head (Job_elt * elementP, Job_List * listP) {
// access optimisation;
Job_elt *head;
if (elementP != NULL) {
head = listP->head;
listP->nb_elements = listP->nb_elements + 1;
// almost one element
if (head == NULL) {
listP->head = elementP;
listP->tail = elementP;
} else {
elementP->next = head;
listP->head = elementP;
}
}
}
void event_list_add_head (Event_elt * elementP, Event_List * listP) {
// access optimisation;
Event_elt *head;
if (elementP != NULL) {
head = listP->head;
listP->nb_elements = listP->nb_elements + 1;
// almost one element
if (head == NULL) {
listP->head = elementP;
listP->tail = elementP;
} else {
elementP->next = head;
listP->head = elementP;
}
}
}
void pkt_list_add_head (Packet_otg_elt * elementP, Packet_OTG_List * listP) {
// access optimisation;
Packet_otg_elt *head;
if (elementP != NULL) {
head = listP->head;
listP->nb_elements = listP->nb_elements + 1;
// almost one element
if (head == NULL) {
listP->head = elementP;
listP->tail = elementP;
} else {
elementP->next = head;
listP->head = elementP;
}
}
}
void event_list_add_element (Event_elt * elementP, Event_elt * previous, Event_List * listP) {
// access optimisation;
Event_elt *next;
elementP->next = NULL;
if (elementP != NULL && previous != NULL) {
next = previous->next;
listP->nb_elements = listP->nb_elements + 1;
// almost one element
if (next == NULL) {
previous->next = elementP;
listP->tail = elementP;
} else {
elementP->next = previous->next;
previous->next = elementP;
}
}
}
//-----------------------------------------------------------------------------
/*
* add an element to the end of a list
* @param pointer on targeted list
* @return pointer on removed Job_elt
*/
void job_list_add_tail_eurecom (Job_elt * elementP, Job_List * listP) {
Job_elt *tail;
if (elementP != NULL) {
// access optimisation
listP->nb_elements = listP->nb_elements + 1;
elementP->next = NULL;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = elementP;
} else {
tail->next = elementP;
}
listP->tail = elementP;
} else {
//msg("[CNT_LIST][ERROR] add_cnt_tail() element NULL\n");
}
}
void event_list_add_tail_eurecom (Event_elt * elementP, Event_List * listP) {
Event_elt *tail;
if (elementP != NULL) {
// access optimisation
listP->nb_elements = listP->nb_elements + 1;
elementP->next = NULL;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = elementP;
} else {
tail->next = elementP;
}
listP->tail = elementP;
} else {
//msg("[CNT_LIST][ERROR] add_cnt_tail() element NULL\n");
}
}
void pkt_list_add_tail_eurecom (Packet_otg_elt * elementP, Packet_OTG_List * listP) {
Packet_otg_elt *tail;
if (elementP != NULL) {
// access optimisation
listP->nb_elements = listP->nb_elements + 1;
elementP->next = NULL;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = elementP;
} else {
tail->next = elementP;
}
listP->tail = elementP;
} else {
//msg("[CNT_LIST][ERROR] add_cnt_tail() element NULL\n");
}
}
//-----------------------------------------------------------------------------
void job_list_add_list (Job_List * sublistP, Job_List * listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Job_elt *tail;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = sublistP->head;
} else {
tail->next = sublistP->head;
}
listP->tail = sublistP->tail;
// clear sublist
sublistP->head = NULL;
sublistP->tail = NULL;
listP->nb_elements = listP->nb_elements + sublistP->nb_elements;
sublistP->nb_elements = 0;
}
}
}
void event_list_add_list (Event_List * sublistP, Event_List * listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Event_elt *tail;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = sublistP->head;
} else {
tail->next = sublistP->head;
}
listP->tail = sublistP->tail;
// clear sublist
sublistP->head = NULL;
sublistP->tail = NULL;
listP->nb_elements = listP->nb_elements + sublistP->nb_elements;
sublistP->nb_elements = 0;
}
}
}
void pkt_list_add_list (Packet_OTG_List * sublistP, Packet_OTG_List * listP) {
if (sublistP) {
if (sublistP->head) {
// access optimisation
Packet_otg_elt *tail;
tail = listP->tail;
// almost one element
if (tail == NULL) {
listP->head = sublistP->head;
} else {
tail->next = sublistP->head;
}
listP->tail = sublistP->tail;
// clear sublist
sublistP->head = NULL;
sublistP->tail = NULL;
listP->nb_elements = listP->nb_elements + sublistP->nb_elements;
sublistP->nb_elements = 0;
}
}
}
//-----------------------------------------------------------------------------
void job_list_display (Job_List * listP) {
//Correct the output once the content of struct Job is fixed
/*Job_elt *cursor;
unsigned short nb_elements = 0;
if (listP) {
cursor = listP->head;
if (cursor) {
while (cursor != NULL) {
if (cursor->job.type == eNB_DL)
printf ("DL eNB From (%d,%d)\n", (cursor->job).nid, (cursor->job).mid);
else if (cursor->job.type == UE_DL)
printf ("DL UE From (%d,%d)\n", (cursor->job).nid, (cursor->job).mid);
else if (cursor->job.type == UE_UL)
printf ("UL UE From (%d,%d)\n", (cursor->job).nid, (cursor->job).mid);
else if (cursor->job.type == eNB_UL)
printf ("UL eNB From (%d,%d)\n", (cursor->job).nid, (cursor->job).mid);
//msg ("From (%d,%d) To (%d,%d)\n", (cursor->job).node1, (cursor->job).master1, (cursor->job).node2, (cursor->job).master2);
cursor = cursor->next;
nb_elements++;
}
printf ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
//msg ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
}
} else {
printf ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
//msg ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
}*/
}
void event_list_display (Event_List * listP) {
Event_elt *cursor;
unsigned short nb_elements = 0;
if (listP) {
cursor = listP->head;
if (cursor) {
while (cursor != NULL) {
printf ("Ev (%d,%d)\n", (cursor->event).type, (cursor->event).frame);
//msg ("From (%d,%d) To (%d,%d)\n", (cursor->job).node1, (cursor->job).master1, (cursor->job).node2, (cursor->job).master2);
cursor = cursor->next;
nb_elements++;
}
printf ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
//msg ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
}
} else {
printf ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
//msg ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
}
}
void pkt_list_display (Packet_OTG_List * listP) {
Packet_otg_elt *cursor;
unsigned short nb_elements = 0;
if (listP) {
cursor = listP->head;
if (cursor) {
while (cursor != NULL) {
printf ("Pkt (DST %d, RB %d)\n", (cursor->otg_pkt).dst_id, (cursor->otg_pkt).rb_id);
//msg ("From (%d,%d) To (%d,%d)\n", (cursor->job).node1, (cursor->job).master1, (cursor->job).node2, (cursor->job).master2);
cursor = cursor->next;
nb_elements++;
}
printf ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
//msg ("Found nb_elements %d nb_elements %d\n", nb_elements, listP->nb_elements);
}
} else {
printf ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
//msg ("[SDU_MNGT][WARNING] display_cnt_dbl_lk_list_up() : list is NULL\n");
}
}
+85
View File
@@ -0,0 +1,85 @@
/*
list.h
-------------------
AUTHOR : Lionel GAUTHIER
COMPANY : EURECOM
EMAIL : Lionel.Gauthier@eurecom.fr
***************************************************************************/
#ifndef __list_H__
#define __list_H__
#include "types.h"
//-----------------------------------------------------------------------------
# ifdef list_C
# define private_list(x) x
# define public_list(x) x
# else
# define private_list(x)
# define public_list(x) extern x
# endif
# ifdef LIST2_C
# define private_list2(x) x
# define public_list2(x) x
# else
# define private_list2(x)
# define public_list2(x) extern x
# endif
//-----------------------------------------------------------------------------
//#include "platform_types.h"
//#include "platform_constants.h"
//#include "PHY/defs.h"
typedef struct {
Job_elt *head;
Job_elt *tail;
int nb_elements;
} Job_List;
typedef struct {
Event_elt *head;
Event_elt *tail;
int nb_elements;
} Event_List;
typedef struct {
Packet_otg_elt *head;
Packet_otg_elt *tail;
int nb_elements;
} Packet_OTG_List;
//-----------------------------------------------------------------------------
public_list( void job_list_init (Job_List*);)
public_list( void job_list_free (Job_List* listP);)
public_list( Job_elt* job_list_get_head (Job_List*);)
public_list( Job_elt* job_list_remove_head (Job_List* );)
public_list( Job_elt* job_list_remove_element (Job_elt*, Job_List*);)
public_list( void job_list_add_head (Job_elt* , Job_List* );)
public_list( void job_list_add_tail_eurecom (Job_elt* , Job_List* );)
public_list( void job_list_add_list (Job_List* , Job_List* );)
public_list( void job_list_display (Job_List* );)
public_list( void event_list_init (Event_List*);)
public_list( void event_list_free (Event_List* listP);)
public_list( Event_elt* event_list_get_head (Event_List*);)
public_list( Event_elt* event_list_remove_head (Event_List* );)
public_list( Event_elt* event_list_remove_element (Event_elt*, Event_List*);)
public_list( void event_list_add_head (Event_elt* , Event_List* );)
public_list( void event_list_add_element (Event_elt* , Event_elt* , Event_List* );)
public_list( void event_list_add_tail_eurecom (Event_elt* , Event_List* );)
public_list( void event_list_add_list (Event_List* , Event_List* );)
public_list( void event_list_display (Event_List* );)
public_list( void pkt_list_init (Packet_OTG_List*);)
public_list( void pkt_list_free (Packet_OTG_List* listP);)
public_list( Packet_otg_elt* pkt_list_get_head (Packet_OTG_List*);)
public_list( Packet_otg_elt* pkt_list_remove_head (Packet_OTG_List* );)
public_list( Packet_otg_elt* pkt_list_remove_element (Packet_otg_elt*, Packet_OTG_List*);)
public_list( void pkt_list_add_head (Packet_otg_elt* , Packet_OTG_List* );)
public_list( void pkt_list_add_element (Packet_otg_elt* , Packet_otg_elt* , Packet_OTG_List* );)
public_list( void pkt_list_add_tail_eurecom (Packet_otg_elt* , Packet_OTG_List* );)
public_list( void pkt_list_add_list (Packet_OTG_List* , Packet_OTG_List* );)
public_list( void pkt_list_display (Packet_OTG_List* );)
#endif
+79
View File
@@ -0,0 +1,79 @@
#include "platform_types.h"
/* Types of events triggering the end of the simulation */
typedef enum End_Of_Sim_Event_Type {FRAME, TRAFFIC} End_Of_Sim_Event_Type;
/* Types regrouping both user-defined and regular events */
typedef enum Event_Type {ET_DL, ET_UL, ET_S, ET_OMG, ET_OTG} Event_Type;
/* decomposition of node functions into jobs for a given event */
typedef enum Job_type { JT_OTG, JT_PDCP, JT_PHY_MAC, JT_INIT_SYNC, JT_DL, JT_UL, RN_DL, RN_UL, JT_END} Job_Type;
typedef struct Job {
enum Job_type type;
int exe_time; /* execution time at the worker*/
int nid; /* node id*/
int eNB_flag;
int frame;
int last_slot;
int next_slot;
int ctime;
} Job;
typedef struct Signal_buffers { // (s = transmit, r,r0 = receive)
double **s_re;
double **s_im;
double **r_re;
double **r_im;
double **r_re0;
double **r_im0;
} Signal_buffers;
/*!\brief sybframe type : DL, UL, SF, */
typedef struct Packet_otg {
unsigned int sdu_buffer_size;
unsigned char *sdu_buffer;
int module_id;
int rb_id;
int dst_id;
u8 mode;
} Packet_otg;
typedef struct Event {
enum Event_Type type;
char * key;
void * value;
int frame;
} Event;
/*typedef struct Global_Time {
u32 frame;
s32 slot;
s32 last_slot;
s32 next_slot;
double time_s;
double time_ms;
};*/
typedef struct End_Of_Sim_Event {
enum End_Of_Sim_Event_Type type;
int value;
} End_Of_Sim_Event;
typedef struct Packet_otg_elt {
struct Packet_otg_elt *next;
struct Packet_otg_elt *previous;
Packet_otg otg_pkt;
} Packet_otg_elt;
typedef struct Job_element {
struct Job_elt *next;
Job job;
} Job_elt;
typedef struct Event_element {
struct Event_elt *next;
struct Event_elt *previous;
Event event;
} Event_elt;