/[resiprocate]/main/resip/stack/test/testThreads.c
ViewVC logotype

Contents of /main/resip/stack/test/testThreads.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 8801 - (show annotations) (download)
Wed Sep 8 13:23:30 2010 UTC (9 years, 2 months ago) by sgodin
File MIME type: text/plain
File size: 606 byte(s)
-fix a link issue with a missing argv[] in testThreads.c - thanks to Aron Rosenberg
1 #include <stdio.h>
2 #include <pthread.h>
3
4 pthread_mutex_t rmutex;
5
6 void *pfunc(void *arg)
7 {
8 int lcount=(int)arg;
9 pthread_mutex_lock(&rmutex);
10 printf("Loop [%d]\n",lcount--);
11 if (lcount)
12 pfunc((void*)lcount);
13 pthread_mutex_unlock(&rmutex);
14 }
15
16 int main(int argc, char *argv[])
17 {
18 pthread_t thread;
19 pthread_mutexattr_t mutexattr;
20 pthread_mutexattr_init(&mutexattr);
21 if (argc < 2)
22 pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
23 pthread_mutex_init(&rmutex, &mutexattr);
24 alarm(1);
25 pthread_create(&thread, NULL, pfunc, (void*)10);
26 pthread_join(thread, NULL);
27
28 }

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27