how to do i o in memory mapped i/o code example

Example 1: what do you mean by io address and memory address

Memory mapped I/O is a technique of performing I/O operations between the CPU and the I/O device. We can perform I/O simply by accessing bytes of memory and relying on the OS kernel to ensure that the changes to the memory are propagated to the mapped I/O device.

This technique can provide performance benefits like :

A normal read() or write() call involves two transfers. One between the I/O device and the kernel buffer cache, and the other between the buffer cache and a user-space buffer. Memory mapping eliminates the second of these transfers.
Memory mapping can also improve performance by lowering memory requirements. It uses one less buffer to store the data i.e. a single buffer is shared between the kernel space and user space.

Example 2: what do you mean by io address and memory address

Memory mapped IO is one where the processor and the IO device share the same memory location(memory),i.e.,the processor and IO devices are mapped using the memory address