I would like to add a small enhancement to the OS, and need to store 4 bytes-Where?
Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I would like to add a small enhancement to the OS, and need to store 4 bytes-Where?
Hi,
As in the subject line, is there at least 4 bytes of low storage available which I could update continuously, (like in a high-priority background program) and this would then be available to any program running.
Does anyone know where this data would best be stored? I was hoping there is already some such area just for developers to use. But I'm pretty new to linux... is there a memory map of the kernel which I should look at?
Anything you can suggest will be greatly appreciated.
an environment variable could be a good solution.
otherwise, open a terminal and type "mount" - chances are you already have a RAM partition:
Code:
run on /run type tmpfs (rw,nosuid,nodev,relatime,mode=755)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /tmp type tmpfs (rw)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=740668k,mode=700,uid=1000,gid=100)
Thanks to all of you for your helpful suggestions!! I'm pretty sure a RAM disk is not what I'd be lloking for, but the Environment Variable may work well. It would be 4-bytes of binary data Similar in nature to when programs refer to the Real Time Clock now.
I was envisioning some 4-bytes of low storage or CMOS storage which is currently unused (or at least not used for anything important)
(like the High Memorty address--ha).
hello ondoho
Ref Environment variable and storage please read http://www.linuxnix.com/2012/05/conv...linuxunix.html
or Google ""linux shell hex to binary"", there are many ways to solve a problem in Linux using shell!
I believe you can put what you like in a variable 16 32 and 65 bit.
Trev
Last edited by trevoratxtal; 06-08-2015 at 11:29 AM.
Reason: spelling
@trevoratxtal, thanks for that link. however, i think "binary" in that article means an actual string of 1's and 0's, but i think op meant actual binary data, as in "a pile of bits, clustered into bytes".
i recently had a similar problem...
as an illustration, try
Code:
cat /dev/urandom
(that's my definition of binary data)
but you got me thinking, and i think there's a utility that will convert that to something bash can use.
Code:
cat /dev/urandom | base64 -i -w 0
maybe...
i'm not saying i'm right or you're wrong, just thinking out...
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680
Rep:
It this fixed or variable data? You could name your kernel in hex and use uname to reach it...
I'll admit to being well out of my depth code wise but how about creating a device node? If it's fFast enough for device access. Oh, sorry, I see that suggested above, I think.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.