Revision 1217

branches/threaded2merge/src/linad99/thread_stuff.cpp (revision 1217)
14 14

  
15 15
//const int NSLAVES=1;
16 16

  
17
typedef char* pchar;
18
typedef pchar*  ppchar;
19
typedef ofstream* pofstream;
20
__thread int adpthread_manager::slave_number;
17
typedef char * pchar;
18
typedef pchar *  ppchar;
19
typedef ofstream * pofstream;
20
__ADMBTHREAD__ int adpthread_manager::slave_number;
21 21

  
22 22
int adpthread_manager::old_buffer_flag=0;
23 23

  
......
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 345
    sbuffend[s1][s2]=stransfer_buffer[s1][s2]+bs-1;
346 346
    cout << "Initialized transfer buffer for pair " 
347 347
         << s1 << "  " << s2 << endl;
......
832 832
  }
833 833
}
834 834

  
835
//void adpthread_manager::create_all(void* (*f)(void*),new_thread_data * ptr)
836
void adpthread_manager::create_all(pthreadfun pf,new_thread_data * ptr)
835

  
836
void adpthread_manager::create_all(pthreadfun pf ,new_thread_data * ptr)
837 837
{
838 838
  for (int i=1;i<=nslaves;i++)
839 839
  {
......
841 841
  }
842 842
}
843 843

  
844
//void adpthread_manager::create_all(void* (*f)(void*),thread_data* ptr)
845
void adpthread_manager::create_all(pthreadfun pf,thread_data* ptr)
844
void adpthread_manager::create_all(pthreadfun pf ,thread_data * ptr)
846 845
{
847 846
  for (int i=1;i<=nslaves;i++)
848 847
  {
......
850 849
  }
851 850
}
852 851

  
853
void adpthread_manager::create_all(void* ptr)
852
void adpthread_manager::create_all(void * ptr)
854 853
{
854
  pthread_attr_t policy_attr;
855
  pthread_attr_init(&policy_attr);
856
  #undef USE_FIFO_POLICY
857
  #ifdef USE_FIFO_POLICY
858
  int old_policy;
859
  //int pthread_attr_getschedpolicy(pthread_attr_t *attr, int *policy);
860
  pthread_attr_getschedpolicy(&policy_attr, &old_policy);
861
  cerr << "In adpthread_manager::create_all, old_policty = " << old_policy << endl;
862

  
863
  // int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy);
864
  pthread_attr_setschedpolicy(&policy_attr, SCHED_FIFO);
865
  cerr << "In adpthread_manager::create_all, set policy to = " << SCHED_FIFO << endl;
866
  #endif //USE_FIFO_POLICY
867
  
868
  //int pthread_attr_setinheritsched(pthread_attr_t *attr, int inheritsched);
869
  pthread_attr_setinheritsched(&policy_attr, PTHREAD_EXPLICIT_SCHED);
870

  
855 871
  new_thread_data * dptr = (new_thread_data *)ptr; 
856 872
  int ii=0;
857 873
  for (int i=1;i<=ngroups;i++)
......
866 882
    {
867 883
      cout << ppf[i] << endl;
868 884
      ++ii;
869
      pthread_create(thread1+ii,NULL,ppf[i],dptr+ii);
885
      //pthread_create(thread1+ii,NULL,ppf[i],dptr+ii);
886
      pthread_create(thread1+ii,&policy_attr,ppf[i],dptr+ii);
870 887
    }
871 888
  }
872 889
}
......
1065 1082
  readbuffer(&x,sizeof(double),sno);
1066 1083
  return x;
1067 1084
}
1085

  
1068 1086
double adpthread_manager::get_double(int sno)
1069 1087
{
1070 1088
  verify_id_string_from_master("TY",sno);
......
1776 1794
  writebuffer(&mmax,sizeof(int),sno);
1777 1795
  writebuffer(&(x(mmin)),sz*sizeof(int),sno);
1778 1796
}
1797

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff