~ubuntu-branches/ubuntu/vivid/atlas/vivid

« back to all changes in this revision

Viewing changes to CONFIG/src/backend/probe_aff_SETPROCNP.c

  • Committer: Package Import Robot
  • Author(s): Sébastien Villemot
  • Date: 2013-06-11 15:58:16 UTC
  • mfrom: (1.1.3 upstream)
  • mto: (2.2.21 experimental)
  • mto: This revision was merged to the branch mainline in revision 26.
  • Revision ID: package-import@ubuntu.com-20130611155816-b72z8f621tuhbzn0
Tags: upstream-3.10.1
Import upstream version 3.10.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdio.h>
 
2
#include <stdlib.h>
 
3
#include <assert.h>
 
4
#include <pthread.h>
 
5
 
 
6
static int rank=0;
 
7
 
 
8
void *DumbTest(void *vp)
 
9
{
 
10
   pthread_exit(vp);
 
11
}
 
12
int main(int nargs, char **args)
 
13
{
 
14
   pthread_attr_t attr;
 
15
   pthread_t thr;
 
16
   void *vp, *vpret;
 
17
 
 
18
   if (nargs > 1)
 
19
      rank = atoi(args[1]);
 
20
   vp = (void*) &thr;
 
21
   vpret = NULL;
 
22
   assert(!pthread_attr_init(&attr));
 
23
   #ifdef IBM_PT_ERROR
 
24
      assert(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_UNDETACHED));
 
25
   #else
 
26
      assert(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE));
 
27
   #endif
 
28
   pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); /* OK to fail */
 
29
   assert(!pthread_attr_setprocessor_np(&attr, (pthread_spu_t)rank,
 
30
                                        PTHREAD_BIND_FORCED_NP));
 
31
   assert(!pthread_create(&thr, &attr, DumbTest, vp));
 
32
   assert(!pthread_attr_destroy(&attr));
 
33
   assert(!pthread_join(thr, &vpret));
 
34
   if (vpret == vp)
 
35
      printf("SUCCESS rank %d\n", rank);
 
36
   else
 
37
      printf("FAILURE rank %d\n", rank);
 
38
   exit(vpret == vp ? 0 : 1);
 
39
}