Page 1 of 1

FatFs hogging the OS

Posted: Sun Dec 03, 2017 12:20 pm
by Tabulous
Ive got a thread that writes data to a file, the file write is about 10KB.

Thus in the thread that writes the data it does

open->write->close.

It seems when it does this it consumes the RTOS 100% i.e no other threads are scheduled whilst this is happening.

Ive got the window watchdog running, and this ends up getting reset as thread servicing the watchdog gets starved, it needs to run every 10ms to reload the window watchdog.

If i disable the watchdog i dont get any system resets, but them i dont have the system protection the watchdog gives.

At the moment all threads are running with the same prority, default NORMALPRIO.

PS before anyone asks, using IWDG is not a option, this makes a sleeping system messy.

Re: FatFs hogging the OS

Posted: Sun Dec 03, 2017 12:30 pm
by Tabulous
increasing the window watchdog thread priority seems to fix the issue.

Re: FatFs hogging the OS

Posted: Sun Dec 03, 2017 12:33 pm
by Giovanni
Hi,

If all threads are at NORMALPRIO then one thread hogging the CPU prevents the others to execute, there is no preemptive round robin, round robin is collaborative and requires threads to yield.

You need to put such threads at a lower priority and, in general, choose appropriate priorities for all threads.

Giovanni

Re: FatFs hogging the OS

Posted: Tue Dec 05, 2017 11:16 am
by Tabulous
whats the thoughts on thread priories and allocating them.....

At the moment most of them are not time critical/low demand and also cooperative thus threads with same priority should just share the CPU in a round robin fashion.

The window watchdog and a time critical sampling thread are the two I've elevated.

But you said you should chose priories for all threads, so whats the best methodology to achieve this. The system at the moment is very stable, as such i dont want to add in at the cost of this.

Re: FatFs hogging the OS

Posted: Tue Dec 05, 2017 11:56 am
by Giovanni
A common strategy is to measure the worst case code path for threads then ordering them to have the short paths on top.

Giovanni

Re: FatFs hogging the OS

Posted: Thu Jan 11, 2018 6:39 am
by faisal
Try looking up rate monotonic scheduling. Giovanni gave a wonderful summary of it in his reply.