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

xthread_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
typedef char * pchar;
17
typedef ofstream * pofstream;
18

  
19 10
void adjoint_adwrite_lock_buffer_1(void);
20 11
void adjoint_adwrite_lock_buffer_2(void);
21 12

  
......
27 18
    //adt[0].get_elapsed_time_and_reset();
28 19
  }
29 20
  int tn2=ad_comm::pthread_manager->get_slave_number();
30
  int s1,s2;
31 21
  if (tn2==sno)
32 22
  {
33 23
    //cerr << "Error -- process can not write to itself" << endl;
......
35 25
  }
36 26
  else if (tn2<sno)  // old master write to slave
37 27
  {
38
    s1=tn2;
39
    s2=sno;
28
    int s1 = tn2;
29
    int s2 = sno;
40 30
    pthread_mutex_lock(ssmutex[s1]+s2);
41 31
    // only write if buffer empty
42 32
    while (smflag(s1,s2) == 1 || ssflag(s1,s2) ==1 ) 
......
52 42
  }
53 43
  else if (sno<tn2)  // old slave write to master
54 44
  {
55
    s2=tn2;
56
    s1=sno;
45
    int s2 = tn2;
46
    int s1 = sno;
57 47
    pthread_mutex_lock(ssmutex[s1]+s2);
58 48
    // only write if buffer empty
59 49
    while (smflag(s1,s2) == 1 || ssflag(s1,s2) ==1 ) 
......
68 58
        set_gradient_stack(::adjoint_adwrite_lock_buffer_2);
69 59
  }
70 60
}   
71

  
72 61
void adpthread_manager::cwrite_lock_buffer(int sno)
73 62
{
74 63
  if (logflag)
......
77 66
    //adt[0].get_elapsed_time_and_reset();
78 67
  }
79 68
  int tn2=ad_comm::pthread_manager->get_slave_number();
80
  int s1,s2;
81 69
  if (tn2==sno)
82 70
  {
83 71
    //cerr << "Error -- process can not write to itself" << endl;
......
85 73
  }
86 74
  else if (tn2<sno)  // old master write to slave
87 75
  {
88
    s1=tn2;
89
    s2=sno;
76
    int s1 = tn2;
77
    int s2 = sno;
90 78
    pthread_mutex_lock(ssmutex[s1]+s2);
91 79
    // only write if buffer empty
92 80
    while (smflag(s1,s2) == 1 || ssflag(s1,s2) ==1 ) 
......
94 82
  }
95 83
  else if (sno<tn2)  // old slave write to master
96 84
  {
97
    s2=tn2;
98
    s1=sno;
85
    int s2 = tn2;
86
    int s1 = sno;
99 87
    pthread_mutex_lock(ssmutex[s1]+s2);
100 88
    // only write if buffer empty
101 89
    while (smflag(s1,s2) == 1 || ssflag(s1,s2) ==1 ) 
102 90
      pthread_cond_wait(sscondition[s1]+s2,ssmutex[s1]+s2);
103 91
  }
104 92
}   
105

  
106 93
void adjoint_adwrite_lock_buffer_1(void)
107 94
{
108 95
  verify_identifier_string("CT");
......
122 109
    cerr << "This can't happen" << endl;
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff