See to understand the program first u need to have an idea of shared memory. Shared memory comes under Inter-Process Communication. Shared memory is the fastest of all IPC. Shared memory comes under System V IPC. SHARED MEMORY: Shared memory is one of the three System V IPC. It allows two unrelated processes to access the same logical memory. Shared memory is a very efficient way of transferring data between two running processes. In the program i have used these functions. shmget and shmat for shared memory. shmget is used to create shared memory. shmat is used to attach the shared memory to the address space of the process. When we come to the program,i have created two process i.e process-1 and process-2. process-1 and process-2 uses same memory i.e shared memory. I have created a single bit shared memory to control the two process not to access the shared memory at a time. When process-1 uses the shared memory then process-2 waits until process-1 completes its work and wise versa . Run the two process at a time (i.e in two terminals ) and u will observe that When process-1 uses the shared memory then process-2 waits until process-1 completes its work and wise versa .
Leave it bashamsc !!! your effort is really apprecited. Now please dont make issue more. That article should be nominated!!! Finallllll
when we pass object as argument to a function, then whether constructor or destructor are called or not.
Hi @all, ok this thread is a bit old already.... but I'm working on quite the same issue now so I thought I refresh this instead of starting a new... 1st: Big thanks to bashamsc for this great code!! Now what I am trying to do for a while now.... ( without any success until now ) is to access this SHM with PHP. So I have a shared-memory created with C++ and I want to read and change the data inside with PHP and read with C++ again and so on...... U know what I mean? I know a bit difficult to explain.... Allright, I know how to create a shm with php and write data inside..... but how the h*** can I access this C++ created shm?? Appreciate every help or suggestion. Thanks in advance & regards from Germany