user3567603
user3567603

Reputation:

Shared memory or named pipes in ram?

I want to communicate between two different programs. A modded ambilight program which outputs led information and my own program that reads this information.

I read about named pipes and shared memory. But for me it is not clear where the data is stored. Due to the fact that i will exchange a lot of data i do not want to write this data to disk every time. I am using a raspberry Pi and the sd card should last for some more time ;)

So the basic question is: with what methode can i exchange information to the other end without writing to the disk? I am not sure if shared memory is written to ram, i want to make this clear. As another idea i read about is /dev/shm which should be a ram disk. Can i also use named pipes for this location and will the information than be saved in ram?

whats the best way to go? thanks :)

Upvotes: 5

Views: 4019

Answers (2)

I read about named pipes and shared memory. But for me it is not clear where the data is stored.

In both cases, data is stored in memory (named pipes look like they reside on filesystem, but actual data is stored on memory).

What method is better, it depends on actual application. Pipes have fairly limited buffer (most likely 64kb) and writing to it will block when buffer is full. Shared memory can be arbitrarily large, but on the downside, shared memory is, well, just like that - plain memory. You have to take care about synchronization etc yourself.

Upvotes: 7

Emilien
Emilien

Reputation: 2445

Shared memory and named pipes (and unix domain sockets) IPC won't write to your sdcard unless you allocate more memory than the available physical RAM which is either 256MB or 512MB depending on your raspberrypi model. If you do so it will start swapping and will probably slow down.

Upvotes: 4

Related Questions