943,603 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 1643
  • C++ RSS
Aug 25th, 2008
0

Shared Memory Object Access

Expand 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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vadan is offline Offline
16 posts
since Jul 2008
Aug 25th, 2008
0

Re: Shared Memory Object Access

This is a problem aout "Communication among process". You can solve it by using "singal, mutex,memory share ect"
Reputation Points: 10
Solved Threads: 1
Newbie Poster
idofindit is offline Offline
4 posts
since Jul 2008
Aug 25th, 2008
0

Re: Shared Memory Object Access

Click to Expand / Collapse  Quote originally posted by vadan ...
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.
kux
Reputation Points: 66
Solved Threads: 11
Junior Poster
kux is offline Offline
119 posts
since Jan 2008
Aug 25th, 2008
0

Re: Shared Memory Object Access

thanks for the replies

i want to know how to check whether an object is being locked by a process or not
Reputation Points: 10
Solved Threads: 0
Newbie Poster
vadan is offline Offline
16 posts
since Jul 2008
Aug 26th, 2008
0

Re: Shared Memory Object Access

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.
Reputation Points: 69
Solved Threads: 28
Posting Whiz
Clockowl is offline Offline
376 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: COM port emulator
Next Thread in C++ Forum Timeline: Heap Corruption??!! Help!!!





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC