17.3. System Configuration

 < Day Day Up > 

17.2. Kernel Utilities

Mac OS X includes various utilities that interact with the kernel. With these utilities, you can debug a running kernel, load and unload kernel modules or extensions, or set kernel variables.

17.2.1. ddb

The ddb utility can debug a running kernel. It is not included with the current version of Mac OS X. If you want to use ddb, you can find its source code in the xnu (Darwin kernel) source code (http://www.opensource.apple.com/darwinsource/).

17.2.2. ktrace

Use ktrace to perform kernel tracing (tracing system calls and other operations) on a process. To launch a program and generate a kernel trace (ktrace.out, which is not human-readable), use ktrace command, as in ktrace emacs. Kernel tracing ends when you exit the process or disable tracing with ktrace -cp pid. You can get human readable output from a ktrace file with kdump -f ktrace.out.

17.2.3. Kernel Module Utilities

The following list describes utilities for manipulating kernel modules. For more information, see the kernel extension tutorials available at http://www.opendarwin.org/en/articles/:


kextload

Loads an extension bundle. Requires superuser privileges.


kextunload

Unloads an extension bundle. Requires superuser privileges.


kextstat

Displays the status of currently loaded kernel extensions. Table 17-5 describes this utility's output. Figure 17-6 shows sample output.

Figure 17-6. Partial output of kextstat


Table 17-5. Information displayed by kextstat

Item number

Column

Description

1

Index

Index number of the loaded extension. Extensions are loaded in sequence; gaps in this sequence signify extensions that have been unloaded.

2

Refs

Number of references to this extension from other extensions.

3

Address

Kernel space address of the extension.

4

Size

Amount of kernel memory (in bytes) used by the extension.

5

Wired

Amount of wired kernel memory (in bytes) used by the extension.

6

Name (Version)

Name and version of the extension.

7

<Linked Against>

Index of kernel extensions to which this extension refers.


17.2.4. sysctl

sysctl is a standard BSD facility for configuring kernel state variables . Use sysctl name to display a variable name, as in sysctl kern.ostype. Use sysctl -a to display all variables. If you have superuser privileges, you can set a variable with sysctl -w name=value.

Table 17-6 lists the sysctl variables on Mac OS X. See the sysctl(3) manpage for a description of the sysctl system call and more detailed information on the kernel state variables.

Table 17-6. sysctl's kernel state variables

Name

Type

Writable

Description

hw.activecpu

int

no

The number of CPUs currently active (may be affected by power management settings).

hw.availcpu

int

no

Number of available CPUs.

hw.busfrequency

int

no

Bus frequency in hertz. Divide by one million for a megahertz figure.

hw.busfrequency_max

int

no

Maximum bus frequency in hertz.

hw.busfrequency_min

int

no

Minimum bus frequency in hertz.

hw.byteorder

int

no

Variable that returns 4321, showing the ordering of four bytes on the PowerPC platform.

hw.cachelinesize

int

no

The cache line size in bytes.

hw.cpufrequency

int

no

CPU frequency in hertz. Divide by one million for a megahertz figure.

hw.cpufrequency_max

int

no

Maximum CPU frequency in hertz.

hw.cpufrequency_min

int

no

Minimum CPU frequency in hertz.

hw.cpusubtype

int

no

The mach-o subtype of the CPU (see /System/Library/Frameworks/Kernel.framework/Versions/A/Headers/mach/machine.h).

hw.cputype

int

no

The mach-o type of the CPU.

hw.epoch

int

no

Variable that indicates whether your hardware is "New World" or "Old World." Old World Macintoshes (pre-G3) have a value of 0.

hw.l1dcachesize

int

no

Level 1 data cache size in bytes.

hw.l1icachesize

int

no

Level 1 instruction cache size in bytes.

hw.l2cachesize

int

no

Level 2 cache size in bytes.

hw.l2settings

int

no

Level 2 cache settings.

hw.l3cachesize

int

no

Level 3 cache size in bytes.

hw.l3settings

int

no

Level 3 cache settings.

hw.logicalcpu

int

no

Number of logical CPUs.

hw.logicalcpu_max

int

no

Maximum number of available logical CPUs.

hw.machine

string

no

Machine class (Power Macintosh on most systems).

hw.memsize

int

no

Memory size.

hw.model

string

no

Machine model.

hw.ncpu

int

no

Number of CPUs.

hw.optional.altivec

int

no

Indicates whether AltiVec is enabled.

hw.optional.datastreams

int

no

Indicates whether PowerPC data stream instructions are supported by the CPU.

hw.optional.dcba

int

no

Indicates whether the PowerPC DCBA instruction is supported by the CPU.

hw.optional.floatingpoint

int

no

Indicates whether floating-point operations are supported by the CPU.

hw.optional.graphicsops

int

no

Indicates whether graphics operations are supported by the CPU.

hw.optional.stfiwx

int

no

Indicates whether the PowerPC STFIWX instruction is supported by the CPU.

hw.pagesize

int

no

Software page size in bytes.

hw.physicalcpu

int

no

Number of physical CPUs.

hw.physicalcpu_max

int

no

Maximum available physical CPUs.

hw.physmem

int

no

Physical memory in bytes.

hw.tbfrequency

int

no

The base frequency used by Mac OS X for its timing services.

hw.usermem

int

no

Non-kernel memory.

hw.vectorunit

int

no

Variable that indicates whether you are running on an AltiVec-enabled CPU.

kern.aiomax

int

no

Maximum AIO requests.

kern.aioprocmax

int

no

Maximum AIO requests per process.

kern.aiothreads

int

no

Maximum number of AIO worker threads.

kern.argmax

int

no

Maximum number of arguments supported by exec( ).

kern.boottime

struct timeval

no

The time when the system was booted.

kern.clockrate

struct clockinfo

no

System clock timings.

kern.coredump

int

yes

Determines whether core dumps are enabled.

kern.corefile

string

yes

Location of core dump files (%P is replaced with process id).

kern.delayterm

int

unknown

Unknown or undocumented.

kern.dummy

n/a

n/a

Unused.

kern.hibernatefile

string

yes

Unknown or undocumented.

kern.hibernatemode

int

yes

Unknown or undocumented.

kern.hostid

int

yes

Host identifier.

kern.hostname

string

yes

Hostname.

kern.ipc.*

various

n/a

Various IPC settings.

kern.job_control

int

no

Variable that indicates whether job control is available.

kern.low_pri_delay

int

yes

Set/reset throttle delay in milliseconds.

kern.low_pri_window

int

yes

Set/reset throttle window in milliseconds.

kern.maxfiles

int

yes

Maximum number of open files.

kern.maxfilesperproc

int

yes

Maximum number of open files per process.

kern.maxproc

int

yes

Maximum number of simultaneous processes.

kern.maxprocperuid

int

yes

Maximum number of simultaneous processes per user.

kern.maxvnodes

int

yes

Maximum number of vnodes.

kern.netboot

int

no

Variable that indicates whether the system booted via NetBoot.

kern.ngroups

int

no

Maximum number of supplemental groups.

kern.nisdomainname

string

yes

NIS domain name.

kern.osrelease

string

no

Operating system release version.

kern.osrevision

int

no

Operating system revision.

kern.ostype

string

no

Operating system name.

kern.posix.sem.max

int

yes

Maximum number of POSIX semaphores.

kern.posix1version

int

no

The version of POSIX 1003.1 with which the system attempts to comply.

kern.saved_ids

int

no

This is set to 1 if saved set-group and set-user IDs are available.

kern.securelevel

int

increment only

The system security level.

kern.shreg_private

int

no

Indicates whether shared memory regions can be privatized.

kern.sugid_coredump

int

yes

Determines whether SUID and SGID files are allowed to dump core.

kern.sugid_scripts

int

yes

Determines whether to permit SUID and SGID scripts.

kern.symfile

string

no

The kernel symbol file.

kern.sysv.*

various

n/a

System V semaphore settings. See /System/Library/Frameworks/Kernel.framework/Versions/A/Headers/sys/sysctl.h.

kern.sysv.shmall

int

yes

The maximum size of a shared memory segment.

kern.sysv.shmmax

int

yes

The maximum number of shared memory pages.

kern.sysv.shmmin

int

yes

The maximum number of shared memory segments per process.

kern.sysv.shmmni

int

yes

The maximum number of shared memory segments.

kern.sysv.shmseg

int

yes

The minimum size of a shared memory segment.

kern.usrstack

int

no

Address of USRSTACK.

kern.version

string

no

The kernel version string.

net.appletalk.routermix

  

Unknown or undocumented.

net.inet.*

various

n/a

IPv4 settings.

net.inet6.*

various

n/a

IPv6 settings.

net.key.*

various

n/a

IPSec key management settings.

net.link.ether.inet.*

various

n/a

Ethernet settings.

net.local.*

various

n/a

Various network settings.

user.bc_base_max

int

no

Maximum ibase/obase available in the bc calculator.

user.bc_dim_max

int

no

Maximum array size available in the bc calculator.

user.bc_scale_max

int

no

Maximum scale value available in the bc calculator.

user.bc_string_max

int

no

Maximum string length available in the bc calculator.

user.coll_weights_max

int

no

Maximum number of weights that can be used with LC_COLLATE in the locale definition file.

user.cs_path

string

no

Value for PATH that can find all the standard utilities.

user.expr_nest_max

int

no

Maximum number of expressions you can nest within parentheses using expr.

user.line_max

int

no

Maximum length in bytes of an input line used with a text-processing utility.

user.posix2_c_bind

int

no

Variable that returns 1 if the C development environment supports the POSIX C Language Bindings Option; otherwise, the result will be 0.

user.posix2_c_dev

int

no

Variable that returns 1 if the C development environment supports the POSIX C Language Development Utilities Option; otherwise, the result will be 0.

user.posix2_char_term

int

no

Variable that returns 1 if the systems supports at least one terminal type specified in POSIX 1003.2; otherwise, the result will be 0.

user.posix2_fort_dev

int

no

Variable that returns 1 if the system supports the POSIX FORTRAN Development Utilities Option; otherwise, the result will be 0.

user.posix2_fort_run

int

no

Variable that returns 1 if the system supports the POSIX FORTRAN Runtime Utilities Option; otherwise, the result will be 0.

user.posix2_localedef

int

no

Variable that returns 1 if the system allows you to create locale; otherwise, the result will be 0.

user.posix2_sw_dev

int

no

Variable that returns 1 if the system supports the POSIX Software Development Utilities Option; otherwise, the result will be 0.

user.posix2_upe

int

no

Variable that returns 1 if the system supports the POSIX User Portable Utilities Option; otherwise, the result will be 0.

user.posix2_version

int

no

Variable that returns the POSIX 1003.2 version with which the system attempts to comply.

user.re_dup_max

int

no

Maximum repeated occurrences of a regular expression when using interval notation.

user.stream_max

int

no

Maximum number of streams a process may have open.

user.tzname_max

int

no

Maximum number of types supported for a time zone name.

vfs.*

various

n/a

Various VFS settings.

vm.loadavg

string

no

Current load average.

vm.swapusage

string

no

Current swap file usage.


     < Day Day Up > 


    Mac OS X Tiger for Unix Geeks
    Mac OS X Tiger for Unix Geeks
    ISBN: 0596009127
    EAN: 2147483647
    Year: 2006
    Pages: 176

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