From d449a4de8a92788abb351bd1d798499609f6ff97 Mon Sep 17 00:00:00 2001 From: Michael Cook Date: Sun, 18 Oct 2020 12:09:43 -0400 Subject: [PATCH] Align thread priorities ``` $ ps -eL -o pid,lwp,class,priority,comm | grep -E softmodem|oai:' 6500 6500 RR -80 lte-softmodem 6500 6520 RR -80 oai:enb-L1-rx 6500 6522 RR -80 oai:enb-L1-tx 6508 6508 RR -80 lte-uesoftmodem 6508 6537 RR -80 oai:ue-phy 6508 6538 RR -80 oai:ue-stand 6509 6509 RR -80 lte-uesoftmodem $ ``` --- targets/RT/USER/lte-enb.c | 29 +++++++++++++++++++++++++++-- targets/RT/USER/lte-softmodem.c | 7 ++----- targets/RT/USER/lte-ue.c | 16 ++++++++++++++++ targets/RT/USER/lte-uesoftmodem.c | 7 ++----- 4 files changed, 47 insertions(+), 12 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 147bc955ae..104374258d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -397,8 +397,20 @@ static void *L1_thread( void *param ) { // set default return value eNB_thread_rxtx_status = 0; sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.L1_proc == proc ? 0 : 1); +#if 1 + { + struct sched_param sparam = + { + .sched_priority = 79, + }; + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) + { + LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); + } + } +#else thread_top_init(thread_name,1,470000,500000,500000); - pthread_setname_np( pthread_self(),"rxtx processing"); +#endif LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); while (!oai_exit) { @@ -919,8 +931,18 @@ void init_eNB_proc(int inst) { // Original Code from Fujitsu w/ old structure/field name //pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); //pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); + pthread_create( &L1_proc->pthread, attr0, L1_thread, L1_proc ); + if (pthread_setname_np(L1_proc->pthread, "oai:enb-L1-rx") != 0) + { + LOG_E(PHY, "pthread_setname_np: %s\n", strerror(errno)); + } + pthread_create( &L1_proc_tx->pthread, attr1, L1_thread, L1_proc_tx); + if (pthread_setname_np(L1_proc_tx->pthread, "oai:enb-L1-tx") != 0) + { + LOG_E(PHY, "pthread_setname_np: %s\n", strerror(errno)); + } } if (NFAPI_MODE!=NFAPI_MODE_VNF) { @@ -930,7 +952,10 @@ void init_eNB_proc(int inst) { AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void *)eNB); + if (opp_enabled == 1) + { + pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void *)eNB); + } } //for multiple CCs: setup master and slaves diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 72b589e386..7ef1281c66 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -516,15 +516,12 @@ int main ( int argc, char **argv ) { struct sched_param param = { - .sched_priority = 1 + .sched_priority = 79 }; if (sched_setscheduler( 0, SCHED_RR, ¶m ) == -1 ) { fprintf(stderr,"error setting scheduler ... are you root?\n"); - } - else - { - fprintf(stderr,"selected rt scheduler\n"); + return EXIT_FAILURE; } int i; diff --git a/targets/RT/USER/lte-ue.c b/targets/RT/USER/lte-ue.c index 95919cca0d..9e710a21dd 100644 --- a/targets/RT/USER/lte-ue.c +++ b/targets/RT/USER/lte-ue.c @@ -437,6 +437,7 @@ void init_UE_standalone_thread() if (pthread_create(&thread, NULL, ue_standalone_pnf_task, NULL) != 0) { LOG_E(MAC, "pthread_create failed for calling ue_standalone_pnf_task"); } + pthread_setname_np(thread, "oai:ue-stand"); } void init_UE_stub(int nb_inst, @@ -1001,7 +1002,21 @@ static void reset_queue(queue_t *q) static void *UE_phy_stub_standalone_pnf_task(void *arg) { +#if 1 + { + struct sched_param sparam = + { + .sched_priority = 79, + }; + if (pthread_setschedparam(pthread_self(), SCHED_RR, &sparam) != 0) + { + LOG_E(PHY,"pthread_setschedparam: %s\n", strerror(errno)); + } + } +#else thread_top_init("UE_phy_stub_thread_rxn_txnp4", 1, 870000L, 1000000L, 1000000L); +#endif + // for multipule UE's L2-emulator //module_id_t Mod_id = 0; //int init_ra_UE = -1; // This counter is used to initiate the RA of each UE in different SFrames @@ -2467,6 +2482,7 @@ void init_UE_single_thread_stub(int nb_inst) UE->proc.proc_rxtx[i].sub_frame_step=nb_threads; printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i); pthread_create(&UE->proc.proc_rxtx[i].pthread_rxtx, NULL, task_func, rtd); + pthread_setname_np(UE->proc.proc_rxtx[i].pthread_rxtx, "oai:ue-phy"); } } diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index 9e310318fe..e162a48726 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -545,15 +545,12 @@ void init_pdcp(void) { int main( int argc, char **argv ) { struct sched_param param = { - .sched_priority = 1 + .sched_priority = 79 }; if (sched_setscheduler( 0, SCHED_RR, ¶m ) == -1 ) { fprintf(stderr,"error setting scheduler ... are you root?\n"); - } - else - { - fprintf(stderr,"selected rt scheduler\n"); + return EXIT_FAILURE; } int CC_id;