2009-08-04

Chapter 11: System Limits and Options

Each Unix implementation sets limits on various system features and resources, and provides--or chooses not to provide--options defined in various standards. Examples include the following:
  • How many files can a process hold open at one time?
  • Does the system support realtime signals?
  • What is the biggest value that can be stored in a variable of type int?
  • How big an argument list can a program have?
  • What is the maximum length of a pathname?
While we could hard-code assumed limits and options into an application, this reduces portability, since limits and options may vary:
  • Across Unix implementations: Although limits and options may be fixed on an individual implementation, they can vary from one Unix implementation to another. The maximum value that can be stored in an int is an example of such a limit.
  • At run time on a particular implementation: The kernel may have been reconfigured to change a limit, for example. Alternatively, the application may have been com-piled on one system, but run on another system with different limits and options.
  • From one file system to another: For example, traditional System V file systems allow a filename to be up to 14 bytes, while traditional BSD file systems and most native Linux file systems allow filenames of up to 255 bytes.
Since these system limits affect what an application may do, a portable application needs ways of determining their values and whether various system options are supported. The C programming language standards and SUSv3 provide two principal avenues for an application to obtain such information:
  • Some limits and options can be determined at compile time. For example, the maximum value of an int is determined by the hardware architecture and compiler design choices. Such limits can be recorded in header files.
  • Other limits and options may vary at run time. For such cases, SUSv3 defines three functions--sysconf(), pathconf(), and fpathconf()--that an application can call to check these implementation limits and options.
SUSv3 specifies a range of limits that a conforming implementation may enforce, as well as a set of options, each of which may or may not be provided by a particular system. We provide an overview of these limits and options in this chapter. We also describe the various SUSv3-specified constants and functions that an application can use to obtain information about system limits and options. Using these techniques eases the task of writing applications that are portable to other Unix implementations.

11 System Limits and Options
11.1 System Limits
11.2 Retrieving System Limits (and Options) at Run Time
11.3 Retrieving File-related Limits (and Options) at Run Time
11.4 Indeterminate Limits
11.5 System Options
11.6 Summary
11.7 Exercises

No comments:

Post a Comment