cpu(HW)
cpu --
SMP ioctl's
Syntax
#include <sys/ci/cilock.h>
#include <sys/ci/cimpdata.h>
#include <sys/ci/ciioctl.h>
Description
These ioctl's are provided on multiprocessor configurations
to allow programs to query
the number of CPUs that are configured,
to lock and unlock processes to specific CPUs,
and to enable and disable specific CPUs.
Use these with the
ioctl(S)
system call.
The first argument to
ioctl( )
is a file descriptor, returned by an
open(S)
call to the /dev/at<XX> device,
where <XX> is the CPU number.
ACPU_GETNUM-
return number of additional CPUs
beyond the primary CPU
in the
int
pointed to by arg.
For example, on a 4-CPU configuration,
this ioctl yields a value of 3.
ACPU_INACTIVE-
make the specified CPU be "inactive" (runs no processes);
arg is unused.
ACPU_ACTIVE-
make the specified CPU be "active" again
so that processes can be scheduled to run on this CPU;
arg is unused.
ACPU_STATIC-
make the specified CPU be "static";
processes will not be scheduled to run on this CPU,
but existing processes that are locked
to this CPU will run.
arg is unused.
ACPU_LOCK-
lock a process to the specified CPU.
arg is a pointer to an
int
that contains
the pid to lock.
ACPU_UNLOCK-
unlock a process;
it may then run on any CPU.
arg is a pointer to an
int
that contains
the pid to unlock.
ACPU_XLOCK-
special Xserver locking (not recommended).
arg is unused;
the process performing the ioctl locks itself.
The following ioctls are not implemented at this time:
ACPU_LED_OFF-
Not implemented at this time.
ACPU_LED_BLINK-
Not implemented at this time.
ACPU_LED_ON-
Not implemented at this time.
See also
cpuonoff(ADM),
lockpid(ADM),
mpstat(ADM)
For information about binding drivers to a CPU,
see the
Documentation for the Consolidated Hardware Development Kit,
which can be downloaded from the
Consolidated Hardware Development (HDK) Web Page.
The documentation can be viewed at
Documentation Web Page.
Select the Open UNIX 8 or UnixWare 7 doc
then click on "Hardware and Driver Development".
Note especially the
idistributed(D3oddi)
and
remap_driver_cpu(D3oddi)
functions.
Examples
Example 1
The first example illustrates how
a process queries the number of CPUs
beyond the primary CPU that are configured.
#include <sys/ci/cilock.h>
#include <sys/ci/cimpdata.h>
#include <sys/ci/ciioctl.h>
#include <fcntl.h>
int fd;
int num_CPUs;
if ( (fd = open("/dev/at1", O_RDONLY)) < 0 )
perror("/dev/at1");
exit(1);
}
if ( ioctl(fd, ACPU_GETNUM, &num_CPUs) < 0 ) {
perror("ACPU_GETNUM");
exit(1);
}
printf("Total number of CPUs: %d\n", num_CPUs + 1);
Example 2
The second example illustrates how
a process locks itself to a particular CPU
(/dev/at2 in this case).
This uses the same #include files
shown in Example 1.
int fd;
int pid;
if ( (fd = open("/dev/at2", O_RDONLY)) < 0 ) {
perror("/dev/at2");
exit(1);
}
pid = (int)getpid();
if ( ioctl(fd, ACPU_LOCK, &pid) < 0 ) {
perror("ACPU_LOCK");
exit(1);
}
printf("Process %d locked to CPU #2\n", pid);
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003