B.5 setCPU.c

     
 

 #  cat setCPU.c  #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <sys/mpctl.h> main(argc,argv) int argc; char *argv[]; {         spu_t new_processor;         int pid;         if ( argc < 3 )         {                 printf("\n 
 #  cat setCPU.c  #include <errno.h> #include <stdio.h> #include <stdlib.h> #include <sys/mpctl.h> main(argc,argv) int argc; char *argv[]; { spu_t new_processor; int pid; if ( argc < 3 ) { printf("\n\007ERROR : %s <processor> <prog>\n", argv[0]); exit(1); } printf("Number of locality domains = %d\n", mpctl(MPC_GETNUMLDOMS_SYS,0,0 )); printf("Number of processors = %d\n",mpctl(MPC_GETNUMSPUS_SYS,0,0)); if ( fork() == 0) { pid=getpid(); if ( new_processor=mpctl(MPC_SETPROCESS_FORCE, atoi(argv[1]), pid) == -1 ) perror("mpctl-SETPROCESS"); else printf("New processor for proc > %d < == %d\n", pid, mpctl graphics/ccc.gif (MPC_GETCURRENTSPU,0,0)); if ( execl(argv[2], argv[2], (char *)0) == -1 ) { perror("execl"); exit(1); } exit(0); } } # #  ioscan -fnkC processor  Class I H/W Path Driver S/W State H/W Type Description =================================================================== processor 0 2/10 processor CLAIMED PROCESSOR Processor processor 1 2/11 processor CLAIMED PROCESSOR Processor processor 2 2/12 processor CLAIMED PROCESSOR Processor processor 3 2/13 processor CLAIMED PROCESSOR Processor # #  getconf KERNEL_BITS  64 #  echo "cpu_arch_is_2_0/D"  adb /stand/vmunix /dev/kmem  cpu_arch_is_2_0: cpu_arch_is_2_0: 1 # #  make setCPU  cc -O setCPU.c -o setCPU (Bundled) cc: warning 480: The -O option is available only with the C/ANSI C product; ignored. /usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (setCPU.o) was detected . The linked output may not run on a PA 1.x system. # #  ./setCPU 2 ./bigcpu  Number of locality domains = 1 Number of processors = 4 New processor for proc > 12325 < == 2 # 
7ERROR : %s <processor> <prog>\n", argv[0]); exit(1); } printf("Number of locality domains = %d\n", mpctl(MPC_GETNUMLDOMS_SYS,0,0 )); printf("Number of processors = %d\n",mpctl(MPC_GETNUMSPUS_SYS,0,0)); if ( fork() == 0) { pid=getpid(); if ( new_processor=mpctl(MPC_SETPROCESS_FORCE, atoi(argv[1]), pid) == -1 ) perror("mpctl-SETPROCESS"); else printf("New processor for proc > %d < == %d\n", pid, mpctl graphics/ccc.gif (MPC_GETCURRENTSPU,0,0)); if ( execl(argv[2], argv[2], (char *)0) == -1 ) { perror("execl"); exit(1); } exit(0); } } # # ioscan -fnkC processor Class I H/W Path Driver S/W State H/W Type Description =================================================================== processor 0 2/10 processor CLAIMED PROCESSOR Processor processor 1 2/11 processor CLAIMED PROCESSOR Processor processor 2 2/12 processor CLAIMED PROCESSOR Processor processor 3 2/13 processor CLAIMED PROCESSOR Processor # # getconf KERNEL_BITS 64 # echo "cpu_arch_is_2_0/D" adb /stand/vmunix /dev/kmem cpu_arch_is_2_0: cpu_arch_is_2_0: 1 # # make setCPU cc -O setCPU.c -o setCPU (Bundled) cc: warning 480: The -O option is available only with the C/ANSI C product; ignored. /usr/ccs/bin/ld: (Warning) At least one PA 2.0 object file (setCPU.o) was detected. The linked output may not run on a PA 1.x system. # # ./setCPU 2 ./bigcpu Number of locality domains = 1 Number of processors = 4 New processor for proc > 12325 < == 2 #



HP-UX CSE(c) Official Study Guide and Desk Reference
HP-UX CSE(c) Official Study Guide and Desk Reference
ISBN: N/A
EAN: N/A
Year: 2006
Pages: 434

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net