USING MULTIPLE CPUS
IN SGI IRIX
Programmer may use library functions to bind a process or a thread to a specific CPU. How to use multiple CPUs on IRIX is briefly explained in the sections above.
IRIX provides sysmp (2) library function to give programmer the ability to access multiple processors available in the system. To be able to use those functions, programmer needs to include the following header files inside the code.
#include <sys/types.h>
#include <sys/sysmp.h>
#include <sys/sysinfo.h>
The sysmp (2) function will be the only funtion that we will be use for basic Multiple CPU oriented programming. We will first try to get the numner of processors curr ently available in the system. Here is the code which does that for use:
/* get the number of processors */
printf("System has %d processors.\n, sysmp(MP_NPROCS));
/* we are now running on */
printf("We are now running on processor %d.\n",
sysmp(MP_GETMUSTRUN));
When we run the given code, it will give us the number of total processors available in the system. Since we know the processor ids now, we can start binding processes onto processors. Here is the code which does that for us:
/* switch to processor 2 */
sysmp(MP_MUSTRUN, 2);
/* check to see if we realy on processor 2 */
printf("We are now running on processor %d.\n",
sysmp(MP_GETMUSTRUN));