Boost logo

Boost Users :

From: Cory Nelson (phrosty_at_[hidden])
Date: 2005-04-14 07:03:35


so long as you wrap your vector accesses with mutexes, it should be fine.

On 4/14/05, Sliwa, Przemyslaw (London) <Przemyslaw_Sliwa_at_[hidden]> wrote:
> It seems the usage of the vector cases problems with the multithreaded programs on the multiprocessor machines.
> I have changed it to queue and the bug has been resolved. I cannot reproduce it now.
>
> Thanks for help,
>
> Pshemek
>
> -----Original Message-----
> From: boost-users-bounces_at_[hidden] [mailto:boost-users-bounces_at_[hidden]] On Behalf Of C. Michailidis
> Sent: 14 April 2005 07:26
> To: boost-users_at_[hidden]
> Subject: [Boost-users] RE: Boost thread problem
>
> > All,
> >
> > I have got a problem with the boost::thread package.
> > My idea was to facilitate the multiprocessor ability of my computer and
> > write a program which creates 10 threads which firstly write to the disk
> > certain amount of information and then they read it back and push back
> > certain objects. I am getting some memory access problems when pushing
> > back the objects to the global vector. Can anyone of you understand why
> > there is a problem? I really do not get it since the mutex is locked and
> > the access to the vector is exclusively guaranteed to the active thread.
> >
> >
> > Can you help?
>
> I tried your code on my system and it seems to work as expected. No
> exceptions were thrown, there was a file called 'file.txt' in the pwd, and
> TradeVector.size was 80000 after the run. Of course I needed to remove the
> include of proprietary code - it was replaced with a dummy/stub class like
> this one:
>
> class CFXTrade {
> public:
> CFXTrade() {
> };
> CFXTrade( int id, string name, double amt ) {
> m_TradeID = id;
> m_Name = name;
> m_Amount = amt;
> };
>
> int m_TradeID;
> string m_Name;
> double m_Amount;
> };
>
> My system looks like this:
>
> FreeBSD medea.digitalescorts.net 5.4-PRERELEASE FreeBSD 5.4-PRERELEASE #0: Thu
> Mar 31 02:47:38 EST 2005
> root_at_[hidden]:/usr/obj/usr/src/sys/MEDEA i386
>
> and I have boost-1.32.0_2 libraries installed. I built the program from the
> command-line using the following command:
>
> "gcc hello.cpp -ggdb -I/usr/local/include -L/usr/local/lib -lboost_thread
> -lc_r"
>
> The problem may be platform specific. Are you linking against a thread-safe
> CRT? Can you provide details regarding your operating system? Which version
> of the boost library do you have installed?
>
> My suspicion is that you may not be using a thread-safe CRT. Of course the
> boost_thread library may be broken for your specific platform (but I doubt
> it).
>
> Sincerely,
> Constantino Michailidis
> Balston Research LLC
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
> --------------------------------------------------------
>
> If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/
> --------------------------------------------------------
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>

-- 
Cory Nelson
http://www.int64.org

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net