From 48f0fe00384c6626190be05cf741f99344907d7b Mon Sep 17 00:00:00 2001 From: "huanfeng.wang" Date: Wed, 16 Aug 2023 09:35:29 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=BB=91=E6=A0=B8=E6=8E=A5=E5=8F=A3osp=5Fset=5Ftaskcpu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main.c | 2 ++ interface/arm_interface.h | 10 +++++++ osp/inc/ospTask.h | 4 ++- osp/src/ospLog.c | 4 +-- osp/src/ospTask.c | 60 +++++++++++++++++++++++++++++++-------- 5 files changed, 65 insertions(+), 15 deletions(-) diff --git a/app/src/main.c b/app/src/main.c index 084e874..4bb78b5 100644 --- a/app/src/main.c +++ b/app/src/main.c @@ -27,6 +27,7 @@ int32_t test_case(uint32_t argc, int32_t* argvp); extern OSP_STATUS osp_init(); +extern int32_t osp_set_taskcpu(uint8_t cpu, uint8_t pri); extern uint8_t osp_sw_queue_init(); #ifdef ENABLE_JESD_TEST @@ -52,6 +53,7 @@ int32_t main(int32_t argc, char* argvp[]) UCP_API_RFIC_CellSetup(2575770000u, 2575770000u, 100000000u, 0); #endif osp_init(); + osp_set_taskcpu(7, 95); drv_init(); #ifdef PALLADIUM_TEST diff --git a/interface/arm_interface.h b/interface/arm_interface.h index 52c5109..b81437f 100644 --- a/interface/arm_interface.h +++ b/interface/arm_interface.h @@ -59,6 +59,16 @@ brief: osp function init */ OSP_STATUS osp_init(); +/********************** set task function *********************/ +/* +name: osp_set_taskcpu +para: uint8_t cpu :0-7 +para: uint8_t pri :1-99 +brief: osp function init +return value:0:success +*/ +int32_t osp_set_taskcpu(uint8_t cpu, uint8_t pri); + uint32_t read_stc_local_timer(void); /* diff --git a/osp/inc/ospTask.h b/osp/inc/ospTask.h index ba51002..a578d7a 100644 --- a/osp/inc/ospTask.h +++ b/osp/inc/ospTask.h @@ -177,7 +177,9 @@ extern int32_t osp_task_is_shell(uint32_t taskid); extern void osp_start_task_all(void); extern int32_t osp_set_net_task_msg_que(int32_t taskid, int32_t txudpid, int32_t rxudpid); extern int32_t osp_local_shell_task_is_reged(void); -extern OSP_STATUS osp_regtask(OSP_TASKMSG_REG *TaskRegTbl); +extern OSP_STATUS osp_regtask(OSP_TASKMSG_REG *TaskRegTbl); +extern int32_t osp_set_taskcpu(uint8_t cpu, uint8_t pri); + #ifdef __cplusplus } diff --git a/osp/src/ospLog.c b/osp/src/ospLog.c index b76a319..6e89f09 100644 --- a/osp/src/ospLog.c +++ b/osp/src/ospLog.c @@ -228,8 +228,8 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) ulfreeram = osp_get_freeram(); if((ulfreeram <= FREE_RAM_SIZE) || (1 == g_ucFflushEnable)) { - sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, (p_log_file_cfg[logid][type].cur_file_idx & 0x7)+1, logid, msg_name); - system(name); + //sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, (p_log_file_cfg[logid][type].cur_file_idx & 0x7)+1, logid, msg_name); + //system(name); UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x ulfreeram:%u g_ucFflushEnable:%u name:%s\n", __LINE__, logid, type, ulfreeram, g_ucFflushEnable, name); osp_log_cfg_reload(); } diff --git a/osp/src/ospTask.c b/osp/src/ospTask.c index f1a859a..bfe11e2 100644 --- a/osp/src/ospTask.c +++ b/osp/src/ospTask.c @@ -68,13 +68,13 @@ OSP_TASKMSG_REG g_TaskRegTbl[] = { //{DbgLogTask, "OspDbglog", NOMARL_MSG_PRI(7), NULL, (OSP_FUNCPTR)osp_dbg_log_main, 0, OSP_PROCESS_MSG}, //{localshellout, "localshellout", RT_MSG_PRI(10), NULL, (OSP_FUNCPTR)osp_local_shell_out_main, 0, OSP_PROCESS_MSG}, - {localshellin, "localshellin", RT_NOMSG_PRI(98), NULL, (OSP_FUNCPTR)osp_shell_main, 0, OSP_PROCESS_MSG}, - {remoteshellout, "remoteshellout", RT_NOMSG_PRI(98), NULL, (OSP_FUNCPTR)osp_shell_task, 0, OSP_OTHER_MSG}, - {OspTickLess, "OspTickLess", RT_NOMSG_PRI(20), NULL, (OSP_FUNCPTR)osp_tick_less, 1, OSP_PROCESS_MSG}, + //{localshellin, "localshellin", RT_NOMSG_PRI(98), NULL, (OSP_FUNCPTR)osp_shell_main, 0, OSP_PROCESS_MSG}, + //{remoteshellout, "remoteshellout", RT_NOMSG_PRI(98), NULL, (OSP_FUNCPTR)osp_shell_task, 0, OSP_OTHER_MSG}, + //{OspTickLess, "OspTickLess", RT_NOMSG_PRI(20), NULL, (OSP_FUNCPTR)osp_tick_less, 1, OSP_PROCESS_MSG}, #ifdef HEARTBEAT_ENABLE {OspTmrTask, "OspTmrTask", RT_NOMSG_PRI(99), NULL, (OSP_FUNCPTR)OspTimerTask, 2, OSP_OTHER_MSG}, #endif - {OspDbgLog, "OspLogTask", RT_NOMSG_PRI(75), NULL, (OSP_FUNCPTR)osp_oam_msg_proc_task, 0, OSP_OTHER_MSG}, + //{OspDbgLog, "OspLogTask", RT_NOMSG_PRI(75), NULL, (OSP_FUNCPTR)osp_oam_msg_proc_task, 0, OSP_OTHER_MSG}, //{ospnetshellrx, "ospnetshellrx", NOMARL_MSG_PRI(6), (OSP_FUNCPTR)osp_net_shell_init, (OSP_FUNCPTR)osp_net_shell_main, 0, OSP_UDP_MSG, (U64)&udp_shell_rx_task}, }; @@ -520,15 +520,51 @@ OSP_TASKCB *osp_get_taskcb_base(void) return gOspTask; } -int32_t osp_set_taskcpu(int32_t taskid, int32_t cpuid) +int32_t osp_set_taskcpu(uint8_t cpu, uint8_t pri) { - cpu_set_t mask; - CPU_ZERO(&mask); - CPU_SET(cpuid, &mask); - - osp_assert(0 == pthread_setaffinity_np(gOspTask[taskid].PhreadId, sizeof(mask), &mask)); - return 0; + OSP_TASKMSG_REG task_reg_tabl[3]; + uint8_t i = 0; + OSP_STATUS ret = OSP_OK; + + if (cpu > 7) + { + UCP_PRINT_DEBUG("coreid %d beyond 7\n", cpu); + return OSP_ERROR; + } + + memset(&task_reg_tabl[0], 0, sizeof(OSP_TASKMSG_REG)); + task_reg_tabl[0].TaskId = OspDbgLog; + strcpy((void *)&task_reg_tabl[0].TaskName,"OspDbgLog"); + task_reg_tabl[0].TaskPri = RT_NOMSG_PRI(pri); + task_reg_tabl[0].Init = NULL; + task_reg_tabl[0].MainLoop = (OSP_FUNCPTR)osp_oam_msg_proc_task; + task_reg_tabl[0].Cpu = cpu; + task_reg_tabl[0].MsgType = OSP_PROCESS_MSG; + + memset(&task_reg_tabl[1], 0, sizeof(OSP_TASKMSG_REG)); + task_reg_tabl[1].TaskId = localshellin; + strcpy((void *)&task_reg_tabl[1].TaskName,"localshellin"); + task_reg_tabl[1].TaskPri = RT_NOMSG_PRI(90); + task_reg_tabl[1].Init = NULL; + task_reg_tabl[1].MainLoop = (OSP_FUNCPTR)osp_shell_main; + task_reg_tabl[1].Cpu = cpu; + task_reg_tabl[1].MsgType = OSP_OTHER_MSG; + + memset(&task_reg_tabl[2], 0, sizeof(OSP_TASKMSG_REG)); + task_reg_tabl[2].TaskId = remoteshellout; + strcpy((void *)&task_reg_tabl[2].TaskName,"remoteshellout"); + task_reg_tabl[2].TaskPri = RT_NOMSG_PRI(91); + task_reg_tabl[2].Init = NULL; + task_reg_tabl[2].MainLoop = (OSP_FUNCPTR)osp_shell_task; + task_reg_tabl[2].Cpu = cpu; + task_reg_tabl[2].MsgType = OSP_OTHER_MSG; + + for (i = 0; i < 3; i++) + { + ret = osp_regtask(&task_reg_tabl[i]); + } + + return ret; } - From 52c901deae874ae8a11c36a4bcb333be27c1d7c1 Mon Sep 17 00:00:00 2001 From: "huanfeng.wang" Date: Wed, 16 Aug 2023 16:13:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=88=A0=E9=99=A4=E9=80=9A=E8=BF=87freeram?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=85=E5=AD=98=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- osp/src/ospLog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/osp/src/ospLog.c b/osp/src/ospLog.c index 6e89f09..8f456bd 100644 --- a/osp/src/ospLog.c +++ b/osp/src/ospLog.c @@ -203,7 +203,7 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) char msg_name[10] = {0}; int32_t file_idx = 0; uint32_t type = 0; - uint32_t ulfreeram = 0; + //uint32_t ulfreeram = 0; if (logid >= MAX_LOG_CFG_NUM || logid < 0) { @@ -225,12 +225,12 @@ OSP_STATUS osp_update_log(uint32_t len, uint32_t logid, uint32_t msg_type) UCP_PRINT_LOG("osp_update_log logid:%d type:0x%x cur_sum_len:%u max_file_size_M:%u !\n", logid,type, p_log_file_cfg[logid][type].cur_sum_len, p_log_file_cfg[logid][type].max_file_size_M); /*判断当前系统是否还有足够空间*/ - ulfreeram = osp_get_freeram(); - if((ulfreeram <= FREE_RAM_SIZE) || (1 == g_ucFflushEnable)) + //ulfreeram = osp_get_freeram(); + if(1 == g_ucFflushEnable) { //sprintf(name, "rm -rf %s%u-%u-%s.log", p_log_file_cfg[logid][type].logname, (p_log_file_cfg[logid][type].cur_file_idx & 0x7)+1, logid, msg_name); //system(name); - UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x ulfreeram:%u g_ucFflushEnable:%u name:%s\n", __LINE__, logid, type, ulfreeram, g_ucFflushEnable, name); + UCP_PRINT_LOG("osp_update_log line:%d logid:%d type:0x%x g_ucFflushEnable:%u name:%s\n", __LINE__, logid, type, g_ucFflushEnable, name); osp_log_cfg_reload(); }