LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   Total amount of allocated SHM memory? (http://www.linuxquestions.org/questions/programming-9/total-amount-of-allocated-shm-memory-828515/)

kresyzig 08-25-2010 11:50 PM

Total amount of allocated SHM memory?
 
Is there an easy way in C to get the total amount of allocated SHM memory on a machine?

Kenny_Strawn 08-26-2010 04:57 PM

It would probably be C's equivalent to the following shell command:

Code:

cat /dev/shm

Sergei Steshenko 08-26-2010 06:03 PM

Quote:

Originally Posted by Kenny_Strawn (Post 4078855)
It would probably be C's equivalent to the following shell command:

Code:

cat /dev/shm

?????

Code:

file /dev/shm
/dev/shm: sticky directory


Sergei Steshenko 08-26-2010 06:11 PM

man 2 shmctl

kresyzig 08-27-2010 08:05 AM

Quote:

Originally Posted by Sergei Steshenko (Post 4078909)
man 2 shmctl

This is what I was looking for. Thanks!

kresyzig 08-27-2010 06:33 PM

Quote:

Originally Posted by Sergei Steshenko (Post 4078909)
man 2 shmctl

Sorry this does not work. shmctl recognizes only System V shared memory and I am working with POSIX shm... Is there anything equivalent for POSIX shm?

Sergei Steshenko 08-27-2010 07:02 PM

Quote:

Originally Posted by kresyzig (Post 4080092)
Sorry this does not work. shmctl recognizes only System V shared memory and I am working with POSIX shm... Is there anything equivalent for POSIX shm?

Maybe
http://www.cs.cf.ac.uk/Dave/C/node27...00000000000000 .

kresyzig 08-28-2010 03:34 AM

Quote:

Originally Posted by Sergei Steshenko (Post 4080114)

Finally I have used opendir("/dev/shm") combined with readdir_r to get the size of the pseudo-files in /dev/shm/ /. This is the only way I have found to compute the total amount of shared memory. That works fine, I just don't know if there is a more optimal method...


All times are GMT -5. The time now is 08:54 AM.