Apes, dolphins and elephants are animals with remarkable communication skills. Could the Internet be expanded to include sentient species like them? A new and developing idea from a panel of four great thinkers — dolphin researcher Diana Reiss, musician Peter Gabriel, internet of things visionary Neil Gershenfeld and Vint Cerf, one of the fathers of the Internet.
Vlad Lazarenko, Ranting @ 741 MHZ, How Constant is Constant, here.
Hopefully, the code is self-explanatory. But if in doubt — read a manual page about
mprotectsystem call. I have touched on memory protection in the beginning and how operating system is using it to make string literals constant. The above example uses the reverse approach and makes the memory writable again (just like a time machine taking the program to old good DOS times). The thing is, our commodity computers work with only two kinds of memory — SRAM memory of CPU caches, which is fast and expensive, and a DRAM, which is slow but very cheap (I have recently got 16 GB for my Mac Mini for only $100). Neither of those two kinds of memory is read-only. Some of the processors have neither memory protection nor memory management units, and it won’t even be possible to write-protect the memory to make it “look” constant (which can also be unprotected as well, as we have just witnessed). Therefore, there are no constants from the hardware point of view.