Revision 1227

branches/threaded2merge/src/GNUmakefile (revision 1227)
51 51
CXXFLAGS_PRE:=$(CXXFLAGS_PRE) -Wall
52 52
endif
53 53

  
54
CXXFLAGS_PRE:=$(CXXFLAGS_PRE) -fpermissive
54
CXXFLAGS_PRE:=$(CXXFLAGS_PRE)
55 55

  
56 56
CXXFLAGS_DEFINES:=-D__GNUDOS__ -Dlinux -D__SPDLL__ -DUSE_LAPLACE
57 57

  
branches/threaded2merge/src/linad99/thread_stuff.cpp (revision 1227)
340 340
{
341 341
  if (stransfer_buffer[s1][s2]== 0)
342 342
  {
343
    transfer_buffer[s1][s2]=new char[bs];
344
    scurrent_bptr[s1][s2]=transfer_buffer[s1][s2];
343
    //transfer_buffer[s1][s2]=new char[bs];
344
    //scurrent_bptr[s1][s2]=transfer_buffer[s1][s2];
345
    stransfer_buffer[s1][s2]=new char[bs];
346
    scurrent_bptr[s1][s2]=stransfer_buffer[s1][s2];
345 347
    sbuffend[s1][s2]=stransfer_buffer[s1][s2]+bs-1;
346 348
    cout << "Initialized transfer buffer for pair " 
347 349
         << s1 << "  " << s2 << endl;
branches/threaded2merge/tests/threads/msimple/tests_adthread_manager.cpp (revision 1227)
137 137
  delete ad_comm::pthread_manager;
138 138
  ad_comm::pthread_manager = 0;
139 139
}
140
static int lflag = 0;
141
pthread_mutex_t lflag_mutex = PTHREAD_MUTEX_INITIALIZER;
142
void* test_read_lock_buffer(void* ptr)
143
{
144
  //ad_comm::pthread_manager->write_lock_buffer(0);
145
  //ad_comm::pthread_manager->write_unlock_buffer(0);
146
  pthread_mutex_lock(&lflag_mutex);
147
  lflag++;
148
  pthread_mutex_unlock(&lflag_mutex);
149
  return ptr;
150
}
151
TEST_F(tests_adthread_manager, read_lock_buffer)
152
{
153
  const int nthread = 5;
154
  const int ngroups = 1;
155
  ivector ng(1, ngroups);
156
  // number of threads in group 1
157
  ng(1)=nthread;
158
  // create instance of pthread_manager class 
159
  // third argument is number of bytes in the transfer buffer
160
  ad_comm::pthread_manager = new adpthread_manager(ngroups, ng, 32005);
161
  if (ad_comm::pthread_manager == 0)
162
  {
163
    FAIL();
164
  }
165

  
166
  ad_comm::pthread_manager->attach_code(test_read_lock_buffer);
167

  
168
  new_thread_data data[nthread + 1];
169
  for (int i = 0; i <= nthread; i++)
170
  {
171
    data[i].thread_no = i;
172
  }
173

  
174
/*
175
  for (int i = 1; i <= nthread; i++)
176
  {
177
    ad_comm::pthread_manager->write_lock_buffer(i);
178
    ad_comm::pthread_manager->send_int(1, i);
179
    ad_comm::pthread_manager->write_unlock_buffer(i);
180
  }
181
*/
182

  
183
  ASSERT_EQ(0, lflag);
184
  //This starts thread after a unknown delay
185
  ad_comm::pthread_manager->create_all(&data);
186
  //Need to join it
187
  ad_comm::pthread_manager->pthread_join_all();
188
  ASSERT_EQ(5, lflag);
189

  
190
  delete ad_comm::pthread_manager;
191
  ad_comm::pthread_manager = 0;
192
}

Also available in: Unified diff