From: Bart Veer <bartv@ecoscentric.com>
To: nickg@ecoscentric.com
Cc: ecos-discuss@ecos.sourceware.org
Subject: Re: [ECOS] Mutex & Asserts during initialisation
Date: Mon, 11 Jul 2005 10:47:00 -0000 [thread overview]
Message-ID: <20050711104740.04D4B65C07D@smtp.ecoscentric.com> (raw)
In-Reply-To: <m3r7e5hi5m.fsf@xl5.calivar.com> (message from Nick Garnett on 11 Jul 2005 09:16:21 +0100)
>>>>> "Nick" == Nick Garnett <nickg@ecoscentric.com> writes:
<snip>
>> I can see the other side of this. You want to write a driver
>> that can work in a multi-threaded environment, so you include a
>> mutex in it. But then you want to call it from startup code.
>> Rather than write a second specialized non-multi-threaded
>> driver, or include some sort of flag that tells it to skip the
>> locking and unlocking, it's much cleaner to simply consider the
>> attempt to lock a mutex before the threading system has been
>> initialized a harmless null operation.
Nick> And this is exactly what happens. The kernel installs the
Nick> idle thread as the current thread as soon as it is
Nick> initialized so that mutexes and semaphores will operate
Nick> correctly before the scheduler starts.
Nick> However, device drivers are usually initialized before this
Nick> point, on the assumption that the hardware should be
Nick> initialized as early as possible. Wallclock devices are
Nick> initialized a little later, but still before the idle
Nick> thread.
Nick> The driver initialization priority was set long before these
Nick> layered I2C and SPI drivers were introduced. These are a
Nick> fairly new feature, and there are clearly a few teething
Nick> troubles.
Nick> I suspect that the correct fix for this problem is to move
Nick> the initialization of the DS1307 to after the idle thread in
Nick> initialized. The simplest way of doing this is to make all
Nick> wallclock devices use CYG_INIT_IO priority.
I agree this is the right short-term solution.
In the medium or long term we may want to rethink the predefined
constructor priorities. The current order is not necessarily optimal,
and I would like to see a few more categories. It is a hard problem
with lots of potential for circular dependencies and destabilizing
existing systems, so I need to think about it for a while before
coming up with a proposal.
Bart
--
Bart Veer eCos Configuration Architect
http://www.ecoscentric.com/ The eCos and RedBoot experts
--
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss
prev parent reply other threads:[~2005-07-11 10:47 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
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 ` Bart Veer [this message]
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=20050711104740.04D4B65C07D@smtp.ecoscentric.com \
--to=bartv@ecoscentric.com \
--cc=ecos-discuss@ecos.sourceware.org \
--cc=nickg@ecoscentric.com \
/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).