2 atlc - arbitrary transmission line calculator, for the analysis of
3 transmission lines are directional couplers.
5 Copyright (C) 2002. Dr. David Kirkby, PhD (G8WRB).
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either package_version 2
10 of the License, or (at your option) any later package_version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
22 Dr. David Kirkby, e-mail drkirkby@ntlworld.com
35 #ifdef ENABLE_POSIX_THREADS
38 void *increment_a(void *arg);
39 void *increment_b(void *arg);
40 int finalise(int, int);
42 int r1 = 0, r2 = 0, r3 = 0;
44 pthread_mutex_t r3_mutex;
46 #endif /* ifdef ENABLE_POSIX_THREADS */
50 #ifdef ENABLE_POSIX_THREADS
51 pthread_t thread1, thread2;
54 pthread_mutex_init(&r3_mutex, NULL);
58 for(i=1; i<10000; ++i)
60 if( pthread_create(&thread1, NULL, increment_a, (void *) &r1) != 0)
62 perror("Thread 1 not created properly");
66 if( pthread_create(&thread2, NULL, increment_b, (void *) &r2) != 0)
68 perror("Thread 2 not created properly");
72 if(pthread_join(thread1, NULL) != 0)
74 perror("Thread 1 did not join properly");
77 if(pthread_join(thread2, NULL) != 0)
79 perror("Thread 2 did not join properly");
83 counter+=finalise(r1, r2);
85 if (counter == 399960000)
94 #ifdef ENABLE_POSIX_THREADS
95 void *increment_a(void *arg)
98 int *pnum_times=(int *) arg;
100 if( pthread_mutex_lock(&r3_mutex) != 0)
102 perror("pthread_mutex_lock failed");
111 if( pthread_mutex_unlock(&r3_mutex) != 0)
113 perror("pthread_mutex_unlock failed");
116 for (i = 0; i < 4; i++) {
122 void *increment_b(void *arg)
125 int *pnum_times=(int *) arg;
127 if( pthread_mutex_lock(&r3_mutex) != 0)
129 perror("pthread_mutex_lock failed");
138 if(pthread_mutex_unlock(&r3_mutex) != 0)
140 perror("pthread_mutex_unlock failed");
143 for (i = 0; i < 4; i++) {
149 int finalise(int one_times, int another_times)
153 total = one_times + another_times;