HP-UX Processor Sets

HP-UX Processor Sets 18
# psrset –a 1246
successfully assigned processor 2 to pset 1
successfully assigned processor 4 to pset 1
successfully assigned processor 6 to pset 1
Users can create a pset and assign processors using psrset as follows:
# psrset –c 246
successfully created pset 2
successfully assigned processor 2 to pset 2
successfully assigned processor 4 to pset 2
successfully assigned processor 6 to pset 2
Binding Applications to a Processor Set
The pset_bind() system call allows users to rebind a process, a thread, all processes owned
by some user, or all processes in a process group from its current processor set to another
processor set. When binding for a process is changed, binding for all its threads is also
changed to the new processor set.
int
pset_bind (
psetid_t pset, /* IN: new pset for process/thread */
itype_t idtype, /* IN: P_PID,P_LWPID,P_UID,P_PGRP */
id_t id, /* IN: pid, lwpid, uid or pgrp */
psetid_t* old_pset/* OUT: current pset */
);
If pset is empty, then the PSET_ATTR_EMPTY attribute for the processor set defines the
behavior. If idtype is P_UID, the processor set binding of all processes with effective user
IDs the same as id is changed. If idtype is P_PGRP, the processor set binding of all
processes in the process group specified by id is changed.
Users can rebind running processes to another processor set by specifying the process ID
(PID), the effective user ID (UID), or the process group ID (PGRP) values:
# psrset –b 1232
successfully bound pid 232 to pset 1
# psrset –U 121
successfully bound processes owned by uid 21 to pset 1
# psrset –g 120
successfully bound processes of pgid 20 to pset 1
Users can start an application in another processor set using psrset. The following example
will run the ps –ef command in pset 2:
# psrset –e 2ps–ef
The mpctl() system call allows an application to bind to a specific processor for better locality
performance. However, the processor sets restrict the processor affinity to a processor within
the application’s processor set. Users can bind a running process to a specific processor
using mpsched as follows: