Revision 779 branches/pthreads-737/tests/nst/adthread.h

adthread.h (revision 779)
31 31
    char message[100];
32 32
  };
33 33
 // 
34
 extern const int NSLAVES;
35
 // 
36 34
 typedef char * pchar;
37 35
 // 
36
 /*
38 37
  class adpthread_manager
39 38
  {
39
    static __ADMBTHREAD__ int slave_number;
40 40
  public:
41
    static int is_slave(void) { if (slave_number)
42
                                  return 1;
43
                                else
44
                                  return 0; }
45
    static int is_master(void) { if (slave_number)
46
                                  return 0;
47
                                else
48
                                  return 1; }
49
    static int get_slave_number(void) { return slave_number; }
50
    static void set_slave_number(int n) { slave_number=n; }
51

  
41 52
    char ** transfer_buffer;
53
    char ** current_bptr;
42 54
    char ** buffend;
43 55
    int nslaves;
44 56
    int bs;
45 57
    int * mflag;
46 58
    int * sflag;
59
    ivector buffer_size;
47 60
    pthread_mutex_t * smutex;
48 61
    pthread_cond_t * scondition;
49 62
    pthread_cond_t *mcondition;
50
    pthread_t * thread1;  /* thread variables */
51
    adpthread_manager(int ns,int bs)
52
    {
53
      int i;
54
      nslaves=ns;
55
      transfer_buffer=new pchar[ns];
56
      buffend=new pchar[ns];
57
      transfer_buffer--;
58
      buffend--;
59
      for (i=1;i<=ns;i++)
60
      {
61
        transfer_buffer[i]=new char[bs];
62
        buffend[i]=transfer_buffer[i]+bs-1;
63
      }
64
      mflag=new int[ns];
65
      mflag--;
66
      sflag=new int[ns];
67
      sflag--;
68
      smutex=new pthread_mutex_t[ns];
69
      smutex--;
70
      for (i=1;i<=ns;i++)
71
      {
72
        pthread_mutex_init(smutex+i,NULL);
73
      }
74
      scondition=new pthread_cond_t[ns];
75
      scondition--;
76
      mcondition=new pthread_cond_t[ns];
77
      mcondition--;
78
      thread1=new pthread_t[ns];
79
      thread1--;
80
    }
63
    pthread_t * thread1;  // thread variables 
64
    adpthread_manager(int ns,int bs);
81 65
    void send_double_to_slave(const double &x,int sno);
82 66
    void send_double_to_master(double &x,int sno);
83 67
    double get_double_from_slave(int sno);
......
94 78
    dvar_vector get_dvar_vector_from_master(int sno);
95 79
    void send_dvar_vector_to_slave(const dvar_vector &x,int sno);
96 80
    void send_dvar_vector_to_master(const dvar_vector &x,int sno);
81
    double get_double_from_master_nl(int sno);
82
    //void send_dvar_vector_to_slave(const dvar_vector &x,int sno);
83
    void writebuffer(const void *x,int nbytes,int sno);
84
    void readbuffer(const void *x,int nbytes,int sno);
97 85
    void pthread_join_all(void);
98 86
    void create_all(void*f,thread_data * ptr);
87
    void check_buffer_size(int, int);
88
    void check_buffer_size_read(int, int);
89
    void memcpy(const double &x,int sno);
90
    void send_double_to_slave_nl(const double &x,int sno);
91
    void read_lock_buffer_slave(int sno);
92
    void write_lock_buffer_slave(int sno);
93
    void read_lock_buffer_master(int sno);
94
    void write_lock_buffer_master(int sno);
95
    void read_unlock_buffer_slave(int sno);
96
    void write_unlock_buffer_slave(int sno);
97
    void read_unlock_buffer_master(int sno);
98
    void write_unlock_buffer_master(int sno);
99
    void adjoint_slave_write_unlock(int sno);
100
    void adjoint_slave_write_lock(int sno);
101
    void adjoint_master_write_lock(int sno);
102
    void verify_id_string_from_master_nl(const char * s,int sno);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff