I know that long time ago computer scientists decided to treat all pointers to memory cell of address 0 as NULL.
Sort of, and practically speaking, yes. However, going back to the C language, in the days of yore, the literal number 0
is taken to mean the null
value in a pointer context. Yet the standard does not require that null
has a bit pattern value of all zeros. It could, for example, as an implementation choice, be -1 instead (the bit pattern of all ones). However, over the years, implementers have settled on the bit pattern of all zeroes to mean null
.
However, the memory cell at that address does exists after all, right? In that case, what value is stored there? Since it's OS that decides how to allocate memory it should be able to access (and modify) value of all cells in the RAM, including the one of index 0, right?
You would have to decide what context your asking about: directly on the processor, or in a process on an operating system.
On an embedded controller/processor, you might not have an operating system with virtual memory. And further, it is common for microprocessors to not only have memory at zero (and/or in highmem) that relates to I/O devices, or is otherwise special rather than being true memory, though true memory is also commonly found at address zero. So in this environment, zero exists as an address, and may or may not be special to the processor in some way.
For a process running within an operating system that offers virtual memory, modern operating systems will often choose to map a number of pages around zero effectively to undefined, so there simply isn't any actual memory at address zero. A request to access memory at zero will result in a fault (such as a segmentation fault).
On the other hand, some operating systems will provide readonly pages of zeros and allow reads to or around zero, while only faulting on writes to zero.