From 7ac9d2ab81ea9892c720d2b48435e51e1a1e204b Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han <wangts@eurecom.fr> Date: Mon, 11 Dec 2017 14:27:26 +0100 Subject: [PATCH] Deadline scheduling for 40MHz --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 12 ++++----- openair1/SCHED/ru_procedures.c | 19 +++++++++----- targets/RT/USER/lte-enb.c | 14 +++++----- targets/RT/USER/lte-ru.c | 31 ++++++++++++++++------- targets/RT/USER/rt_wrapper.c | 2 ++ 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index a401111bc8..dfedb97e9c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -456,12 +456,12 @@ void *te_thread(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - //thread_top_init("te_thread",1,870000,1000000,1000000); + thread_top_init("te_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(4, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(4, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; @@ -494,12 +494,12 @@ void *te_thread1(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - //thread_top_init("te_thread1",1,870000,1000000,1000000); + thread_top_init("te_thread1",1,200000,250000,500000); pthread_setname_np( pthread_self(),"te processing 1"); LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(7, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(7, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 9e3093e2ba..386cdc4153 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -142,12 +142,15 @@ static void *feptx_thread(void *param) { RU_proc_t *proc = &ru->proc; cpu_set_t cpuset; CPU_ZERO(&cpuset); - - CPU_SET(6, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + thread_top_init("feptx_thread",1,85000,120000,500000); + pthread_setname_np( pthread_self(),"feptx processing"); + LOG_I(PHY,"thread feptx created id=%ld\n", syscall(__NR_gettid)); + //CPU_SET(6, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - thread_top_init("feptx_thread",0,870000,1000000,1000000); + while (!oai_exit) { @@ -434,12 +437,14 @@ static void *fep_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - thread_top_init("fep_thread",0,870000,1000000,1000000); + thread_top_init("fep_thread",1,100000,120000,5000000); + pthread_setname_np( pthread_self(),"fep processing"); + LOG_I(PHY,"thread fep created id=%ld\n", syscall(__NR_gettid)); cpu_set_t cpuset; CPU_ZERO(&cpuset); - CPU_SET(2, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(2, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); while (!oai_exit) { diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ff489dbd8b..1bd4f751f9 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -205,7 +205,7 @@ static void* tx_thread(void* param) { char thread_name[100]; sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + thread_top_init(thread_name,1,470000,500000,500000); while (!oai_exit) { @@ -258,10 +258,12 @@ static void* eNB_thread_rxtx( void* param ) { sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + thread_top_init(thread_name,1,470000,500000,500000); + pthread_setname_np( pthread_self(),"rxtx processing"); + LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(3, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(3, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); while (!oai_exit) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -621,7 +623,7 @@ static void* eNB_thread_prach( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); while (!oai_exit) { @@ -663,7 +665,7 @@ static void* eNB_thread_prach_br( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 158cb68898..fd59e1ae6f 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -690,6 +690,17 @@ static void* emulatedRF_thread(void* param) { struct timespec req = {0}; req.tv_sec = 0; req.tv_nsec = microsec * 1000L; + cpu_set_t cpuset; + CPU_SET(1,&cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + int policy; + struct sched_param sparam; + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO ; + pthread_setschedparam(pthread_self(), policy, &sparam); + wait_sync("emulatedRF_thread"); while(!oai_exit){ nanosleep(&req, (struct timespec *)NULL); @@ -878,7 +889,7 @@ static void* ru_thread_asynch_rxtx( void* param ) { int subframe=0, frame=0; - thread_top_init("ru_thread_asynch_rxtx",1,870000L,1000000L,1000000L); + thread_top_init("ru_thread_asynch_rxtx",1,870000,1000000,1000000); // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe @@ -975,7 +986,7 @@ static void* ru_thread_prach( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach",1,500000,1000000,20000000); while (!oai_exit) { @@ -1014,7 +1025,7 @@ static void* ru_thread_prach_br( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { @@ -1398,10 +1409,10 @@ static void* ru_thread_tx( void* param ) { CPU_ZERO(&cpuset); - thread_top_init("ru_thread_tx",1,870000L,1000000L,1000000L); + thread_top_init("ru_thread_tx",1,400000,500000,500000); - CPU_SET(5, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(5, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); @@ -1461,10 +1472,12 @@ static void* ru_thread( void* param ) { // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); + thread_top_init("ru_thread",0,400000,500000,500000); - CPU_SET(1, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(1, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + pthread_setname_np( pthread_self(),"ru thread"); + LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index e50b0ae34f..7010abb5c0 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -43,6 +43,7 @@ #include <getopt.h> #include <sys/sysinfo.h> #include "rt_wrapper.h" +#include <errno.h> static int latency_target_fd = -1; static int32_t latency_target_value = 0; @@ -281,6 +282,7 @@ void thread_top_init(char *thread_name, if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB tx thread: sched_setattr failed\n"); + fprintf(stderr,"sched_setattr Error = %s",strerror(errno)); exit(1); } -- GitLab