2 Copyright (C) 2004-2008 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"
42 #include "JackWinEvent.h"
46 #include "JackPosixSemaphore.h"
50 #include "JackPlatformThread.h"
54 #define SERVER "serveur3"
55 #define CLIENT "client3"
59 class Test2
: public JackRunnableInterface
64 detail::JackSynchro
* fSynchro1
;
65 detail::JackSynchro
* fSynchro2
;
69 Test2(detail::JackSynchro
* synchro1
, detail::JackSynchro
* synchro2
)
70 : fSynchro1(synchro1
), fSynchro2(synchro2
)
76 for (int i
= 0; i
< ITER
; i
++) {
78 for (int j
= 0; j
< 2000000; j
++) {
88 int main(int ac
, char *av
[])
91 detail::JackSynchro
* sem1
= NULL
;
92 detail::JackSynchro
* sem2
= NULL
;
95 printf("Test of synchronization primitives : client side\n");
96 printf("type -s to test Posix semaphore\n");
97 printf("type -f to test Fifo\n");
98 printf("type -m to test Mach semaphore\n");
99 printf("type -e to test Windows event\n");
102 if (strcmp(av
[1], "-m") == 0) {
103 printf("Mach semaphore\n");
104 sem1
= new JackMachSemaphore();
105 sem2
= new JackMachSemaphore();
110 if (strcmp(av
[1], "-e") == 0) {
111 printf("Win event\n");
112 sem1
= new JackWinEvent();
113 sem2
= new JackWinEvent();
118 if (strcmp(av
[1], "-s") == 0) {
119 printf("Posix semaphore\n");
120 sem1
= new JackPosixSemaphore();
121 sem2
= new JackPosixSemaphore();
124 if (strcmp(av
[1], "-f") == 0) {
126 sem1
= new JackFifo();
127 sem2
= new JackFifo();
131 if (!sem1
->ConnectOutput(SERVER
, "default"))
133 if (!sem2
->ConnectInput(CLIENT
, "default"))
136 obj
= new Test2(sem1
, sem2
);
139 thread
= new JackMachThread(obj
, 10000 * 1000, 500 * 1000, 10000 * 1000);
143 thread
= new JackWinThread(obj
);
147 thread
= new JackPosixThread(obj
, false, 50, PTHREAD_CANCEL_DEFERRED
);
151 thread
->AcquireRealTime();