2 Copyright (C) 2004-2006 Grame
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include <sys/types.h>
31 #include <semaphore.h>
38 #include "JackMachSemaphore.h"
39 #include "JackMachThread.h"
43 #include "JackWinThread.h"
44 #include "JackWinEvent.h"
48 #include "JackPosixThread.h"
49 #include "JackPosixSemaphore.h"
55 #define SERVER "serveur3"
56 #define CLIENT "client3"
60 class Test2
: public JackRunnableInterface
65 JackSynchro
* fSynchro1
;
66 JackSynchro
* fSynchro2
;
70 Test2(JackSynchro
* synchro1
, JackSynchro
* synchro2
)
71 : fSynchro1(synchro1
), fSynchro2(synchro2
)
77 for (int i
= 0; i
< ITER
; i
++) {
79 for (int j
= 0; j
< 2000000; j
++) {
89 int main(int ac
, char *av
[])
92 JackSynchro
* sem1
= NULL
;
93 JackSynchro
* sem2
= NULL
;
96 printf("Test of synchronization primitives : client side\n");
97 printf("type -s to test Posix semaphore\n");
98 printf("type -f to test Fifo\n");
99 printf("type -m to test Mach semaphore\n");
100 printf("type -e to test Windows event\n");
103 if (strcmp(av
[1], "-m") == 0) {
104 printf("Mach semaphore\n");
105 sem1
= new JackMachSemaphore();
106 sem2
= new JackMachSemaphore();
111 if (strcmp(av
[1], "-e") == 0) {
112 printf("Win event\n");
113 sem1
= new JackWinEvent();
114 sem2
= new JackWinEvent();
119 if (strcmp(av
[1], "-s") == 0) {
120 printf("Posix semaphore\n");
121 sem1
= new JackPosixSemaphore();
122 sem2
= new JackPosixSemaphore();
125 if (strcmp(av
[1], "-f") == 0) {
127 sem1
= new JackFifo();
128 sem2
= new JackFifo();
132 sem1
->ConnectOutput(SERVER
);
133 sem2
->ConnectInput(CLIENT
);
135 obj
= new Test2(sem1
, sem2
);
138 thread
= new JackMachThread(obj
, 10000 * 1000, 500 * 1000, 10000 * 1000);
142 thread
= new JackWinThread(obj
);
146 thread
= new JackPosixThread(obj
, false, 50, PTHREAD_CANCEL_DEFERRED
);
150 thread
->AcquireRealTime();