Shared memory

I have two application running on my embedded Linux system and I need to communicate between the two. I have done this very successfully in Windows by shared memory and I wonder if this is possible in Linux too.

Shared memory is handy here because one appliacation will be setting flags and values the other one can read at its convenience and vice versa.

Thanks,

Jens.

Reply to
Jens
Loading thread data ...

Absolutely.

Reply to
Ari Rankum

Search for "sys/shm.h" in google. You will find tutorials about it on the first 2 pages.

Here is a code from me:

There is a code example at the end.

Greetings

Ernst

// 0xFFFF bytes empfangsbuffer: #define SHM_BUFFSIZE 0xFFFF im_shm_requestid = shmget(im_ID_Readkey,SHM_BUFFSIZE,S_IRWXU | S_IRWXG | S_IRWXO); if (im_shm_requestid == -1) im_shm_requestid = shmget(im_ID_Readkey,SHM_BUFFSIZE,S_IRWXU | S_IRWXG | S_IRWXO | IPC_CREAT /*| IPC_EXCL*/); if (im_shm_requestid == -1) { SetError(fErrBus_open); return false; } // empfangsbuffer anbinden: pm_ReceiveBuffer = (SendReceiveBuffer *) shmat(im_shm_requestid,0,0); if (pm_ReceiveBuffer

Reply to
Ernst Murnleitner

Remember that there are two ways doing shared memory in Linux. You can do the System V style or the POSIX way.

Reply to
Harold Chu

Reply to
jianjia

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.