public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Chris Holgate <chris@zynaptic.com>
To: Stanislav Meduna <stano@meduna.org>
Cc: eCos Discussion <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] I/O thread safety
Date: Tue, 15 Sep 2009 12:09:00 -0000	[thread overview]
Message-ID: <4AAF83BF.5060304@zynaptic.com> (raw)
In-Reply-To: <4AAF766C.9070101@meduna.org>

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

  reply	other threads:[~2009-09-15 12:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-15 11:12 Stanislav Meduna
2009-09-15 12:09 ` Chris Holgate [this message]
2009-09-15 13:42   ` [ECOS] Devfs ioctl's Green, Neal
2009-09-15 15:58     ` [ECOS] " Grant Edwards

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4AAF83BF.5060304@zynaptic.com \
    --to=chris@zynaptic.com \
    --cc=ecos-discuss@ecos.sourceware.org \
    --cc=stano@meduna.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).