LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 05-28-2015, 12:24 PM   #1
DavidKimbl
LQ Newbie
 
Registered: Apr 2015
Posts: 6

Rep: Reputation: Disabled
Question 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.

David K
 
Old 05-29-2015, 12:11 AM   #2
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
You can make a ramdisk for that storage.
 
Old 05-29-2015, 02:51 AM   #3
trevoratxtal
Member
 
Registered: Dec 2012
Location: South Devon, UK
Distribution: PCLinuxOS, Suse, Mint, Puppy.
Posts: 79

Rep: Reputation: 20
System variable

this may help

https://wiki.archlinux.org/index.php...ment_variables

Trev
 
1 members found this post helpful.
Old 05-30-2015, 06:45 AM   #4
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
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)
typically you would use /tmp or /dev/shm.

of what nature is this 4 byte data?
 
Old 05-30-2015, 08:24 AM   #5
veerain
Senior Member
 
Registered: Mar 2005
Location: Earth bound to Helios
Distribution: Custom
Posts: 2,524

Rep: Reputation: 319Reputation: 319Reputation: 319Reputation: 319
Quote:
Originally Posted by ondoho View Post
an environment variable could be a good solution.
otherwise, open a terminal and type "mount" - chances are you already have a RAM partition:

typically you would use /tmp or /dev/shm.
tmpfs is not ram partition/block. It is a ram based filesystem. Also data on it it can be swapped to swap space.
 
Old 06-01-2015, 07:54 AM   #6
DavidKimbl
LQ Newbie
 
Registered: Apr 2015
Posts: 6

Original Poster
Rep: Reputation: Disabled
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).

David --- Long Live Linux
 
Old 06-08-2015, 09:56 AM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by DavidKimbl View Post
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'm not sure if you can assign binary data to an environment variable?
Quote:
I was envisioning some 4-bytes of low storage or CMOS storage which is currently unused
wow, that's pretty close to the hardware.
i have no idea how something like that could even be done in linux. sounds more like bios stuff to me.
 
Old 06-08-2015, 11:29 AM   #8
trevoratxtal
Member
 
Registered: Dec 2012
Location: South Devon, UK
Distribution: PCLinuxOS, Suse, Mint, Puppy.
Posts: 79

Rep: Reputation: 20
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
 
Old 06-08-2015, 12:43 PM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
@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...

in the end it depends on the nature of op's data.
 
Old 06-08-2015, 12:56 PM   #10
273
LQ Addict
 
Registered: Dec 2011
Location: UK
Distribution: Debian Sid AMD64, Raspbian Wheezy, various VMs
Posts: 7,680

Rep: Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373Reputation: 2373
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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting error gfs_mkfs: subdevice 0 is way too small (0 bytes) sam_deshp Linux - Server 1 07-11-2014 08:02 AM
can i add my own field(of 2 bytes) in the ip header structure raklo Linux - Networking 5 08-18-2011 02:17 PM
enhancement of echo gr8linux Linux - Newbie 1 06-16-2009 01:22 AM
small-endian to big-endian conversion of data to store in a structure NancyT Programming 2 11-26-2008 10:06 AM
How to add some bytes to a binary file? kornerr Linux - General 6 02-28-2006 11:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 07:15 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration