Given that this code makes no use of "volatile" when reading and writing from mapped memory it's behavior is undefined as per the C standard. As such it is only a matter of luck that it works at all!