Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C++ (http://www.go4expert.com/articles/cpp-tutorials/)
-   -   Program for shared memory in c++ (http://www.go4expert.com/articles/program-shared-memory-cpp-t8461/)

shabbir 13Feb2008 17:14

Re: Program for shared memory in c++
 
Quote:

Originally Posted by imrantechi
i have gone through the link and found that the program is your 's
i regret for the issue

Even I did the same and so we would like to make sure we conclude that its an original contribution.

bashamsc 13Feb2008 19:26

Re: Program for shared memory in c++
 
Quote:

Originally Posted by imrantechi
i m not so well versed with linux, so can you provide a little more explanation ,

so that even people like us also can understand.

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 .

imrantechi 13Feb2008 19:31

Re: Program for shared memory in c++
 
Okay!!! Thanks man...

debleena_doll2002 13Feb2008 19:40

Re: Program for shared memory in c++
 
Leave it bashamsc !!! your effort is really apprecited. Now please dont make issue more. That article should be nominated!!! Finallllll

shabbir 19Feb2008 12:45

Re: Program for shared memory in c++
 
Voting for article of the month for January 2008

lead.smart34 26Feb2008 18:21

Re: Program for shared memory in c++
 
its complex

crazytolearn57 26Feb2008 18:36

Re: Program for shared memory in c++
 
what is this problem of copy

rlearntowin1 27Feb2008 09:26

Re: Program for shared memory in c++
 
good one

bashamsc 27Feb2008 16:30

Re: Program for shared memory in c++
 
see this blog www.sharedmemoryprogram.blogspot.com

shabbir 28Feb2008 17:32

Re: Program for shared memory in c++
 
Winner of the month for January 2008


All times are GMT +5.5. The time now is 02:59.