<chapter id="concepts-2"><title>Resource Management
in the Solaris Operating System</title><highlights><para>The purpose of this manual is to help developers who are writing either
utility applications for managing computer resources or self-monitoring applications
that can check their own usage and adjust accordingly. This chapter provides
an introduction to resource management in the Solaris Operating System (OS).
The following topics are included:</para><itemizedlist><listitem><para><olink targetptr="concepts-3" remap="internal">Understanding Resource Management
in the Solaris OS</olink></para>
</listitem><listitem><para><olink targetptr="concepts-6" remap="internal">Writing Resource Management
Applications</olink></para>
</listitem>
</itemizedlist>
</highlights><sect1 id="concepts-3"><title>Understanding Resource Management in the Solaris
OS</title><para>The main concept behind resource management is that workloads on a server
need to be balanced for the system to work efficiently. Without good resource
management, faulty runaway workloads can bring progress to a halt, causing
unnecessary delays to priority jobs. An additional benefit is that efficient
resource management enables organizations to economize by consolidating servers.
To enable the management of resources, the Solaris OS provides a structure
for organizing workloads and resources, and provides controls for defining
the quantity of resources that a particular unit of workload can consume.
For an in-depth discussion of resource management from the system administrator's
viewpoint, see <olink targetdoc="sysadrm" targetptr="rmintro-1" remap="external">Chapter 1, <citetitle remap="chapter">Introduction to Solaris Resource Manager,</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink>.</para><sect2 id="gackx"><title>Workload Organization</title><para>The basic unit of workload is the <emphasis>process</emphasis>. Process
IDs (PIDs) are numbered sequentially throughout the system. By default, each
user is assigned by the system administrator to a <emphasis>project</emphasis>,
which is a network&ndash;wide administrative identifier. Each successful login
to a project creates a new <emphasis>task</emphasis>, which is a grouping
mechanism for processes. A task contains the login process as well as subsequent
child processes. </para><para>For more information on projects and tasks, see <olink targetdoc="sysadrm" targetptr="rmtaskproj-1" remap="external">Chapter 2, <citetitle remap="chapter">Projects and Tasks (Overview),</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink> for
the system administrator's perspective or <olink targetptr="tasks-3" remap="internal">Chapter&nbsp;2,
Projects and Tasks</olink> for the developer's point of view.</para><para>Processes can optionally be grouped into <emphasis>non-global zones</emphasis>,
which are set up by system administrators for security purposes and to isolate
processes. A zone can be thought of as a box in which one or more applications
run isolated from all other applications on the system. Non-global zones are
discussed thoroughly in <olink targetdoc="sysadrm" targetptr="zone" remap="external">Part&nbsp;II, <citetitle remap="chapter">Zones,</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink>.
To learn more about special precautions for writing resource management applications
that run in zones, see <olink targetptr="fquzd" remap="internal">Chapter&nbsp;7, Design Considerations
for Resource Management Applications in Solaris Zones</olink></para>
</sect2><sect2 id="gacky"><title>Resource Organization</title><para>The system administrator can assign workloads to specific CPUs or defined
groups of CPUs in the system. CPUs can be grouped into <emphasis>processor
sets</emphasis>, otherwise known as <emphasis>psets</emphasis>. A <literal>pset</literal> in
turn can be coupled with one or more thread scheduling classes, which define
CPU priorities, into a <emphasis>resource pool</emphasis>. Resource pools
provide a convenient mechanism for a system administrator to make system resources
available to users. <olink targetdoc="sysadrm" targetptr="rmpool-1" remap="external">Chapter 12, <citetitle remap="chapter">Resource Pools (Overview),</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink> covers resource pools for system administrators.
Programming considerations are described in <olink targetptr="resource-pools-5" remap="internal">Chapter&nbsp;6,
Resource Pools</olink>.</para><para>The following diagram illustrates how workload and computer resources
are organized in the Solaris OS.</para><figure id="fxxtf"><title>Workload and Resource Organization in the Solaris
Operating System</title><mediaobject><imageobject><imagedata entityref="overview.resmgt"/>
</imageobject><textobject><simpara>Diagram provides an example of how workloads and resources
are organized in a system.</simpara>
</textobject>
</mediaobject>
</figure>
</sect2><sect2 id="gaclj"><title>Resource Controls</title><para>Simply assigning a workload unit to a resource unit is insufficient
for managing the quantity of resources that users consume. To manage resources,
the Solaris OS provides a set of flags, actions, and signals that are referred
to collectively as <emphasis>resource controls</emphasis>. Resource controls
are stored in the <filename>/etc/project</filename> file or in a zone's configuration
through the <command>zonecfg</command> command described in <olink targetdoc="refman1m" targetptr="zonecfg-1m" remap="external"><citerefentry><refentrytitle>zonecfg</refentrytitle><manvolnum>1M</manvolnum></citerefentry></olink>. The Fair Share Scheduler
(FSS), for example, can allocate shares of CPU resources among workloads based
on the specified importance factor for the workloads. With these resource
controls, a system administrator can set privilege levels and limit definitions
for a specific zone, project, task, or process. To learn how a system administrator
uses resource controls, see <olink targetdoc="sysadrm" targetptr="rmctrls-1" remap="external">Chapter 6, <citetitle remap="chapter">Resource Controls (Overview),</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink>. For programming considerations, see <olink targetptr="resource-ctrls-8" remap="internal">Chapter&nbsp;5, Resource Controls</olink>.</para>
</sect2><sect2 id="gaclg"><title>Extended Accounting Facility</title><para>In addition to the workload and resource organization, the Solaris OS
provides the <emphasis>extended accounting facility</emphasis> for monitoring
and recording system resource usage. The extended accounting facility provides
system administrators with a detailed set of resource consumption statistics
on processes and tasks.</para><para>The facility is described in depth for system administrators in <olink targetdoc="sysadrm" targetptr="rmacct-1" remap="external">Chapter 4, <citetitle remap="chapter">Extended Accounting (Overview),</citetitle> in <citetitle remap="book">System Administration Guide: Solaris Containers-Resource Management and Solaris Zones</citetitle></olink>.
The Solaris OS provides developers with both a C interface and a Perl interface
to the extended accounting facility. Refer to <olink targetptr="ext-acctg-11" remap="internal">Chapter&nbsp;3,
Using the C Interface to Extended Accounting</olink> for the C interface or <olink targetptr="extacctg-perl-1" remap="internal">Chapter&nbsp;4, Using the Perl Interface to Extended
Accounting</olink> for the Perl interface.</para>
</sect2>
</sect1><sect1 id="concepts-6"><title>Writing Resource Management Applications</title><para>This manual focuses on resource management from the developer's point
of view and presents information for writing the following kinds of applications:</para><itemizedlist><listitem><para>Resource administration applications &ndash; Utilities to
perform such tasks as allocating resources, creating partitions, and scheduling
jobs.</para>
</listitem><listitem><para>Resource monitoring applications &ndash; Applications that
check system statistics through <literal>kstats</literal> to determine resource
usage by systems, workloads, processes, and users.</para>
</listitem><listitem><para>Resource accounting utilities &ndash; Applications that provide
accounting information for analysis, billing, and capacity planning.</para>
</listitem><listitem><para>Self-adjusting applications &ndash; Applications that can
determine their use of resources and can adjust consumption as necessary.</para>
</listitem>
</itemizedlist>
</sect1>
</chapter>