You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The situation where I ran into this is with one low priority software task (handle_ethernet) spawning a higher priority software task (handle_mess), but while this is getting spawned a hardware tasks interrupts (transfer_complete) and tries to spawn the same function. Resulting in an error on the spawn by the hardware task.
In my opinion this shouldn't happen. The handle_mess task is 'spawned' which has a higher priority than the hardware task so the hardware task should be preempted until the spawned task has completed.
As a workaround I've wrapped the handle_mess::spawn(MessEvent::ReadingComplete).unwrap() in a critical section which seems to solve the problem.
What is most likely happening is that after a spawn handle_mess hits it's await point after being spawned by transfer_complete, if then ethernet_transmit_readings does a spawn it will fail as the high prio task is still working on the latest event. As there are await points in handle_mess it means that lower prio tasks can run while it waits for its events.
What you can do is to use a channel instead of sending messages with spawn to solve this issue. Or use an atomic bitfield to set the event as pending.
Thanks for your input, but the awaits are not hit in this state. I wrote the send event in such a way that it never relinquishes control as you can see here:
let Err(_e) = spi.send_event.try_send(EthernetEvent::TransmitReadings) else {
return;
};
mess_reading_complete(ctx);
Did you look at the backtrace? From that it's pretty clear that handle_ethernet is running first at #19, it calls the handle_mess::spawn() at #17 and is interrupted by the hardware task at #9.
If the issue was as you say it is, simply wrapping the handle_mess::spawn(MessEvent::ReadingComplete).unwrap() in a critical section shouldn't fix the issue.
The situation where I ran into this is with one low priority software task (handle_ethernet) spawning a higher priority software task (handle_mess), but while this is getting spawned a hardware tasks interrupts (transfer_complete) and tries to spawn the same function. Resulting in an error on the spawn by the hardware task.
In my opinion this shouldn't happen. The handle_mess task is 'spawned' which has a higher priority than the hardware task so the hardware task should be preempted until the spawned task has completed.
As a workaround I've wrapped the
handle_mess::spawn(MessEvent::ReadingComplete).unwrap()
in a critical section which seems to solve the problem.The rough code layout is shown below:
And I got the following backtrace from it
The text was updated successfully, but these errors were encountered: