Hi,
I have a problem with the task scheduling model, and no idea how to solve it.
There are two tasks (lets call them T1 and T2), and one interrupt I. Task T1 does pend for a Semaphore and writes to SPI using the Stream_write function if the semaphore was posted. Task T2 does a complex calculation which can last for around 500 usecs til 4msecs depending on the size of some input data I have. Interrupt I is issued from an external source (each 5ms) and will post the semaphore that task T1 waits for. Because of some timing requirements of the Stream_write function (see please the problem under http://e2e.ti.com/support/embedded/bios/f/355/t/151706.aspx) task T1 does not necessarily wait on the semaphore when interrupt I posts it, thus task T1 will not be rescheduled (which is logic). The problem is now that if task T2 has a lot of input data to process, it seems that it slows down the reaction time of task T1 (even if it owns the required semaphore) in some way and this will lead to a system abort because it messes up the SPI communication mechanism. My question is if there is a way to cyclically interrupt the whole system (lets say each 500 usecs) and manually force a rescheduling of the tasks I have in the system. Task T1 already has the highest priority.
Here is the pseudo code of my system:
Void InterruptI(Void)
{
Semaphore_post(tx_event);
}
Void TaskT1(Void)
{
while (1)
{
Semaphore_pend(tx_event, BIOS_WAIT_FOREVER);
Stream_write(spiHandle, BIOS_WAIT_FOREVER); //interrupt I can also be triggered if Stream_write is currenty blocking => T1 does not wait on tx_event during post time
}
}
Void TaskT2(Void)
{
while(1)
{
Semaphore_pend(input_data_rx_event, BIOS_WAIT_FOREVER);
Do_heavy_computation(input_data); //can last from 500usecs - 4ms
}
}
Btw for the future I've planned a task T3 which does even more complex calculations (processing times around 30-40ms). How can I ensure that I met the timing requirements of task T1 then?
Any help on this issue is very appreciated. If you need more info please let me know. Btw Iam using bios_6_32_05_54 and ipc_1_23_05_40 on an OMAP-L138 device.
Thanks in advance.
Kind Regards,
Steve