This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: I/O thread safety


Stanislav Meduna wrote:
> Hi,
> 
> I'd like to ask whether and how is the thread-safety
> of the I/O subsystem approached - is this a problem
> of application code, each subsystem, each driver,...?
> 
> I am implementing a driver for a CAN controller
> connected via a SPI interface. Each CAN controller
> transaction requires a few separate SPI transactions
> that should not be interrupted by transactions done
> from another thread (this can be probably fixed
> to do everything in one SPI transaction, but
> I'd like to ask anyway).

The generic SPI layer has a mutex which protects the bus between calls
to cyg_spi_transaction_begin and cyg_spi_transaction_end, so you can
assemble an atomic series of SPI transfers fairly easily.  You can
either hold the chip select for the device for the duration of the
entire transaction or use the 'drop_cs' parameter in
cyg_spi_transaction_transfer in order to release the chip select between
transfers.  Of course this assumes that you're accessing the SPI API
from thread context and not DSR handlers from the CAN driver.

Chris.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]