Hi,
I have some code which runs once each time an event occurs. I've got this code in tasks because I need to use locks.
My first thought was to use semaphores. The hardware interrupt handler posts a semaphore and the task pends on a semphore. For example:
Void TaskFxn(Void)
{
for (;;)
{
SEM_pend(&sem, SYS_FOREVER);
...
}
}
But then I had another thought and wondered if raising and lowering the task priority was a better solution. The hardware interrupt handler sets the task priority and the task sets its own priority to -1 when it has finished. For example:
Void TaskFxn(Void)
{
for (;;)
{
...
TSK(&tsk, -1);
}
}
Both methods seem to work for me but I wondered if anyone had any thoughts about which is the better solution.
I'm not sure what better means in this case!!!
The application has several examples of this and in one case it is necessary to pass some information from the interrupt handler to the task so in this case I think the most obvious solution is to use a mailbox.
Thanks,
Matt