@@ -389,6 +389,7 @@ const char* ERR_BAM_SORT="\nError: the input alignment file is not sorted!\n";
389389if (ballgown)
390390 Ballgown_setupFiles (f_tdata, f_edata, f_idata, f_e2t, f_i2t);
391391#ifndef NOTHREADS
392+ // model: one producer, multiple consumers
392393#define DEF_TSTACK_SIZE 8388608
393394 int tstackSize=GThread::defaultStackSize ();
394395 size_t defStackSize=0 ;
@@ -403,6 +404,8 @@ if (tstackSize<DEF_TSTACK_SIZE) defStackSize=DEF_TSTACK_SIZE;
403404 GThread* threads=new GThread[num_cpus]; // bundle processing threads
404405
405406 GPVec<BundleData> bundleQueue (false ); // queue of loaded bundles
407+ // the consumers take (pop) bundles out of this queue for processing
408+ // the producer populates this queue with bundles, built from the BAM file
406409
407410 BundleData* bundles=new BundleData[num_cpus+1 ];
408411 // bundles[0..num_cpus-1] are processed by threads, loading bundles[num_cpus] first
@@ -527,7 +530,7 @@ if (tstackSize<DEF_TSTACK_SIZE) defStackSize=DEF_TSTACK_SIZE;
527530 // push this in the bundle queue where it'll be picked up by the threads
528531 DBGPRINT2 (" ##> Locking queueMutex to push loaded bundle into the queue (bundle.start=%d)\n " , bundle->start );
529532 int qCount=0 ;
530- queueMutex.lock ();
533+ queueMutex.lock (); // FIXME: possible point of contention here between multiple threads
531534 bundleQueue.Push (bundle);
532535 bundleWork |= 0x02 ; // set bit 1
533536 qCount=bundleQueue.Count ();
@@ -1309,7 +1312,8 @@ void workerThread(GThreadData& td) {
13091312 // wait for a ready bundle in the queue, until there is no hope for incoming bundles
13101313 DBGPRINT2 (" ---->> Thread%d starting..\n " ,td.thread ->get_id ());
13111314 DBGPRINT2 (" ---->> Thread%d locking queueMutex..\n " ,td.thread ->get_id ());
1312- queueMutex.lock (); // enter wait-for-notification loop
1315+ queueMutex.lock (); // FIXME: possible point of contention
1316+ // enter wait-for-notification loop
13131317 while (bundleWork) {
13141318 DBGPRINT3 (" ---->> Thread%d: waiting.. (queue len=%d)\n " ,td.thread ->get_id (), bundleQueue->Count ());
13151319 waitMutex.lock ();
0 commit comments