-
December 8th, 2012, 06:37 AM
#1
Conflict in VC++ Pragma Area?
I have a DLL which is written in Visual C++ 6.0. It is called from a program written in Visual Basic 6.0 (yes, I know, it is obsolete now but changing up will be a big task - maybe later!)
I may well have several copies running at the same time and in order for the copies to talk to each other (eg "I am copy 3 and you are copy 5") I use the Pragma area. This has been working pretty well but occasionally when running multiple copies one of them will crash, especially when the multiple copies are being generated (the program will say eg "you have a six core processor, do you want to run six copies?" and then generate five more copies of itself - it is looking for solutions to a big problem and may run for several days so six copies running will find a solution six times quicker generally speaking)
It crosses my mind that this could be because of conflict in reading and writing to from the Pragma Area. So, my question is:
"Is the Pragma Area automatically locked to prevent conflict or is this something I will have to do myself?"
All help and suggestions appreciated!
Bob
.
-
December 9th, 2012, 03:58 AM
#2
Re: Conflict in VC++ Pragma Area?
Originally Posted by wavering
(the program will say eg "you have a six core processor, do you want to run six copies?" and then generate five more copies of itself - it is looking for solutions to a big problem and may run for several days so six copies running will find a solution six times quicker generally speaking)
Why not just create multiple threads?
Cheers, D Drmmr
Please put [code][/code] tags around your code to preserve indentation and make it more readable.
As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky
-
December 9th, 2012, 07:59 AM
#3
Re: Conflict in VC++ Pragma Area?
Originally Posted by D_Drmmr
Why not just create multiple threads?
Well, I guess that may have been a route (although it appears that VB6 is not really set up for multithreading). Anyway, I am far too far along the route to change now. My program is basically in its final form after a very long time in gestation so it comes back to solving my specific question viz
"Is the Pragma Area automatically locked to prevent conflict or is this something I will have to do myself?"
-
December 9th, 2012, 10:20 AM
#4
Re: Conflict in VC++ Pragma Area?
Do you mean #pragma data_seg - http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx ? This data is not synchronized automatically, you need to to this in your own code. You can use the named mutex for synchronization.
-
December 9th, 2012, 05:41 PM
#5
Re: Conflict in VC++ Pragma Area?
Originally Posted by Alex F
Alex
Many thanks - that is what I feared!
Bob
.
-
December 10th, 2012, 07:53 AM
#6
Re: Conflict in VC++ Pragma Area?
And this is why multithreading would be better than trying to synchronise several instances of an application over the same data.
Accessing the data will be slower if it's across instances
named mutexes and semaphores are your only synchronisation available. These are considerably slower than (slow to fast) unnamed mutexes, events or critical sections. The difference is significant.
The OS itself will be having more overhead to keep X applications running vs the same amount of threads in a single application. Additionally you'll be forcing stuff out of the L1 and L2 caches faster by having multiple instances vs multithreads.
Sometimes multithreading isn't an option (especially in the case of old programs) however.
Ideally you want to solve your problem without having any form of shared data or synchronization needs. For some problems that's easy, for others that's hard or impossible.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|