#! /bin/ksh

#
# Name	      : ${HOME}/AIX/SetProcessorAffinity.ksh
#
# Version     : 1.0
#
# Author      : Gerard van Wageningen
#
# Description : Set Processor Affinity
#
# 1.0	First Version
#


typeset -i PROCESSOR


\whence set_debug 1> /dev/null 2>&1 && eval $( set_debug ${0##*/} )


if ! \whence -p bindprocessor 1>/dev/null 2>&1
then
  print -u2 'Could not find bindprocessor executable, bailing out...'
  exit 1
fi


#The available processors are:  0 1 2
#for i in $( seq 0 6 )
#do
#echo $i ${XXX[i]}
#done
#0 The
#1 available
#2 processors
#3 are:
#4 0
#5 1
#6 2

case $# in
  0) set -A XXX $( bindprocessor -q ) ; PROCESSOR="${XXX[4]}" ;;
  1) PROCESSOR="$1" ;;
  *) print -u2 "$0 <processor number>\n$( bindprocessor -q )" ; exit 1 ;;
esac


bindprocessor ${PPID} ${XXX[4]}


exit 0


############# EOF #############
