tw_cli_task.c
资源名称:cli.rar [点击查看]
上传用户:hujq123
上传日期:2016-04-10
资源大小:153k
文件大小:8k
源码类别:
Telnet服务器
开发平台:
Unix_Linux
- /*
- * Copyright (C) 2002 Koninklijke Philips Electronics N.V.,
- * All Rights Reserved.
- *
- * This source code and any compilation or derivative thereof is the
- * proprietary information of Koninklijke Philips Electronics N.V.
- * and is confidential in nature.
- * Under no circumstances is this software to be exposed to or placed
- * under an Open Source License of any type without the expressed
- * written permission of Koninklijke Philips Electronics N.V.
- *
- *###########################################################
- */
- /*!
- * file tw_cli_task.c
- *
- * brief -
- *
- */
- /*-----------------------------------------------------------*
- *
- * %version: 4 %
- * instance: DS_6
- * %date_created: Fri Feb 21 08:04:45 2003 %
- *
- *###########################################################
- */
- /****************************************************************************
- *
- * Filename : tw_cli_task.c
- * Purpose : CLI command objects and functions to support TASK commands.
- *
- *
- *****************************************************************************/
- #include <stdio.h>
- #include <stdlib.h>
- #include "tw_cli.h"
- /*** 3rd level CLI Command Option - task profile "start"
- ***/
- static int CliCoVoproc_TaskProfileStart(Cli_cmdSession_t *pSess,
- char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskProfileStart =
- {
- "start",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "start profiling tasks",
- NULL_HELP_FUNC,
- CliCoVoproc_TaskProfileStart,
- NULL_VAR_OPT_FUNC,
- };
- /*** 3rd level CLI Command Option - task profile "stop"
- ***/
- static int CliCoVoproc_TaskProfileStop(Cli_cmdSession_t *pSess,
- char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskProfileStop =
- {
- "stop",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "stop profiling tasks and dump result",
- NULL_HELP_FUNC,
- CliCoVoproc_TaskProfileStop,
- NULL_VAR_OPT_FUNC,
- };
- /*** 3rd level CLI Command Option - task profile "freq"
- ***/
- static int CliCoVoproc_TaskProfileFreq(Cli_cmdSession_t *pSess,
- char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskProfileFreq =
- {
- "freq",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "set task profile reporting frequency (in seconds)",
- NULL,
- NULL,
- CliCoVoproc_TaskProfileFreq
- };
- /*** 2nd level CLI Command Option - task "threshold"
- ***/
- static int CliCoVoProc_TaskLogThreshold(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskLogThreshold =
- {
- "log_threshold",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Set logging threshold for unpreempted CPU usage.",
- NULL,
- NULL,
- CliCoVoProc_TaskLogThreshold
- };
- /*** 2nd level CLI Command Option - task "clr"
- ***/
- static int CliCoVoproc_TaskClr(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskClr =
- {
- "clr",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Clear Max cycles counters",
- NULL,
- CliCoVoproc_TaskClr,
- NULL
- };
- /*** 2nd level CLI Command Option - task "max"
- ***/
- static int CliCoVoproc_TaskMax(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskMax =
- {
- "max",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Max cycles and max interrupts off Intervals per task",
- NULL,
- CliCoVoproc_TaskMax,
- NULL
- };
- /*** 2nd level CLI Command Option - task "list"
- ***/
- static int CliCoVoproc_TaskList(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskList =
- {
- "list",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "List tasks started in system",
- NULL,
- CliCoVoproc_TaskList,
- NULL
- };
- /*** 2nd level CLI Command Option - task "calls"
- ***/
- static int CliCoVoproc_TaskCalls(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskCalls =
- {
- "calls",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Trace of pSOS calls",
- NULL,
- CliCoVoproc_TaskCalls,
- NULL
- };
- /*** 2nd level CLI Command Option - task "switches"
- ***/
- static int CliCoVoproc_TaskSwitches(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskSwitches =
- {
- "switches",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Trace of task switches",
- NULL,
- CliCoVoproc_TaskSwitches,
- NULL
- };
- /*** 2nd level CLI Command Option - task "stacks"
- ***/
- static int CliCoVoproc_TaskStacks(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr);
- Cli_CmdStruct_t CliCo_TaskStacks =
- {
- "stacks",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- NULL,
- "Trace of task stack",
- NULL,
- CliCoVoproc_TaskStacks,
- NULL
- };
- /*** 2nd level CLI Command Option - task "profile"
- ***/
- Cli_CmdStruct_t *CliCoOptionList_TaskProfile[] =
- {
- &CliCo_TaskProfileStart,
- &CliCo_TaskProfileStop,
- &CliCo_TaskProfileFreq,
- NULL
- };
- Cli_CmdStruct_t CliCo_TaskProfile =
- {
- "profile",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- CliCoOptionList_TaskProfile,
- "Task profile information",
- NULL,
- NULL,
- NULL
- };
- /*** 1st level CLI Command Option - "task"
- ***/
- Cli_CmdStruct_t *CliRcoOptionList_Task[] =
- {
- &CliCo_TaskLogThreshold,
- &CliCo_TaskCalls,
- &CliCo_TaskClr,
- &CliCo_TaskMax,
- &CliCo_TaskList,
- &CliCo_TaskProfile,
- &CliCo_TaskSwitches,
- &CliCo_TaskStacks,
- NULL
- };
- Cli_CmdStruct_t CliRco_Task =
- {
- "task",
- ALL_ACCESS_MODE | ALL_PRODUCT_TYPE,
- CliRcoOptionList_Task,
- "Task display commands",
- NULL,
- NULL,
- NULL
- };
- /*****************************************************************************
- *
- * CliCoVoProc_TaskLogThreshold - Set logging threshold for unpreempted CPU usage.
- *
- * Returns:
- * int - 0 on success, -1 on failure.
- *
- * Description:
- *
- *
- * History:
- * 1/3/00 BM Adapted MA's original version for Ints Threshold command.
- *
- *****************************************************************************/
- int CliCoVoProc_TaskLogThreshold(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- #ifdef TW_TASK_MAX_CYCLES_PROFILING
- int NewThreshold;
- if (sscanf(CmdStr + Ptr, "%lu", &NewThreshold) != 1)
- {
- return Cli_Printf(pSess, badParamStr);
- }
- TwTask_LogThreshold = NewThreshold;
- #else
- return Cli_Printf(pSess, "Task profiling not enabledn");
- #endif
- return 0;
- }
- static int CliCoVoproc_TaskClr(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_ClearMax ((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskMax(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_PrintMax ((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskList(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_Print((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskCalls(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_PrintCallTrace((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskSwitches(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_PrintSwitchTrace((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskStacks(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_PrintStacks((Cli_Printf_t) Cli_Printf, (void *) pSess) ;
- return 0;
- }
- static int CliCoVoproc_TaskProfileStart(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_ProfileBegin(NULL, 0, 0) ;
- return 0;
- }
- static int CliCoVoproc_TaskProfileStop(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- TwTask_ProfileEnd() ;
- return 0;
- }
- static int CliCoVoproc_TaskProfileFreq(Cli_cmdSession_t *pSess, char *CmdStr, int Ptr)
- {
- int reportEveryNseconds;
- if (sscanf(CmdStr + Ptr, "%d", &reportEveryNseconds) != 1)
- goto BadParamError;
- if (reportEveryNseconds < 1)
- goto BadParamError;
- TwTask_ProfileFreq((Cli_Printf_t) Cli_Printf, (void *) pSess, reportEveryNseconds);
- return 0;
- BadParamError:
- Cli_Printf(pSess, badParamStr);
- return 0;
- }