Changeset 1710 in Sophya for trunk


Ignore:
Timestamp:
Oct 19, 2001, 2:20:38 PM (24 years ago)
Author:
aubourg
Message:

pb deadlock multiple fits readers

Location:
trunk/ArchTOIPipe
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ArchTOIPipe/Kernel/fitstoirdr.cc

    r1696 r1710  
    128128       << firstSn << endl;
    129129
    130   fits_lock();
    131130  for (int i=0; i<nrows; i++) {
    132131    int anyNul;
    133132    double y;
     133    fits_lock();
    134134    fits_read_col_dbl(fptr,1,i+1,1,1,0,&y,&anyNul,&fstatus);
    135     //fits_unlock();
     135    fits_unlock();
    136136    int sn = (int) (y+.1);
    137137    TOIManager* mgr = TOIManager::getManager();
     
    142142      int j = colsinput[k].first;
    143143      if ( !checkOutputTOIIndex(k) )  continue;  // Reza - Si TOI non connecte
    144       //      fits_lock();
     144      fits_lock();
    145145      fits_read_col_dbl(fptr,j+1,i+1,1,1,0,&y,&anyNul,&fstatus);
    146146      long flg = 0;
     
    148148        fits_read_col_lng(fptr,j+2,i+1,1,1,0,&flg,&anyNul,&fstatus);
    149149      }
    150       //      fits_unlock();
     150      fits_unlock();
    151151      putData(k, sn, y, flg);
    152152    }
    153     if (i%50==0)  {
     153/*    if (i%50==0)  {
    154154      fits_unlock();
    155155      sched_yield();
    156156      fits_lock();
    157     }
     157    }*/
    158158    totnscount++;
    159159  }
    160   fits_unlock();
     160  //fits_unlock();
    161161  cout << "reader done reading... " << pthread_self() << endl;
    162162}
  • trunk/ArchTOIPipe/Kernel/toisegment.cc

    r1709 r1710  
    1010static void cout_lock() {pthread_mutex_lock(&cout_mutex);}
    1111static void cout_unlock() {pthread_mutex_unlock(&cout_mutex);}
    12 #define LOG(_xxx_)
    13 /*
     12//#define LOG(_xxx_)
     13// /*
    1414#define LOG(_xxx_) \
    1515cout_lock(); \
    1616_xxx_; \
    1717cout_unlock();
    18 */
     18// */
    1919
    2020/******************************/
     
    2323
    2424TOISegmented::TOISegmented(int bufsz, int maxseg) {
    25   master = new MasterView(bufsz, maxseg);
     25  master = new MasterView(bufsz, maxseg, "");
    2626  setName("TOISegmented");
    2727}
    2828
    2929TOISegmented::TOISegmented(string nm, int bufsz, int maxseg) {
    30   master = new MasterView(bufsz, maxseg);
     30  master = new MasterView(bufsz, maxseg, nm);
    3131  setName(nm);
    3232}
     
    3434TOISegmented::TOISegmented(char* cnm, int bufsz, int maxseg) {
    3535  string nm = cnm;
    36   master = new MasterView(bufsz, maxseg);
     36  master = new MasterView(bufsz, maxseg, nm);
    3737  setName(nm);
    3838}
     
    217217  if (sn0 < 0 ||
    218218      sn >= sn0 + segmentSize*segments.size()) {
    219     LOG(cout << "BufferView " << hex << this << dec << ": read fault for " << sn << endl)
     219    LOG(cout << master->name << " BufferView "
     220        << hex << this << dec << ": read fault for " << sn << endl)
    220221    sync();
    221222    pthread_mutex_lock(&(master->read_wait_mutex));
     
    223224      wait(); // must be atomic with loop test
    224225      pthread_mutex_unlock(&(master->read_wait_mutex));
    225       LOG(cout << "BufferView " << hex << this << dec << ": waiting for " << sn << endl)
     226      LOG(cout << master->name << " BufferView " << hex << this << dec << ": waiting for " << sn << endl)
    226227      sync();
    227228      pthread_mutex_lock(&(master->read_wait_mutex));
     
    229230    pthread_mutex_unlock(&(master->read_wait_mutex));
    230231
    231     LOG(cout << "BufferView " << hex << this << dec << ": resuming for " << sn
     232    LOG(cout << master->name << " BufferView " << hex << this << dec << ": resuming for " << sn
    232233        << " now data for " << sn0 << " - " << sn0 + segmentSize*segments.size()
    233234        << " in " << segments.size() << " segments " << endl)
     
    259260/*******************************/
    260261
    261 TOISegmented::MasterView::MasterView(int bufsz, int maxseg) {
     262TOISegmented::MasterView::MasterView(int bufsz, int maxseg, string nm) {
    262263  currentSegment = NULL;
    263264  maxSegments    = maxseg;
     
    265266  sn0            = -1;
    266267  nConsumers = 0;
     268  name = nm;
    267269 
    268270  pthread_mutex_init(&views_mutex, NULL);
     
    296298        sn >= currentSegment->sn0 &&
    297299        sn < currentSegment->sn0 + currentSegment->bufferSize)) {
    298     LOG(cout << "MasterView::putData, need extend for " << sn << endl)
     300    LOG(cout << name << " MasterView::putData, need extend for " << sn << endl)
    299301    nextSegment();
    300302  }
     
    328330void TOISegmented::MasterView::signalWrite() { /* reader thread */ /* views locked */
    329331  if (waitingOnWrite) {
    330     LOG(cout << "MasterView : signal for wait on write" << endl)
     332    LOG(cout << name << " MasterView : signal for wait on write" << endl)
    331333    pthread_cond_signal(&write_wait_condv); // only one thread can be sleeping
    332334  }
     
    362364
    363365void TOISegmented::MasterView::waitForCleaning() { /* writer thread */ /* views locked */
    364   LOG(cout << "MasterView : write wait for clean for " << sn0 << endl)
     366  LOG(cout << name << " MasterView : write wait for clean for " << sn0 << endl)
    365367  waitingOnWrite = true;
    366368  checkDeadLock();
    367369  pthread_cond_wait(&write_wait_condv, &views_mutex);
    368   LOG(cout << "MasterView : wait done" << endl)
     370  LOG(cout << name << " MasterView : wait done" << endl)
    369371}
    370372
     
    403405    }
    404406   
    405     LOG(cout << "MasterView : firstNeeded = " << firstNeeded << endl);
     407    LOG(cout << name << " MasterView : firstNeeded = " << firstNeeded << endl);
    406408     
    407409    vector<BufferSegment*>::iterator j = segments.begin();
     
    447449  }
    448450
    449   LOG(cout << "sync for " << hex << bv << dec << " : "
     451  LOG(cout << name << " sync for " << hex << bv << dec << " : "
    450452      << oldBegin << " - " << oldEnd << "  -->  "
    451453      << bv->sn0 << " - " << newEnd << endl);
  • trunk/ArchTOIPipe/Kernel/toisegment.h

    r1699 r1710  
    101101  class MasterView {
    102102  public:
    103     MasterView(int bufsz=256, int maxseg=20);
     103    MasterView(int bufsz=256, int maxseg=20, string nm="");
    104104    ~MasterView();
    105105
     
    114114    friend class BufferView;
    115115    friend class TOISegmented;
     116    string name;
    116117    void signalWaitingViews(); // views are waiting on read
    117118    void signalWrite();        // we are waiting on write
  • trunk/ArchTOIPipe/TestPipes/tstseg3.cc

    r1698 r1710  
    44#include "fitstoirdr.h"
    55#include "fitstoiwtr.h"
     6#include "asciitoiwtr.h"
    67#include "toisqfilter.h"
    78#include "toimanager.h"
     
    1617
    1718  FITSTOIWriter w1("out1.fits");
    18   FITSTOIWriter w2("out2.fits");
     19//  FITSTOIWriter w2("out2.fits");
     20 // ASCIITOIWriter w1("out1.data");
     21 // ASCIITOIWriter w2("out2.data");
    1922
    2023 
     
    2831  w1.addInput("143K02", toi2);
    2932
    30   w2.addInput("143K01", toi1);
    31   w2.addInput("143K02", toi2);
     33 // w2.addInput("143K01", toi1);
     34 // w2.addInput("143K02", toi2);
    3235 
    3336  cout << "starting" << endl;
     
    3639  r2.start();
    3740  w1.start();
    38   w2.start();
     41  //w2.start();
    3942
    4043  cout << "joining" << endl;
  • trunk/ArchTOIPipe/fan_copy

    r1692 r1710  
    66  foreach f (`cat files_$d`)
    77   echo $f
    8    cp -p $f $d/$f
     8   rm -f $d/$f
     9   ln -s ../$f $d/$f
     10   #cp -p $f $d/$f
    911  end
    10   cp -p Makefile.in_$d $d/Makefile.in
     12  rm -f $d/Makefile.in
     13  ln -s ../Makefile.in_$d $d/Makefile.in
     14  #cp -p Makefile.in_$d $d/Makefile.in
    1115end
Note: See TracChangeset for help on using the changeset viewer.