Add Book to My BookshelfPurchase This Book Online

Chapter 9 - System Configuration and Resource Limits

UNIX Systems Programming for SVR4
David A. Curry
 Copyright © 1996 O'Reilly & Associates, Inc.

System Resource Limits
There are many limits imposed both by the operating system and by the native hardware architecture; these include such things as the maximum positive integer, the minimum decimal value of a floating-point number, the maximum number of characters in a terminal input buffer, the maximum length of a filename, and so forth. Prior to the adoption of the POSIX standard, these limits were defined in various include files and the programmer had to examine those to determine where items were defined.
The POSIX standard specifies that most of these limits should be described, using standard constant names, in the include file limits.h. The standard also specifies three functions that can be used to determine the values of the more “interesting” of these values at runtime:
    #include <unistd.h>
    long sysconf(int name);
    long fpathconf(int fd, int name);
    long pathconf(const char *path, int name);
The sysconf function returns the current value of a configurable system limit or option. If the call fails due to an error, it returns -1 and sets  errno to indicate the error. If it fails due to an unknown value of name, it returns -1 but does not change the value of  errno.
The legal values for name and their meanings are:
_SC_VERSION
The version of the POSIX.1 standard supported by this system.
_SC_XOPEN_VERSION
The version of the X/Open standard supported by this system.
_SC_JOB_CONTROL
A Boolean value indicating whether or not job control is supported.
_SC_SAVED_IDS
A Boolean value indicating whether or not saved IDs (used by setuid and setgid) are supported.
_SC_ASYNCHRONOUS_IO
A Boolean value indicating whether or not the system supports asynchronous input and output.
_SC_FSYNC
A Boolean value indicating whether or not the system supports file synchronization (the fsync system call).
_SC_MAPPED_FILES
A Boolean value indicating whether or not the system supports memory-mapped files.
_SC_MEMLOCK
A Boolean value indicating whether or not the system supports process memory locking.
_SC_MEMLOCK_RANGE
A Boolean value indicating whether or not the system supports process memory range locking.
_SC_MEMORY_PROTECTION
A Boolean value indicating whether or not the system supports memory protection.
_SC_MESSAGE_PASSING
A Boolean value indicating whether or not the system supports message passing.
_SC_PRIORITIZED_IO
A Boolean value indicating whether or not the system supports prioritized input and output.
_SC_PRIORITY_SCHEDULING
A Boolean value indicating whether or not the system supports process scheduling.
_SC_REALTIME_SIGNALS
A Boolean value indicating whether or not the system supports the POSIX real-time signals extension.
_SC_SEMAPHORES
A Boolean value indicating whether or not the system supports semaphores.
_SC_SHARED_MEMORY_OBJECTS
A Boolean value indicating whether or not the system supports shared memory objects.
_SC_SYNCHRONIZED_IO
A Boolean value indicating whether or not the system supports synchronized input and output.
_SC_TIMERS
A Boolean value indicating whether or not the system supports timers.
_SC_ARG_MAX
The maximum combined size, in bytes, of argv and envp.
_SC_CHILD_MAX
The maxmimum number of processes allowed to an individual user ID. This is often called NPROC on older systems.
_SC_CLK_TCK
The number of clicks per second of the system clock. This is often called HZ on older systems.
_SC_NGROUPS_MAX
The maximum number of simultaneous groups a process may belong to. This is often called NGROUPS_MAX on older systems.
_SC_OPEN_MAX
The maximum number of open files per process. This is often called NOFILE on older systems.
_SC_STREAM_MAX
The maximum number of open streams per process.
_SC_TIMER_MAX
The maximum number of timers per process.
_SC_MQ_OPEN_MAX
The maximum number of open message queue descriptors per process.
_SC_SEM_NSEMS_MAX
The maximum number of semaphores per process.
_SC_SIGQUEUE_MAX
The maximum number of queued signals that a process may send and have pending at the receiver(s) at any time.
_SC_LOGNAME_MAX
The maximum number of characters in a login name.
_SC_PASS_MAX
The maximum number of significant characters in a password.
_SC_TZNAME_MAX
The maximum length of a time zone name.
_SC_NPROCESSORS_CONF
The number of processors configured into the system.
_SC_NPROCESSORS_ONLN
The number of processors online.
_SC_PAGESIZE
The system memory page size. This is not necessarily the same as the hardware memory page size.
_SC_PHYS_PAGES
The total number of pages of physical memory in the system.
_SC_AVPHYS_PAGES
The number of pages of physical memory not currently in use by the system.
_SC_AIO_LISTIO_MAX
The maximum number of I/O operations in a single list I/O call supported by the system.
_SC_AIO_MAX
The maximum number of outstanding asynchronous I/O operations supported by the system.
_SC_AIO_PRIO_DELTA_MAX
The maximum amount by which a process can decrease its asynchronous I/O priority level from its own scheduling priority.
_SC_DELAYTIMER_MAX
The maximum number of timer expiration overruns.
_SC_MQ_PRIO_MAX
The maximum number of message priorities supported by the system.
_SC_RTSIG_MAX
The maximum number of real-time signals reserved for application use in this implementation.
_SC_SIGRT_MIN
The lowest-numbered real-time signal available for application use.
_SC_SIGRT_MAX
The highest-numbered real-time signal available for application use.
_SC_SEM_VALUE_MAX
The maximum value for a sempahore.
The pathconf function returns the current value of a configurable limit or option associated with the file or directory named in path. The fpathconf function returns the same information, but about the file referenced by the open file descriptor  fd. Both functions return -1 if an error occurs.
The legal values for name and their meanings are:
_PC_LINK_MAX
The maximum number of links to a single file or directory. If path or  fd refer to a directory, the value returned applies to the directory itself.
_PC_MAX_CANON
The maximum number of bytes in a line of input from a terminal. If path or fd do not refer to a terminal device, the return value is meaningless.
_PC_MAX_INPUT
The maximum number of bytes in a terminal input queue. If path or  fd do not refer to a terminal device, the return value is meaningless.
_PC_NAME_MAX
The maxmimum number of bytes in a filename. If  path or  fd do not refer to a directory, the return value is meaningless. Otherwise, the return value applies to the filenames within the directory.
_PC_PATH_MAX
The maximum number of characters in a pathname. If path or  fd do not refer to a directory, the return value is meaningless. Otherwise, the value returned is the maximum length of a relative pathname when the specified directory is the working directory.
_PC_PIPE_BUF
The maximum number of bytes that are atomic in a write to a pipe or FIFO. If  path or  fd refer to a pipe or FIFO, the return value applies to the pipe or FIFO. If  path or  fd refer to a directory, the return value applies to any FIFOs that exist or can be created in that directory. If  path or  fd refer to any other type of file, the value returned is meaningless.
_PC_CHOWN_RESTRICTED
A Boolean value indicating whether or not unprivileged users may use the chown system call to change the ownership of their files. If  path or  fd refer to a directory, the returned value applies to any files, other than directories, that exist or can be created within that directory.
_PC_NO_TRUNC
A Boolean value indicating whether or not pathnames whose components are longer than _PC_NAME_MAX will generate an error. If path or fd do not refer to a directory, the return value is meaningless. Otherwise, the return value applies to the filenames within the directory.
_PC_VDISABLE
This value can be used to disable special terminal characters (see Chapter 12, Terminals) such as the interrupt character or the erase character. If  path or  fd do not refer to a terminal device, the return value is meaningless.
_PC_ASYNC_IO
A Boolean value indicating whether or not ansynchronous input and output may be performed on this file. If  path or  fd do not refer to a terminal device, the return value is meaningless.
_PC_PRIO_IO
A Boolean value indicating whether or not prioritized input and output may be performed on this file. If  path or  fd do not refer to a terminal device, the return value is meaningless.
_PC_SYNC_IO
Indicate whether or not synchronous input and output may be performed on this file. If  path or  fd refer to a directory, the return value applies to the directory itself.
Porting Notes
BSD systems, because they predate POSIX, do not offer the functions described in this section. Instead, most of their configuration parameters are stored in include files. However, two functions are available:
    int getdtablesize(void);
    int getpagesize(void);
The getdtablesize function returns the number of file descriptors available to the process; this is like the _SC_OPEN_MAX option to sysconf. The getpagesize function returns the system page size (not necessarily the same as the hardware page size); this is like the _SC_PAGESIZE option to sysconf.

Previous SectionNext Section
Books24x7.com, Inc © 2000 –  Feedback