EmbeddedRelated.com
Forums

side effects problem.

Started by leilei December 7, 2008
On Sun, 7 Dec 2008 13:31:39 -0500, "Jujitsu Lizard"
<jujitsu.lizard@gmail.com> wrote:

>"leilei" <huxuelei630@gmail.com> wrote in message >news:f60b5048-0254-45e1-88ae-b83f1fb0e468@g1g2000pra.googlegroups.com... >> Hi, I am reading <Linux Device Drivers, 3rd Edition>, >> In section 9.1.1, it described the side effect about memory access: >> The main difference between I/O registers and RAM is that I/O >> operations have side effects, while memory operations have none: the >> only effect of a memory write is storing a value to a location, and a >> memory read returns the last value written there. Because memory >> access speed is so critical to CPU performance, the no-side-effects >> case has been optimized in several ways: values are cached and read/ >> write instructions are reordered. >> >> But I can not understand what the I/O operations's side effect is. >> Could anyone give me some tips. > >I think the text you quoted may not reflect what the author intended. I >think he is hinting at the classic "volatile" issue that was discussed a few >days ago here and elsewhere.
Especially when using peripherals originally intended for separate I/O space is used in a memory mapped I/O system, you may have completely different actions for read and write. For example writing to memory location 100 would send a new character out from the UART, while reading location 100 will return the character received from the UART in a full duplex protocol. Reading location 101 could return the status register, while writing to location 101 will update the control register .e.g. set the number of bits etc. You can not optimize away a read after write in such situations. Paul