Changeset 167


Ignore:
Timestamp:
Jun 23, 2008, 2:11:21 PM (11 years ago)
Author:
cameron
Message:

Affinity binding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/markup_stats.cxx

    r161 r167  
    349349
    350350
    351 
     351#include <sched.h>
    352352
    353353int
    354354main(int argc, char * argv[]) {
     355
     356#ifdef SET_AFFINITY
     357cpu_set_t mask;
     358
     359
     360unsigned int len = sizeof(mask);
     361if (sched_getaffinity(0, len, &mask) < 0) {
     362    perror("sched_getaffinity");
     363    return -1;
     364    }
     365printf("Original affinity mask is: %08lx\n", mask);
     366
     367CPU_CLR(0, &mask);
     368
     369if (sched_setaffinity(0, len, &mask) < 0) {
     370    perror("sched_setaffinity");
     371}
     372if (sched_getaffinity(0, len, &mask) < 0) {
     373    perror("sched_getaffinity");
     374    return -1;
     375    }
     376printf("Modified affinity mask is:  %08lx\n", mask);
     377#endif
     378
     379
     380
     381
    355382        if (argc != 2) {
    356383        printf("Usage: %s <filename>\n", argv[0]);
Note: See TracChangeset for help on using the changeset viewer.