FatFs hogging the OS

ChibiOS public support forum for all topics not covered by a specific support forum.

Moderators: barthess, RoccoMarco, utzig, lbednarz, tfAteba

Tabulous
Posts: 426
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 11 times

FatFs hogging the OS

Postby Tabulous » Sun Dec 03, 2017 12:20 pm

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.

Tabulous
Posts: 426
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 11 times

Re: FatFs hogging the OS

Postby Tabulous » Sun Dec 03, 2017 12:30 pm

increasing the window watchdog thread priority seems to fix the issue.

User avatar
Giovanni
Site Admin
Posts: 10487
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 253 times
Been thanked: 220 times
Contact:

Re: FatFs hogging the OS

Postby Giovanni » Sun Dec 03, 2017 12:33 pm

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

Tabulous
Posts: 426
Joined: Fri May 03, 2013 12:02 pm
Has thanked: 1 time
Been thanked: 11 times

Re: FatFs hogging the OS

Postby Tabulous » Tue Dec 05, 2017 11:16 am

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.

User avatar
Giovanni
Site Admin
Posts: 10487
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 253 times
Been thanked: 220 times
Contact:

Re: FatFs hogging the OS

Postby Giovanni » Tue Dec 05, 2017 11:56 am

A common strategy is to measure the worst case code path for threads then ordering them to have the short paths on top.

Giovanni

faisal
Posts: 54
Joined: Wed Jul 19, 2017 12:44 am
Has thanked: 6 times
Been thanked: 3 times

Re: FatFs hogging the OS

Postby faisal » Thu Jan 11, 2018 6:39 am

Try looking up rate monotonic scheduling. Giovanni gave a wonderful summary of it in his reply.


Return to “General Support”

Who is online

Users browsing this forum: No registered users and 5 guests