SYS/BIOS  7.00
Load.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020, Texas Instruments Incorporated - https://www.ti.com
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  *
32  */
229 #ifndef ti_sysbios_utils_Load__include
230 #define ti_sysbios_utils_Load__include
231 
232 /* BIOS 6.x compatibility, use -Dxdc_std__include to disable */
233 #include <xdc/std.h>
234 
235 #include <stdbool.h>
236 #include <stddef.h>
237 #include <stdint.h>
238 
239 #include <ti/sysbios/knl/Queue.h>
240 #include <ti/sysbios/knl/Task.h>
241 #include <ti/sysbios/hal/Hwi.h>
242 
244 
245 #define ti_sysbios_utils_Load_long_names
246 #include "Load_defs.h"
247 
248 #ifdef __cplusplus
249 extern "C" {
250 #endif
251 
252 /*
253  * ======== INTERNAL DEFINITIONS ========
254  */
255 
259 typedef void (*Load_FuncPtr)(void);
260 
264 typedef struct {
265  uint32_t threadTime;
266  uint32_t totalTime;
267 } Load_Stat;
268 
273 typedef struct {
274  Queue_Elem qElem;
275  uint32_t totalTimeElapsed;
276  uint32_t totalTime;
277  uint32_t nextTotalTime;
278  uint32_t timeOfLastUpdate;
279  void * threadHandle;
280 } Load_HookContext;
283 typedef struct {
284  Queue_Object taskList; /* List to hold registered task instances */
285  int taskHId; /* Task Hook Context Id for this module */
286  uint32_t taskStartTime; /* The start time of the current task */
287  Task_Handle runningTask; /* Currently running task */
288  uint32_t timeElapsed; /* Working count of time elapsed */
289  bool firstSwitchDone; /* Flag for first task switch */
290  uint32_t swiStartTime; /* Start time of the current Swi */
291  Load_HookContext swiEnv; /* Singleton hook context for swi's */
292  uint32_t swiCnt; /* number of Swi's currently executing */
293  uint32_t hwiStartTime; /* Start time of the current Hwi */
294  Load_HookContext hwiEnv; /* Singleton hook context for hwi's */
295  uint32_t hwiCnt; /* number of Hwi's currently executing */
296  uint32_t timeSlotCnt; /* count of number of time windows printed */
297  uint32_t minLoop; /* shortest time thru the idle loop */
298  uint32_t minIdle; /* minLoop is never set below this value */
299  uint32_t t0; /* start time of previous call to idle fxn */
300  uint32_t idleCnt; /* number of times through idle loop */
301  uint32_t cpuLoad; /* CPU load in previous time window */
303 
304 /*
305  * ======== FUNCTION DECLARATIONS ========
306  */
307 extern void Load_init(void);
323 extern bool Load_getTaskLoad(Task_Handle task, Load_Stat *stat);
330 extern void Load_update();
337 extern void Load_updateLoads();
346 extern void Load_updateContextsAndPost();
353 extern void Load_updateCurrentThreadTime();
360 extern void Load_updateThreadContexts();
368 extern void Load_reset();
380 extern bool Load_getGlobalSwiLoad(Load_Stat *stat);
392 extern bool Load_getGlobalHwiLoad(Load_Stat *stat);
408 extern uint32_t Load_getCPULoad();
416 extern uint32_t Load_calculateLoad(Load_Stat *stat);
422 extern uint32_t Load_setMinIdle(uint32_t newMinIdleTime);
433 extern void Load_addTask(Task_Handle task, Load_HookContext *env);
442 extern bool Load_removeTask(Task_Handle taskHandle);
447 extern void Load_idleFxn();
453 extern void Load_startup();
465 extern void Load_taskCreateHook(Task_Handle task, Error_Block *eb);
474 extern void Load_taskDeleteHook(Task_Handle task);
484 extern void Load_taskSwitchHook(Task_Handle curTask, Task_Handle nextTask);
492 extern void Load_swiBeginHook(Swi_Handle swi);
500 extern void Load_swiEndHook(Swi_Handle swi);
508 extern void Load_hwiBeginHook(Hwi_Handle hwi);
516 extern void Load_hwiEndHook(Hwi_Handle hwi);
528 extern void Load_taskRegHook(int id);
539 extern void Load_logLoads(void);
545 extern void logCPULoad(void);
548 #define Load_module ((Load_Module_State *) &(Load_Module_state))
549 
550 #ifdef __cplusplus
551 }
552 #endif
553 
554 #endif /* ti_sysbios_utils_Load__include */
555 
556 #undef ti_sysbios_utils_Load_long_names
557 #include "Load_defs.h"
int taskHId
Definition: Load.h:285
uint32_t cpuLoad
Definition: Load.h:301
uint32_t swiStartTime
Definition: Load.h:290
void Load_init(void)
void(* Load_FuncPtr)(void)
Callback function type.
Definition: Load.h:259
uint32_t hwiCnt
Definition: Load.h:295
uint32_t threadTime
Definition: Load.h:265
uint32_t Load_calculateLoad(Load_Stat *stat)
Compute total CPU load from a Load_Stat structure.
bool Load_getGlobalSwiLoad(Load_Stat *stat)
Return the load and time spent in Swi&#39;s.
bool Load_getGlobalHwiLoad(Load_Stat *stat)
Return the load and time spent in hwi&#39;s.
uint32_t minLoop
Definition: Load.h:297
uint32_t timeSlotCnt
Definition: Load.h:296
Load_HookContext hwiEnv
Definition: Load.h:294
uint32_t Load_setMinIdle(uint32_t newMinIdleTime)
Set lower bound on idle loop time used to compute CPU load.
uint32_t timeElapsed
Definition: Load.h:288
Load_HookContext swiEnv
Definition: Load.h:291
uint32_t hwiStartTime
Definition: Load.h:293
void Load_update()
Record thread statistics and reset all counters.
bool Load_removeTask(Task_Handle taskHandle)
Remove a task from the list for benchmarking.
Opaque queue element.
Definition: Queue.h:204
Definition: Hwi.h:773
Swi_Struct * Swi_Handle
Definition: Swi.h:312
Runtime error manager.
Queue Manager.
bool Load_getTaskLoad(Task_Handle task, Load_Stat *stat)
Return the load and time spent in a specific task.
uint32_t minIdle
Definition: Load.h:298
Error block.
Definition: Error.h:152
void Load_addTask(Task_Handle task, Load_HookContext *env)
Add a task to the list for benchmarking.
Task_Handle runningTask
Definition: Load.h:287
bool firstSwitchDone
Definition: Load.h:289
Queue_Object taskList
Definition: Load.h:284
uint32_t taskStartTime
Definition: Load.h:286
Load statistics info.
Definition: Load.h:264
void Load_reset()
Reset all internal load counters.
Task Manager.
uint32_t totalTime
Definition: Load.h:266
uint32_t idleCnt
Definition: Load.h:300
Definition: Load.h:283
struct Task_Struct * Task_Handle
Definition: Task.h:526
uint32_t swiCnt
Definition: Load.h:292
uint32_t t0
Definition: Load.h:299
uint32_t Load_getCPULoad()
Return an estimate of the global CPU load.
© Copyright 1995-2022, Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy policy | Terms of use | Terms of sale