Hi all,
Im using tci6638k2k SoC(4arm+8dsp), we are using sysbios also. Task switch hook make switching between two task,
Void task_switch_hook(Task_Handle from, Task_Handle to){...}
I realize that one of tasks; "my_task" can call this, when from and to equals itself. How it is possible?
I reviewed "C:\ti\bios_6_37_03_30\packages\ti\sysbios\knl\Task.c" source file;
/*
* ======== Task_schedule ========
* Find highest priority task and invoke it.
*
* Must be called with interrupts disabled.
*/
Void Task_schedule()
{
Queue_Handle maxQ;
Task_Object *prevTask;
Task_Object *curTask;
#ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS
Int i;
#endif
do {
Task_module->workFlag = 0;
/* stall until a task is ready */
while (Task_module->curSet == 0) {
Task_allBlockedFunction();
}
/* Determine current max ready Task priority */
maxQ = (Queue_Handle)((UInt8 *)(Task_module->readyQ) +
(UInt)(Intrinsics_maxbit(Task_module->curSet)*(2*sizeof(Ptr))));
/* if a higher priority task is ready - switch to it */
if (maxQ > Task_module->curQ) {
prevTask = Task_module->curTask;
Task_module->curQ = maxQ;
Task_module->curTask = Queue_head(maxQ);
curTask = Task_module->curTask;
/* It's safe to enable intrs here */
Hwi_enable();
#ifndef ti_sysbios_knl_Task_DISABLE_ALL_HOOKS
for (i = 0; i < Task_hooks.length; i++) {
if (Task_hooks.elem[i].switchFxn != NULL) {
Task_hooks.elem[i].switchFxn(prevTask, curTask);
}
}
#endif
Log_write4(Task_LM_switch, (UArg)prevTask, (UArg)prevTask->fxn,
(UArg)curTask, (UArg)curTask->fxn);
/* Hard-disable intrs - this fxn is called with them disabled */
Hwi_disable();
Task_SupportProxy_swap((Ptr)&prevTask->context,
(Ptr)&curTask->context);
}
} while (Task_module->workFlag);
}
Note that the "Task_hooks.elem[i].switchFxn(prevTask, curTask);" is defined "task_switch_hook(Task_Handle from, Task_Handle to)"
Note that too; Task_schedule() function needs to call between hwi_disable and hwi_enable(), so any hwi doesnt interrupt switching.
Remember, i saw task_switch_hook's two parameters is same. So im reviewing Task_schedule(). According to calling "task_switch_hook" function, We can say if (maxQ > Task_module->curQ) condition achieved. If my parameters is equal, how it is possible to achieve this condition??? Same task but different priority???
Remeber; process like that;
Hwi_disable();
Task_switching();
Hwi_enable();
Im thinking of a situation, but i dont know how to test it yet.
Think task1 proceed and going to blocked state, idle loop will be run, If called an hwi and post a semaphore to Task1 just before Hwi_disable(), and Task_switch_hook calls, So condition looks like if(Prio_task1 > Prio_idle) but actually the current task not an idle, it is task1 actually, so task_switch_hook calls with same parameter. Is it possible?
Any suggestion would be help, Thanks.
Srt