Boost logo

Boost :

From: Tim Laplaca (tlaplaca_at_[hidden])
Date: 2004-11-24 09:21:07


I switched the parameter-passing to the bind method, e.g.
thrds.create_thread( boost::bind( updatethread, threadid, "123456789" )
);

with no difference.

I did find that the same code that "aborts" under Linux seems to run ok
under Windows.

-----Original Message-----
From: boost-bounces_at_[hidden]
[mailto:boost-bounces_at_[hidden]] On Behalf Of Tim Laplaca
Sent: Tuesday, November 23, 2004 3:32 PM
To: boost_at_[hidden]
Subject: [boost] Thread: Why is my prog aborting after 283 or so
threads?

I wrote a prog that spawns threads (RED HAT Fedora Core 2), and after
spawning 283 or so threads, it stops running and 'Aborted' is printed.

It doesn't matter if I spawn them one after each other, or only 10 at a
time, or if the threads only last 1 second or if they all stick around
until the 283rd thread is spawned. Every combination I've tried results
in the prog aborting at about the 283rd thread spawn.

Does this sound familiar to anybody?

Is there something my thread must do to properly shut itself down? Does
it need to call some kind of procedure to announce it is going away for
proper cleanup? I couldn't see anything in the examples like that.

And is there documentation explaining the examples? I failed to find
any.

My thread procedure:

void updatethread(void* inparams)
{

        thread_params *tparam;
        tparam=(thread_params *)inparams;
        
        int local_threadid = tparam->param1;
        std::string DID = tparam->param2;
        
        
        {
        boost::mutex::scoped_lock scoped_lock(io_mutex);
        std::cout << " Thread:" << local_threadid << " running. "
                     "UPDATE for " << DID << std::endl;
        }

        
        // wait some secs (just for debug, remove when real work is
being done)
          boost::xtime xt;
        boost::xtime_get(&xt, boost::TIME_UTC);
      xt.sec += 2;
        boost::thread::sleep(xt);

        
        
        {
        boost::mutex::scoped_lock scoped_lock(io_mutex);
        std::cout << " Thread:" << local_threadid << " Exiting. " <<
std::endl;
        }

        
        {
        boost::mutex::scoped_lock scoped_lock(numthreads_mutex);
        --activethreads;
        }
        
}

MAIN calls it with this:

//spawn thread
tparam.param1=threadid;
tparam.param2=dids[i];
boost::thread *pt;
pt = thrds.create_thread(thread_adapter(&updatethread, (void*)&tparam));

Thanks,
Tim

_______________________________________________
Unsubscribe & other changes:
http://lists.boost.org/mailman/listinfo.cgi/boost


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk