Tool/software: TI-RTOS
Hi all,
I have the following class, and any child of it can run provided that it implements the Run() function.
I had to attach static class function when creating task in sys/bios (same with posix API), thus I used the static
function trick. The problem with this approach is that all task essentially has same function to run, and while this was working
well (I think it was accidentally), when I created more child application crashed.
I believe there is a problem with task stacks, but I dont know how to handle that.
========================================================================================================================
Class ActiveCls {
private:
Task_Params taskParams;
Task_Handle taskLa;
Error_Block eb;
protected:
void attach(void* (*tsk_fxn)(void* arg), int priority) {
Error_init(&eb);
Task_Params_init(&taskParams);
taskParams.priority = priority;
taskParams.stackSize = 0x100000;
taskParams.arg0 = (UArg) this;
taskLa = Task_create(ActiveCls::__run, &taskParams, &eb);
if(taskLa == NULL)
{
System_printf("Task creation() failed!\n");
BIOS_exit(0);
}
/* SAME HAPPENS WITH PTHREAD API- BUT WORKS WELL UNDER WINDOWS 7 !! */
}
virtual void* Run() {
Log(
"Warning.. Run() function is not implemented for this class.\n");
return 0;
}
ActiveCls(int pri) {
attach(&ActiveCls::run, pri);
}
ActiveCls() {
Log("Warning.. Class priority is not set, defaulting to priority 1.\n");
attach(&ActiveCls::run, 1);
}
static void __run(UArg a0, UArg a1) {
((ActiveCls*) a0)->Run();
}
};
class AnExampleChild : public ActiveCls {
public:
void* Run() {
Log("Heyo!, I am running..\n")
}
};
========================================================================================================================
sincerely,
napyonsen