rework threads in 5G

This commit is contained in:
laurent
2019-04-30 10:17:08 +02:00
parent db79d72b37
commit 8a92138086
33 changed files with 5174 additions and 285 deletions
+1 -1
View File
@@ -30,7 +30,7 @@
#define RRC_CONFIG_TOOLS_H_
#define KHz (1000UL)
#define MHz (1000 * KHz)
#define MHz (1000*KHz)
typedef struct eutra_band_s {
int16_t band;
+4 -35
View File
@@ -27,12 +27,12 @@
*/
#include "flexran_agent.h"
#include <common/utils/system.h>
#include <arpa/inet.h>
void *send_thread(void *args);
void *receive_thread(void *args);
pthread_t new_thread(void *(*f)(void *), void *b);
Protocol__FlexranMessage *flexran_agent_timeout(void* args);
@@ -102,6 +102,7 @@ void *flexran_agent_task(void *args){
}
void *receive_thread(void *args) {
threadTopInit("flexran",-1,OAI_PRIORITY_RT_LOW);
flexran_agent_info_t *d = args;
void *data;
@@ -145,38 +146,6 @@ error:
}
/* utility function to create a thread */
pthread_t new_thread(void *(*f)(void *), void *b) {
pthread_t t;
pthread_attr_t att;
if (pthread_attr_init(&att)){
fprintf(stderr, "pthread_attr_init err\n");
exit(1);
}
struct sched_param sched_param_recv_thread;
sched_param_recv_thread.sched_priority = sched_get_priority_max(SCHED_FIFO) - 1;
pthread_attr_setschedparam(&att, &sched_param_recv_thread);
pthread_attr_setschedpolicy(&att, SCHED_FIFO);
if (pthread_attr_setdetachstate(&att, PTHREAD_CREATE_DETACHED)) {
fprintf(stderr, "pthread_attr_setdetachstate err\n");
exit(1);
}
if (pthread_create(&t, &att, f, b)) {
fprintf(stderr, "pthread_create err\n");
exit(1);
}
if (pthread_attr_destroy(&att)) {
fprintf(stderr, "pthread_attr_destroy err\n");
exit(1);
}
return t;
}
int channel_container_init = 0;
int flexran_agent_start(mid_t mod_id)
{
@@ -227,8 +196,8 @@ int flexran_agent_start(mid_t mod_id)
/*Initialize the continuous stats update mechanism*/
flexran_agent_init_cont_stats_update(mod_id);
new_thread(receive_thread, flexran);
pthread_t t;
threadCreate(&t, receive_thread, flexran, "flexran", -1, OAI_PRIORITY_RT);
/*Initialize and register the mac xface. Must be modified later
*for more flexibility in agent management */
+1 -22
View File
@@ -101,33 +101,12 @@ static void *pdcp_thread_main(void* param)
int init_pdcp_thread(void)
{
int error_code;
struct sched_param p;
pthread_attr_init (&pdcp_thread_attr);
pthread_attr_setstacksize(&pdcp_thread_attr,OPENAIR_THREAD_STACK_SIZE);
//attr_dlsch_threads.priority = 1;
p.sched_priority = OPENAIR_THREAD_PRIORITY;
pthread_attr_setschedparam (&pdcp_thread_attr, &p);
pthread_attr_setschedpolicy (&pdcp_thread_attr, SCHED_FIFO);
pthread_mutex_init(&pdcp_mutex,NULL);
pthread_cond_init(&pdcp_cond,NULL);
pdcp_instance_cnt = -1;
LOG_I(PDCP,"Allocating PDCP thread\n");
error_code = pthread_create(&pdcp_thread,
&pdcp_thread_attr,
pdcp_thread_main,
(void*)NULL);
if (error_code!= 0) {
LOG_I(PDCP,"Could not allocate PDCP thread, error %d\n",error_code);
return(error_code);
} else {
LOG_I(PDCP,"Allocate PDCP thread successful\n");
pthread_setname_np( pdcp_thread, "PDCP" );
}
threadCreate(&pdcp_thread, pdcp_thread_main, (void*)NULL, "PDCP", -1, OAI_PRIORITY_RT);
return(0);
}
+3 -19
View File
@@ -76,6 +76,7 @@
#include "pdcp.h"
#include "plmn_data.h"
#include "msc.h"
#include <common/utils/system.h>
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
@@ -5477,7 +5478,6 @@ void rrc_control_socket_init(){
struct sockaddr_in rrc_ctrl_socket_addr;
pthread_attr_t attr;
struct sched_param sched_param;
int optval; // flag value for setsockopt
//int n; // message byte size
@@ -5505,27 +5505,11 @@ void rrc_control_socket_init(){
LOG_E(RRC,"[rrc_control_socket_init] ERROR: Failed on binding the socket\n");
exit(1);
}
//create thread to listen to incoming packets
if (pthread_attr_init(&attr) != 0) {
LOG_E(RRC, "[rrc_control_socket_init]Failed to initialize pthread attribute for ProSe -> RRC communication (%d:%s)\n",
errno, strerror(errno));
exit(EXIT_FAILURE);
}
sched_param.sched_priority = 10;
pthread_attr_setschedpolicy(&attr, SCHED_RR);
pthread_attr_setschedparam(&attr, &sched_param);
threadTopInit("RRC Control Socket",-1,OAI_PRIORITY_RT);
pthread_t rrc_control_socket_thread;
if (pthread_create(&rrc_control_socket_thread, &attr, rrc_control_socket_thread_fct, NULL) != 0) {
LOG_E(RRC, "[rrc_control_socket_init]Failed to create new thread for RRC/ProSeApp communication (%d:%s)\n",
errno, strerror(errno));
exit(EXIT_FAILURE);
}
pthread_setname_np( rrc_control_socket_thread, "RRC Control Socket" );
threadCreate(&rrc_control_socket_thread, rrc_control_socket_thread_fct, NULL, "RRC/ProSeApp", -1, OAI_PRIORITY_RT);
}
-1
View File
@@ -58,7 +58,6 @@ int8_t mac_rrc_nr_data_req(const module_id_t Mod_idP,
uint8_t sfn_msb = (uint8_t)((frameP>>4)&0x3f);
#ifdef DEBUG_RRC
int i;
LOG_I(RRC,"[eNB %d] mac_rrc_data_req to SRB ID=%d\n",Mod_idP,Srb_id);
#endif
+1 -4
View File
@@ -116,10 +116,9 @@ mui_t rrc_gNB_mui = 0;
void openair_nr_rrc_on(const protocol_ctxt_t* const ctxt_pP){
int CC_id;
LOG_I(NR_RRC, PROTOCOL_NR_RRC_CTXT_FMT" gNB:OPENAIR NR RRC IN....\n",PROTOCOL_NR_RRC_CTXT_ARGS(ctxt_pP));
for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
for (int CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) {
rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI, BCCH, 1);
RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].SI.Active = 1;
rrc_config_nr_buffer (&RC.nrrrc[ctxt_pP->module_id]->carrier[CC_id].Srb0, CCCH, 1);
@@ -144,8 +143,6 @@ void rrc_gNB_generate_SgNBAdditionRequestAcknowledge(
rrc_gNB_ue_context_t *const ue_context_pP
){
uint8_t size;
uint8_t buffer[100];
int CC_id = ue_context_pP->ue_context.primaryCC_id;
OCTET_STRING_t *secondaryCellGroup;
NR_CellGroupConfig_t *cellGroupconfig;
+3 -29
View File
@@ -30,6 +30,7 @@
#include "link_manager.h"
#include "common/utils/LOG/log.h"
#include <common/utils/system.h>
#include <stdio.h>
#include <stdlib.h>
@@ -112,41 +113,14 @@ link_manager_t *create_link_manager(
ret->socket_link = link;
ret->run = 1;
if (pthread_attr_init(&attr))
goto error;
// Make the async interface threads real-time
//#ifndef LOWLATENCY
struct sched_param sched_param_recv_thread;
sched_param_recv_thread.sched_priority = sched_get_priority_max(SCHED_RR) - 1;
pthread_attr_setschedparam(&attr, &sched_param_recv_thread);
pthread_attr_setschedpolicy(&attr, SCHED_RR);
//#endif
if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED))
goto error;
if (pthread_create(&t, &attr, link_manager_sender_thread, ret))
goto error;
threadCreate(&t, link_manager_sender_thread, ret, "flexranSender", -1, OAI_PRIORITY_RT_LOW);
ret->sender = t;
if (pthread_create(&t, &attr, link_manager_receiver_thread, ret))
/* we should destroy the other thread here */
goto error;
threadCreate(&t, link_manager_receiver_thread, ret, "flexranReceiver", -1, OAI_PRIORITY_RT_LOW);
ret->receiver = t;
if (pthread_attr_destroy(&attr))
/* to be clean we should destroy the threads at this point,
* even if in practice we never reach it */
goto error;
return ret;
error:
LOG_E(MAC, "%s: an error occured\n", __FUNCTION__);
free(ret);
return NULL;
}
void destroy_link_manager(link_manager_t *manager)
+1 -4
View File
@@ -90,10 +90,7 @@ int cli_server_init(cli_handler_t handler)
}
/* create telnet listener thread */
if (pthread_create(&cli_server_listener, NULL, cli_server_listen, NULL)) {
perror("thread");
return -1;
}
threadCreate(&cli_server_listener, cli_server_listen, NULL, "telnet", -1, OAI_PRIORITY_RT_LOW);
return 0;
}
+2 -9
View File
@@ -90,6 +90,7 @@ what about the implementation
#include <pthread.h>
#include <stdint.h>
#include <common/utils/system.h>
#include "opt.h"
@@ -203,15 +204,7 @@ int opt_create_listener_socket(char *ip_address, uint16_t port)
return -1;
}
ret = pthread_create(&opt_listener.thread, NULL, opt_listener_thread, NULL);
if (ret != 0) {
LOG_E(OPT, "Failed to create thread for server socket: %s\n", strerror(errno));
opt_type = OPT_NONE;
close(opt_listener.sd);
opt_listener.sd = -1;
return -1;
}
threadCreate(&opt_listener.thread, opt_listener_thread, NULL, "flexran", -1, OAI_PRIORITY_RT_LOW);
return 0;
}
+1 -11
View File
@@ -195,17 +195,7 @@ void server_socket_tcp_ip4()
/* create new thread for the new connection */
if (pthread_create(&id, NULL, (void *)recv_ip4_tcp, (void*)csock))
LOG_W(OTG,"SOCKET:: TCP-IP4 ::pthread_create OK!\n");
else
LOG_W(OTG,"SOCKET:: TCP-IP4 ::Error in pthread_create \n");
if (pthread_detach(id))
LOG_W(OTG,"SOCKET:: TCP-IP4 ::pthread_detach OK!\n");
else
LOG_W(OTG,"SOCKET:: TCP-IP4 ::Error in pthread_detach\n");
threadCreate(&id, (void *)recv_ip4_tcp, (void*)csock), "OTG", -1, OAI_PRIORITY_RT_LOW);
LOG_I(OTG,"SOCKET:: TCP-IP4 :: Client n=%d finish transmission\n", cmpt_cl);
cmpt_cl+=1;
}