DSPRelated.com
Forums

TSK objects created dynamically

Started by net_hotang September 5, 2006
Hi,everyone
I want to create my task dynamically after taskA,and i wrote those code in
taskA:
 ��    
    TSK_Attrs attrs;
    tskVideoInputInit();//video initial function
    tskVideoInputStart(); //video start function 
    // create video task
    attrs = TSK_ATTRS;
    attrs.priority = 3;
    attrs.stacksize = 16384; 
    attrs.name = "tskVideoInput";//task name
    TSK_create((Fxn)"_tskVideoInput", &attrs);//create task
��
but i found this video input task didn't work! could someone help me about
this? By the way, my other settings is absolutely right.
> Hi,everyone > I want to create my task dynamically after taskA,and i wrote those code in > taskA: > ...... > TSK_Attrs attrs; > tskVideoInputInit();//video initial function > tskVideoInputStart(); //video start function > // create video task > attrs = TSK_ATTRS; > attrs.priority = 3; > attrs.stacksize = 16384; > attrs.name = "tskVideoInput";//task name > TSK_create((Fxn)"_tskVideoInput", &attrs);//create task
It looks like you want your task to call a function with prototype void tskVideoInput(void); A) You shouldn't have the quotes around the function name in the TSK_create call. B) You don't need to explicity put the underscore in front of the function name. C) If this is C++ code (not C code) you need to extern "C" your function, otherwise you need to call the TSK_create funtion with C++ mangled name (do a google search for C++ name mangling if you don't know what this is). So you probably want to do something like: extern "C" void tskVideoInput(void); ... TSK_create((Fxn)tskVideoInput,&attrs,NULL);
> ...... > but i found this video input task didn't work! could someone help me about > this? By the way, my other settings is absolutely right.
> C) If this is C++ code (not C code) you need to extern "C" your > function, otherwise you need to call the TSK_create funtion with C++ > mangled name (do a google search for C++ name mangling if you don't > know what this is).
Actually, this part isn't required if you're dynamically creating tasks. Its only required if you want to statically create tasks from the DSP/BIOS .cdb file, or if you ever want to call that function from some other C (not C++) context.