[ECOS] Disk I/O -> scheduling problems
Paul D. DeRocco
Thu Apr 30 06:10:00 GMT 2009
> From: Szentirmai Gergely
> 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?
> 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)
Assuming that you're using the SPI bus that doesn't share pins with the MCI
interface, it ought to be possible. Does the existing MCI driver do the
entire sector transfer without using any interrupts? If that's how it works,
then, yes, the scheduler will remain locked for the duration, which is a Bad
Idea. But in this chip the MCI interface can transfer a sector via the PDC,
so this shouldn't be necessary. You may have to start from scratch and write
a better MCI driver that uses DMA and an interrupt at the end.
Ciao, Paul D. DeRocco
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