From: "Perez-Gonzalez, Inaky" <inaky.perez-gonzalez@intel.com>
To: "'Ming Lei'" <lei.ming@attbi.com>,
"'linux-kernel@vger.kernel.org'" <linux-kernel@vger.kernel.org>
Subject: RE: can linux RT thread corrupt global variable?
Date: Thu, 8 May 2003 13:46:27 -0700 [thread overview]
Message-ID: <A46BBDB345A7D5118EC90002A5072C780CCAFD78@orsmsx116.jf.intel.com> (raw)
> From: Ming Lei [mailto:lei.ming@attbi.com]
>
> ...
>
> There is a global variable I define as 'int cpl'. All the threads and main
> process may alter cpl at any time. cpl may have one of these values {0,
> 0xf000006e, 0xf0000068, 0xe0000000, 0xe0000060}.
>
> <Problem=> at some point of execution which cpl should be a value say
> e0000060, but the actual value retained at cpl is another say e0000000;
that
> is, the value is changed without the program actually done anything on it.
> The retained value I observed is kind of historic value(one of these value
> in the above set), not the arbituary value. The problem had occured just
> after context switch, also occured during a thread execution.
Probably GCC is keeping the value of the variable around in
some register. Did you declare the global variable as 'volatile'?
[as in "it can be modified by entities external to the flow of
the code"]. Try that.
On the other hand - being an integer, access should be atomic,
most of the time, but I would not really trust that, at least
portability wise. Protecting access to it with a mutex would
be a good idea ...
> Is linux kernel 2.4.10 considered strictly preemptive such as VxWorks or
> other RTOS?
Nope
> I guess 2.4.10 may simulate preemptive with running scheduler on
> every syscall or interrupt returns. Am I right?
You need the preemption patches or 2.5
I hope you are not trying to do serious real-time w/ Linux ... are you?
> Is printf() real-time priority thread safe?
Dunno - you'd have to check the internal implementation in
glibc. Last time I heard anything about it, it had some
mutex dangling around, but I could be wrong.
Iñaky Pérez-González -- Not speaking for Intel -- all opinions are my own
(and my fault)
next reply other threads:[~2003-05-08 20:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-05-08 20:46 Perez-Gonzalez, Inaky [this message]
-- strict thread matches above, loose matches on Subject: below --
2003-05-05 20:52 can linux RT thread corrupt global variable? Ming Lei
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=A46BBDB345A7D5118EC90002A5072C780CCAFD78@orsmsx116.jf.intel.com \
--to=inaky.perez-gonzalez@intel.com \
--cc=lei.ming@attbi.com \
--cc=linux-kernel@vger.kernel.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 NNTP newsgroup(s).