Shared Memory Object Access

Reply

Join Date: Jul 2008
Posts: 15
Reputation: vadan is an unknown quantity at this point 
Solved Threads: 0
vadan vadan is offline Offline
Newbie Poster

Shared Memory Object Access

 
0
  #1
Aug 25th, 2008
Hi

iam a newbie to C++
I have a problem, pls give me a solution

I have an object in the shared memory which encapsulates an array of 6 objects. I want to acess one of the objects in the array. If the first object in the array is already locked by a process, i want to get the second object and so on.

Please tell me how to do this and please let me know, how to check whether an object in the array is already locked by some process or it is free to access?

Thanks in Advance

Vadan
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 4
Reputation: idofindit is an unknown quantity at this point 
Solved Threads: 1
idofindit idofindit is offline Offline
Newbie Poster

Re: Shared Memory Object Access

 
0
  #2
Aug 25th, 2008
This is a problem aout "Communication among process". You can solve it by using "singal, mutex,memory share ect"
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 119
Reputation: kux is on a distinguished road 
Solved Threads: 10
kux kux is offline Offline
Junior Poster

Re: Shared Memory Object Access

 
0
  #3
Aug 25th, 2008
Originally Posted by vadan View Post
Hi

iam a newbie to C++
I have a problem, pls give me a solution

I have an object in the shared memory which encapsulates an array of 6 objects. I want to acess one of the objects in the array. If the first object in the array is already locked by a process, i want to get the second object and so on.

Please tell me how to do this and please let me know, how to check whether an object in the array is already locked by some process or it is free to access?

Thanks in Advance

Vadan
well, you could have another array of 6 bools that marks that the corresponding object in the info array is locked or not ( a flags array, or something ), only be very carefull about syncronization... the locking of an object from the array and setting the corresponding flag are 2 different operations... u must make them atomic!! if not, if a context switch is made between them and another process might then check the flags, it will find an object unlocked while it is actually locked but the flag is not properly set because of the context switch that happend between the locking of the object and the flag setting.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 15
Reputation: vadan is an unknown quantity at this point 
Solved Threads: 0
vadan vadan is offline Offline
Newbie Poster

Re: Shared Memory Object Access

 
0
  #4
Aug 25th, 2008
thanks for the replies

i want to know how to check whether an object is being locked by a process or not
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 371
Reputation: Clockowl is on a distinguished road 
Solved Threads: 27
Clockowl's Avatar
Clockowl Clockowl is offline Offline
Posting Whiz

Re: Shared Memory Object Access

 
0
  #5
Aug 26th, 2008
That depends on your OS in C++. C++ itself doesn't have functions for that. Maybe some library does have crossplatform functions for it. If you're on Windows, go to MSDN and lookup the threading functions there.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC