/var/lib/pcp/testsuite/src/multithread0.c is in pcp-testsuite 3.8.12ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 | /*
* Copyright (c) 2011 Ken McDonell. All Rights Reserved.
*
* exercise __pmMultiThreaded()
*/
#include <stdio.h>
#include <stdlib.h>
#include <pcp/pmapi.h>
#include <pcp/impl.h>
#include <pthread.h>
#ifndef HAVE_PTHREAD_BARRIER_T
#include "pthread_barrier.h"
#endif
static void *
func(void *arg)
{
if (__pmMultiThreaded(PM_SCOPE_DSO_PMDA))
printf("func: is multithreaded\n");
else
printf("func: is NOT multithreaded\n");
pthread_exit(NULL);
}
int
main()
{
pthread_t tid1;
pthread_t tid2;
int sts;
char *msg;
if (__pmMultiThreaded(PM_SCOPE_DSO_PMDA))
printf("main0: is multithreaded\n");
else
printf("main0: is NOT multithreaded\n");
sts = pthread_create(&tid1, NULL, func, NULL);
if (sts != 0) {
printf("thread_create: tid1: sts=%d\n", sts);
exit(1);
}
if (__pmMultiThreaded(PM_SCOPE_DSO_PMDA))
printf("main1: is multithreaded\n");
else
printf("main1: is NOT multithreaded\n");
sts = pthread_create(&tid2, NULL, func, NULL);
if (sts != 0) {
printf("thread_create: tid2: sts=%d\n", sts);
exit(1);
}
if (__pmMultiThreaded(PM_SCOPE_DSO_PMDA))
printf("main2: is multithreaded\n");
else
printf("main2: is NOT multithreaded\n");
pthread_join(tid1, (void *)&msg);
if (msg != NULL) printf("tid1: %s\n", msg);
pthread_join(tid2, (void *)&msg);
if (msg != NULL) printf("tid2: %s\n", msg);
exit(0);
}
|