memory barrier problem in driver development

Hi, I have been thinking, is there any necessary we should consider use the memory barrier in our driver development?

Reply to
leilei
Loading thread data ...

On Wed, 10 Dec 2008 18:20:41 -0800 (PST), leilei wrote in comp.arch.embedded:

We should consider providing enough information for somebody to begin to answer your question. Such as:

What kind of processor architecture (Core 2 Quad or 8051)?

What kind of device?

Memory mapped or I/O mapped device?

Operating system?

Without this kind of information, the only answer anyone can give to your question is "maybe"?

--
Jack Klein
Home: http://JK-Technology.Com
FAQs for
comp.lang.c http://c-faq.com/
comp.lang.c++ http://www.parashift.com/c++-faq-lite/alt.comp.lang.learn.c-c++
http://www.club.cc.cmu.edu/~ajo/docs/FAQ-acllc.html
Reply to
Jack Klein

tml

I am sorry. I am a fresh in driver development, I did not realise there are so many problem need to be considered. I usually write device driver based on x86 architecture, use gcc to compile the source.Ths OS is developed by our own company.

I know the memory barrier when I read Linux kernel source code.But I do not know how and when to use it properly.

Reply to
leilei

A safer answer is "yes" (after all, he asked if they should *consider* using memory barriers).

Memory barriers are normally implemented as a macro. If you are writing code that you want to be portable, use memory barriers in the low-level driver code. When compiling for different architectures, the macro definition will be different - on the 8051 it might be empty, while on the PPC it might be something like:

asm volatile(" eieio " : : "memory")

Reply to
David Brown

g

Hi, I have been looking for materials for these things. some article mentioned volatile key words.

I want to know what's the difference between volatile and macro like asm volatile(" eieio " : : "memory"). how to use these two things correctly.

Reply to
leilei

Briefly, volatile instructs the *compiler* to prevent re-ordering, while "eieio" instructs the PowerPC CPU to prevent re-ordering. Obviously, the "eieio" is a PowerPC specific instruction. Other (not all) processors have similar instructions as required.

--
Michael N. Moran           (h) 770 516 7918
5009 Old Field Ct.         (c) 678 521 5460
Kennesaw, GA, USA 30144    http://mnmoran.org

"So often times it happens, that we live our lives in chains
  and we never even know we have the key."
"Already Gone" by Jack Tempchin (recorded by The Eagles)

The Beatles were wrong: 1 & 1 & 1 is 1
Reply to
Michael N. Moran

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.