[ECOS] Disk I/O -> scheduling problems

Szentirmai Gergely reg@t-online.hu
Thu Apr 30 06:08:00 GMT 2009


I have an SD card with FAT filesystem, handled throught an MCI
interface. eCos did not have support for this interface (target
AT91SAM7A3), and I have written an extension - based on Atmel's library
- for the MMC driver to support it.
I have a sensor connected with SPI, and this sensor has an interrupt,
which is handled this way isr -> dsr (flag set) -> thread (flag wait) ->
spi_read. This reader thread has a high pritority.

When I write the card with a low priority thread, it blocks reading the
sensor. Sensor reading should be done in about every 5 ms.

This is because dsr-s are locked by io/src/disk.c. So the question is,
what should I do to prevent losing samples? Writing a blocks of data
(512Byte) to the card can take some time (approx. 10 ms). Are these 
really concurent request, so this locking mechanism is needed?

I have tried to unlock dsr-s (at the start of the read and write 
functiions) in my MCI driver for the lengthy operation, and it seams to 
solve my problems, the sampling is not affected by writing the card.

What are the possible effects of this "hack"?

There is some instability using the card, after a time it is unable to 
write to the card. But this can be an error in the FAT implementation 
(it corrupts the card), I need more tests. It is maybe another story.

So what is the recommened solution for handling lengthy operations in a 

This is a code part from the Atmel AT91 SPI driver:
             // Wait for its completion
                 while (!spi_bus->transfer_end)

Currently the MCI does a busy wait (which is ugly, but temporary), but
if it used this mechanism, I'd still have the same problem.

Thank you!
Gergely Szentirmai

Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss

More information about the Ecos-discuss mailing list