public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Will Wagner <will_wagner@carallon.com>
To: Andrew Lunn <andrew@lunn.ch>
Cc: eCos Discussion <ecos-discuss@ecos.sourceware.org>
Subject: Re: [ECOS] Mutex & Asserts during initialisation
Date: Fri, 08 Jul 2005 14:18:00 -0000	[thread overview]
Message-ID: <42CE8BD8.2080404@carallon.com> (raw)
In-Reply-To: <20050708140827.GA2640@lunn.ch>

Thanks Andrew.

Will try that.

The issue with SPI and i2c is that all the functions ensure only 1 
thread can access the buses at once and hence the lock. Before the 
scheduler is started there is no possibility of another thread running 
and so no need to lock the mutex. However the generic functions don't 
test for this case.

Will

Andrew Lunn wrote:
> On Fri, Jul 08, 2005 at 01:17:47PM +0100, Will Wagner wrote:
> 
>>Hi All,
>>
>>I am trying to run with asserts on to test a couple of things. However 
>>there seems to be a problem with the mutex check_this function has been 
>>implemented.
>>
>>If anything tries to lock a mutex before the scheduler has been started 
>>then an assert goes off. This is because when locking the mutex 
>>Cyg_Thread::self() returns NULL. So in the check this function locked is 
>>true but owner is NULL so it fails.
>>
>>This means that you can't use SPI or i2c before the scheduler starts. If 
>>you have any driver that is initialised via static constructor that uses 
>>either of those then the system asserts. An example of this would be the 
>>DS1307 wallclock.
>>
>>How has anyone worked around this in the past?
> 
> 
> Humm, i think this is reasonable behaviour. Anything that tries to use
> a mutex must assume it can block. Otherwise why are you using a mutex! 
> 
> I think the solution for you is to also start the schedular in a
> static constructor. Just give it a higher priority than anything that
> needs the schedular enabled.
> 
>         Andrew


-- 
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:[~2005-07-08 14:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-08 12:15 Will Wagner
2005-07-08 14:08 ` Andrew Lunn
2005-07-08 14:18   ` Will Wagner [this message]
2005-07-09 14:30   ` Paul D. DeRocco
2005-07-11  7:52     ` Fabian Scheler
2005-07-11  9:36     ` Nick Garnett
2005-07-11 10:30       ` [ECOS] issues: memcpy in flash_config_insert_value & exec -r Michael Anburaj
2005-07-12  1:22         ` [ECOS] SOS: " Michael Anburaj
2005-07-12  1:30           ` Gary Thomas
2005-07-11 10:47       ` [ECOS] Mutex & Asserts during initialisation Bart Veer

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=42CE8BD8.2080404@carallon.com \
    --to=will_wagner@carallon.com \
    --cc=andrew@lunn.ch \
    --cc=ecos-discuss@ecos.sourceware.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).