Revision 1228 branches/threaded2merge/src/linad99/ythread_stuff.cpp

ythread_stuff.cpp (revision 1228)
1

  
2 1
#include <admodel.h>
3 2
#include <cstddef>
4 3
#include "adthread.h"
......
8 7
#  endif
9 8
#endif
10 9

  
11
/* prototype for thread routine */
12
void admb_thread(void * ptr);
13

  
14
//pthread_mutex_t mutex_print;
15

  
16
//const int NSLAVES=1;
17

  
18
typedef char * pchar;
19
typedef ofstream * pofstream;
20

  
21 10
void adjoint_adread_lock_buffer_1(void);
22 11
void adjoint_adread_lock_buffer_2(void);
23 12

  
......
29 18
    adt[0].get_elapsed_time_and_reset();
30 19
  }
31 20
  int tn2=ad_comm::pthread_manager->get_slave_number();
32
  int s1,s2;
33 21
  if (tn2==sno)
34 22
  {
35 23
   // cerr << "Error -- process can not write to itself" << endl;
......
37 25
  }
38 26
  else if (tn2<sno)  // old master read from
39 27
  {
40
    s1=tn2;
41
    s2=sno;
28
    int s1 = tn2;
29
    int s2 = sno;
42 30
    pthread_mutex_lock(ssmutex[s1]+s2);
43 31
    scurrent_bptr[s1][s2]=stransfer_buffer[s1][s2];
44 32
    // only read if buffer full and data is for you
......
57 45
  }
58 46
  else
59 47
  {
60
    s1=sno;
61
    s2=tn2;
48
    int s1 = sno;
49
    int s2 = tn2;
62 50
    pthread_mutex_lock(ssmutex[s1]+s2);
63 51
    scurrent_bptr[s1][s2]=stransfer_buffer[s1][s2];
64 52
    // only write if buffer empty
......
83 71
    adt[0].get_elapsed_time_and_reset();
84 72
  }
85 73
  int tn2=ad_comm::pthread_manager->get_slave_number();
86
  int s1,s2;
87 74
  if (tn2==sno)
88 75
  {
89 76
   // cerr << "Error -- process can not write to itself" << endl;
......
91 78
  }
92 79
  else if (tn2<sno)  // old master read from
93 80
  {
94
    s1=tn2;
95
    s2=sno;
81
    int s1 = tn2;
82
    int s2 = sno;
96 83
    pthread_mutex_lock(ssmutex[s1]+s2);
97 84
    scurrent_bptr[s1][s2]=stransfer_buffer[s1][s2];
98 85
    // only read if buffer full and data is for you
99 86
    while (ssflag(s1,s2) == 0) 
100 87
      pthread_cond_wait(smcondition[s1]+s2,ssmutex[s1]+s2);
101
    // cout  << "A sflag=0" << endl;
102 88
    ssflag(s1,s2)=0; 
103 89
  }
104 90
  else
105 91
  {
106
    s1=sno;
107
    s2=tn2;
92
    int s1 = sno;
93
    int s2 = tn2;
108 94
    pthread_mutex_lock(ssmutex[s1]+s2);
109 95
    scurrent_bptr[s1][s2]=stransfer_buffer[s1][s2];
110 96
    // only write if buffer empty
......
132 118
    cerr << "This can't happen" << endl;
133 119
    ad_exit(1);
134 120
  }
135
  int s1,s2;
136
  s1=tn2;
137
  s2=sno;
121
  int s1 = tn2;
122
  int s2 = sno;
138 123
  // *************************************************
139 124
  // *************************************************
140 125
  verify_identifier_string("WE");
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff