rework threads in 5G
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user