/** ****************************************************************************** * @file task_manager.c * @author MSO Application Team * @version V1.0.0 * @date 10-October-2011 * @brief This file provides all the memory related operation functions. ****************************************************************************** * @attention * * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. * *

© COPYRIGHT 2015 MSO

****************************************************************************** */ /** @addtogroup BMCU(EMCB) * @{ */ /* Includes ------------------------------------------------------------------*/ #include "includes.h" #include "malloc.h" #include "asutil.h" #include "console.h" /* Private typedef -----------------------------------------------------------*/ /* Private define ------------------------------------------------------------*/ #define OS_MAX_TASK_PRIO 14 /* Private macro -------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ OS_TCB AppTaskTCB[OS_MAX_TASK_PRIO - 3]; // 0 ~ 2 Task -> uC/OS u16 disCPU_Usage[OS_MAX_TASK_PRIO - 3]; /* Private function prototypes -----------------------------------------------*/ /* Private functions ---------------------------------------------------------*/ void TaksTCBInit(void) { memset(AppTaskTCB, 0x00, sizeof(OS_TCB) * (OS_MAX_TASK_PRIO - 3)); } void *GetAppTaskTCB(u16 prio) { return &AppTaskTCB[prio - 3]; } #ifdef CONSOLE_DEBUG /* Command processing in Task Status Mode STATE */ s8 Process_TaskStatus_Data(u8 *text, u16 size) { s8 ret; if (size > 1) { if (text[1] != ' ') return(0); /* Invalid command if space is in first position */ } text[size] = 0x00; ret = 1; switch (text[0]) { case 'o': screenmode = OP_MODE; ViewScreen(); break; case 's': screenmode = SET_MODE; ViewScreen(); break; case 'd': screenmode = DIAG_MODE; ViewScreen(); break; default: ret = 0; break; } return(ret); } u32 disCPUSum; u32 bakOSTaskCtxSwCtr; u32 PerSecOSTaskCtxSwCrt; u32 disOSTaskCtxSwCtr; u32 cswTick = 0; void CalOSTaskCtxSwCtrPerSec(u32 tick) { cswTick += tick; if (cswTick >= 1000) { PerSecOSTaskCtxSwCrt = OSTaskCtxSwCtr - bakOSTaskCtxSwCtr; bakOSTaskCtxSwCtr = OSTaskCtxSwCtr; cswTick = 0; } } void osDisplayTaskStatus(u8 p) { u32 CPUSum = 0; u8 *text; static u32 tsCount = 0; if (p || (tsCount <= 0)) { text = mymalloc(100); if (text != NULL) { for (int i = 0; i < OS_MAX_TASK_PRIO - 3; i++) { if (AppTaskTCB[i].StkPtr == NULL) continue; if (p) { sprintf((char *)text, "%s", AppTaskTCB[i].NamePtr); NormalOutXY( 2, 8 + i, text); } if (p) { sprintf((char *)text, "%6d %6d %6d", AppTaskTCB[i].StkSize, AppTaskTCB[i].StkFree, AppTaskTCB[i].StkUsed ); NormalOutXY( 18, 8 + i, text); } if (p ||(disCPU_Usage[i] != AppTaskTCB[i].CPUUsage)) { sprintf((char *)text, "%6.2f(%6.2f)" , (float)AppTaskTCB[i].CPUUsage / 100 , (float)AppTaskTCB[i].CPUUsageMax / 100 ); NormalOutXY( 18 + 24, 8 + i, text); disCPU_Usage[i] = AppTaskTCB[i].CPUUsage; } if (p) { sprintf((char *)text, "%6d", AppTaskTCB[i].TickRemain); NormalOutXY( 64, 8 + i, text); } CPUSum += AppTaskTCB[i].CPUUsage; } if (p ||(disCPUSum != CPUSum)) { sprintf((char *)text, "%5.1f", (float)CPUSum / 100 ); GreenOutXY( 42, 20, text); disCPUSum = CPUSum; } if (p || (disOSTaskCtxSwCtr != PerSecOSTaskCtxSwCrt)) { sprintf((char *)text, "%6d", PerSecOSTaskCtxSwCrt); GreenOutXY( 70, 20, text); disOSTaskCtxSwCtr = PerSecOSTaskCtxSwCrt; } myfree(text); } tsCount = 200; } tsCount--; } #endif // #ifdef CONSOLE_DEBUG /*******************(C)COPYRIGHT 2015 MSO ********************END OF FILE******/