Hi Dan.
quote:
Without registers or a stack being part of a tasks context, I don't think there's a way for a task using shared code to refer to its parameter again.
For the general case, this is entirely true.
However, for the specific case where you know that the parameter(s) passed to the task are done so in registers, you may be able to pull this off. I haven't tried it, though.
Just thinking off the top of my head, this ought to work trivially the first time the task runs (since the entry point is a "conventional" one). Exactly what happens when the task is resumed at a later time is not so clear, nor is it clear as to what one would pass at the call-by-function in OSSched().
Perhaps a more robust alternative would be to provide an extra field in a task's tcb -- a void pointer which is passed to OSCreateTask(), as other OS's do. This "tcb extension" would be very useful, as you can imagine ... but consumes a pointer per tcb, regardless of whether it's used or not ...
quote:
If I can tolerate the overhead, I suppose I could have task derive its CCB address by calculating its task index (relative to others) from its TCB address (a la, OStID) each time the task is resumed.
Take a look at the source code in demod1 in the PIC distribution. There, OStID() is used on-the-fly to figure out which task "we're in".
BTW, OStID() is a pretty inefficient function. If you have suggestions as to how to improve the "detect which task I am" function, pls let me know.
Regards, and Happy Holidays.
------------------