6 #include <sys/thread.h> 10 #define ra_det ra_det_ 15 int rs,preDetachrs,postDetachrs;
25 tid_string=malloc(4*
sizeof(
char));
33 rset=rs_alloc(RS_EMPTY);
35 if ( *det_type==CHECK_PROC ) {
37 rsid.at_pid=RS_MYSELF;
38 sprintf(tid_string,
" %d",mypid);
40 else if ( *det_type==CHECK_THREAD ) {
42 rsid.at_tid=RS_MYSELF;
43 thread_num=omp_get_thread_num();
44 sprintf(tid_string,
" %d: %d",thread_num,mytid);
47 fprintf(stderr,
"Error: rstype not R_PROCESS (1) or R_THREAD (2)\n");
52 preDetachrs=ra_getrset(rstype,rsid,0,rset);
54 switch (preDetachrs) {
55 case RS_EFFECTIVE_RSET:
56 preRSET=
"RS_EFFECTIVE_RSET";
58 case RS_PARTITION_RSET:
59 preRSET=
"RS_PARTITION_RSET";
62 preRSET=
"RS_DEFAULT_RSET";
65 preRSET=
"RS_THREAD_RSET";
67 case RS_THREAD_PARTITION_RSET:
68 preRSET=
"RS_THREAD_PARTITION_RSET";
77 rs=ra_detachrset(rstype,rsid,0);
79 postDetachrs=ra_getrset(rstype,rsid,0,rset);
81 switch (postDetachrs) {
82 case RS_EFFECTIVE_RSET:
83 postRSET=
"RS_EFFECTIVE_RSET";
85 case RS_PARTITION_RSET:
86 postRSET=
"RS_PARTITION_RSET";
89 postRSET=
"RS_DEFAULT_RSET";
92 postRSET=
"RS_THREAD_RSET";
94 case RS_THREAD_PARTITION_RSET:
95 postRSET=
"RS_THREAD_PARTITION_RSET";
106 perror(
"ra_detachrset error:");
109 if(*prnt==1) fprintf(stderr,
"ra_det:%s Successfully detached from rset: %s. Current rset: %s\n",tid_string,preRSET,postRSET);
int ra_det(int *det_type, int *prnt)