Boost logo

Boost Users :

From: C. Michailidis (dinom_at_[hidden])
Date: 2005-04-14 01:25:52


> 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 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