Introduction to Operating Systems: A Hands-On Approach Using the OpenSolaris Project

Instructor Guide

Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054 U.S.A.
Part No: 819–5580–12 August, 2007

Copyright 2007 Sun Microsystems, Inc.

4150 Network Circle, Santa Clara, CA 95054 U.S.A.

All rights reserved.

Sun Microsystems, Inc. has intellectual property rights relating to technology embodied in the product that is described in this document. In particular, and without limitation, these intellectual property rights may include one or more U.S. patents or pending patent applications in the U.S. and in other countries. U.S. Government Rights – Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. This distribution may include materials developed by third parties. Parts of the product may be derived from Berkeley BSD systems, licensed from the University of California. UNIX is a registered trademark in the U.S. and other countries, exclusively licensed through X/Open Company, Ltd. Sun, Sun Microsystems, the Sun logo, the Solaris logo, the Java Coffee Cup logo, docs.sun.com, Java, and Solaris are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. in the U.S. and other countries. Products bearing SPARC trademarks are based upon an architecture developed by Sun Microsystems, Inc. The OPEN LOOK and SunTM Graphical User Interface was developed by Sun Microsystems, Inc. for its users and licensees. Sun acknowledges the pioneering efforts of Xerox in researching and developing the concept of visual or graphical user interfaces for the computer industry. Sun holds a non-exclusive license from Xerox to the Xerox Graphical User Interface, which license also covers Sun's licensees who implement OPEN LOOK GUIs and otherwise comply with Sun's written license agreements. Products covered by and information contained in this publication are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical or biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited. DOCUMENTATION IS PROVIDED “AS IS” AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID. Copyright 2007 Sun Microsystems, Inc. 4150 Network Circle, Santa Clara, CA 95054 U.S.A. Tous droits réservés.

Sun Microsystems, Inc. détient les droits de propriété intellectuelle relatifs à la technologie incorporée dans le produit qui est décrit dans ce document. En particulier, et ce sans limitation, ces droits de propriété intellectuelle peuvent inclure un ou plusieurs brevets américains ou des applications de brevet en attente aux Etats-Unis et dans d'autres pays. Cette distribution peut comprendre des composants développés par des tierces personnes. Certaines composants de ce produit peuvent être dérivées du logiciel Berkeley BSD, licenciés par l'Université de Californie. UNIX est une marque déposée aux Etats-Unis et dans d'autres pays; elle est licenciée exclusivement par X/Open Company, Ltd. Sun, Sun Microsystems, le logo Sun, le logo Solaris, le logo Java Coffee Cup, docs.sun.com, Java et Solaris sont des marques de fabrique ou des marques déposées de Sun Microsystems, Inc. aux Etats-Unis et dans d'autres pays. Toutes les marques SPARC sont utilisées sous licence et sont des marques de fabrique ou des marques déposées de SPARC International, Inc. aux Etats-Unis et dans d'autres pays. Les produits portant les marques SPARC sont basés sur une architecture développée par Sun Microsystems, Inc. L'interface d'utilisation graphique OPEN LOOK et Sun a été développée par Sun Microsystems, Inc. pour ses utilisateurs et licenciés. Sun reconnaît les efforts de pionniers de Xerox pour la recherche et le développement du concept des interfaces d'utilisation visuelle ou graphique pour l'industrie de l'informatique. Sun détient une licence non exclusive de Xerox sur l'interface d'utilisation graphique Xerox, cette licence couvrant également les licenciés de Sun qui mettent en place l'interface d'utilisation graphique OPEN LOOK et qui, en outre, se conforment aux licences écrites de Sun. Les produits qui font l'objet de cette publication et les informations qu'il contient sont régis par la legislation américaine en matière de contrôle des exportations et peuvent être soumis au droit d'autres pays dans le domaine des exportations et importations. Les utilisations finales, ou utilisateurs finaux, pour des armes nucléaires, des missiles, des armes chimiques ou biologiques ou pour le nucléaire maritime, directement ou indirectement, sont strictement interdites. Les exportations ou réexportations vers des pays sous embargo des Etats-Unis, ou vers des entités figurant sur les listes d'exclusion d'exportation américaines, y compris, mais de manière non exclusive, la liste de personnes qui font objet d'un ordre de ne pas participer, d'une façon directe ou indirecte, aux exportations des produits ou des services qui sont régis par la legislation américaine en matière de contrôle des exportations et la liste de ressortissants spécifiquement designés, sont rigoureusement interdites. LA DOCUMENTATION EST FOURNIE "EN L'ETAT" ET TOUTES AUTRES CONDITIONS, DECLARATIONS ET GARANTIES EXPRESSES OU TACITES SONT FORMELLEMENT EXCLUES, DANS LA MESURE AUTORISEE PAR LA LOI APPLICABLE, Y COMPRIS NOTAMMENT TOUTE GARANTIE IMPLICITE RELATIVE A LA QUALITE MARCHANDE, A L'APTITUDE A UNE UTILISATION PARTICULIERE OU A L'ABSENCE DE CONTREFACON.

070816@18135

Instructor Notes

Contents

1

What is the OpenSolaris Project? ............................................................................................. 7 Country Portals ............................................................................................................................9 Web Resources for OpenSolaris ..............................................................................................10 Discussions .................................................................................................................................10 Communities .............................................................................................................................10 Projects ........................................................................................................................................11 Source Repositories ...................................................................................................................12 OpenGrok ...................................................................................................................................12

2

OpenSolaris Advocacy .............................................................................................................13 Why Use OpenSolaris? ..............................................................................................................14 Price .............................................................................................................................................14 Innovative Core Features ..........................................................................................................14 Backward Compatibility ...........................................................................................................15 Hardware Platform Neutrality .................................................................................................15 Development Tools ...................................................................................................................16 Acknowledgments .....................................................................................................................17

3

Planning the OpenSolaris Environment ............................................................................... 19 Development Environment Configuration ............................................................................20 Networking .................................................................................................................................21 Network Auto-Configuration Daemon ..................................................................................23 Zone Overview ...........................................................................................................................24 Zones Administration ...............................................................................................................25 Getting Started With Zones Administration ..................................................................26
3

Contents

Instructor Notes
Web Server Virtualization With Zones ...................................................................................29 Creating Non-Global Zones ..............................................................................................30 Creating ZFS Storage Pools and File Systems .........................................................................34 Creating a Mirrored ZFS Storage Pool ....................................................................................35 Creating ZFS File Systems as Home Directories ....................................................................37 Creating a RAID-Z Configuration ..........................................................................................40

4

Userland Consolidations .........................................................................................................43 Userland Consolidations and Descriptions ...........................................................................44

5

Core Features of the Solaris OS ............................................................................................... 45 Development Process and Coding Style .................................................................................46 Overview .....................................................................................................................................49 FireEngine ..................................................................................................................................49 Least Privilege ............................................................................................................................51 Packet Filtering ..........................................................................................................................52 Zones ...........................................................................................................................................54 Branded Zones (BrandZ) ..........................................................................................................55 Zones Networking .....................................................................................................................56 Predictive Self-Healing ..............................................................................................................58 Dynamic Tracing (DTrace) ......................................................................................................59 Modular Debugger (MDB) .......................................................................................................60 ZFS File System ..........................................................................................................................60 Services Management Facility (SMF) ......................................................................................61

6

Programming Concepts ...........................................................................................................63 Process and System Management ............................................................................................64 Threaded Programming ...........................................................................................................64 CPU Scheduling .........................................................................................................................67 Kernel Overview ........................................................................................................................69 Process Debugging ....................................................................................................................72
Contents 4

Contents

Instructor Notes

7

Getting Started With DTrace ................................................................................................... 75 Enabling Simple DTrace Probes ..............................................................................................76 Listing Traceable Probes ...........................................................................................................79 Programming in D .....................................................................................................................82

8

Debugging Applications With DTrace ................................................................................... 85 Enabling User Mode Probes .....................................................................................................86 DTracing Applications ......................................................................................................87

9

Debugging C++ Applications With DTrace ........................................................................... 91 Using DTrace to Profile and Debug A C++ Program ............................................................92

10

Managing Memory with DTrace and MDB .......................................................................... 103 Software Memory Management ............................................................................................104 Using DTrace and MDB to Examine Virtual Memory .......................................................105

11

Debugging Drivers With DTrace ........................................................................................... 117 Porting the smbfs Driver from Linux to the Solaris OS ......................................................118

A

OpenSolaris Resources ..........................................................................................................127

5

6

1
Objectives

Instructor Notes
1

M O D U L E

What is the OpenSolaris Project?

The objective of this course is to learn about operating system computing by using the SolarisTM Operating System source code that is freely available through the OpenSolaris project.
Tip – To receive a free OpenSolaris Starter Kit that includes training materials, source code, and developer tools, register online at http://get.opensolaris.org.

We'll start by showing you the user groups, portals, and documentation you will use to get started with UNIX® computing. Next, we'll show you where to go to access the code, communities, discussions, projects, and source browser for the OpenSolaris project. Then, we'll give you steps to configure zones, ZFS, networking, and the environment. Finally, we'll demonstrate debugging processes, applications, page faults, and device drivers with DTrace in the lab exercises. The OpenSolaris project was launched on June 14, 2005 to create a community development effort using the Solaris OS code as a starting point. It is a nexus for a community development effort where contributors from Sun and elsewhere can collaborate on developing and improving operating system technology. The OpenSolaris source code will find a variety of uses, including being the basis for future versions of the Solaris OS product, other operating system projects,
7

What is the OpenSolaris Project?

Instructor Notes

third-party products and distributions of interest to the community. The OpenSolaris project is currently sponsored by Sun Microsystems, Inc. In the first two years, over 60,000 participants have become registered members. The engineering community is continually growing and changing to meet the needs of developers, system administrators, and end users of the Solaris Operating System. Teaching with the OpenSolaris project provides the following advantages over instructional operating systems:

Access to code for the revolutionary technologies in the Solaris 10 operating system Access to code for a commercial OS that is used in many environments and that scales to large systems Superior observability and debugging tools Hardware platform support including SPARC, x86 and x64 architectures Leadership on 64–bit computing $0.00 for infinite right-to-use Free, exciting, innovative, complete, seamless, and rock-solid code base Availability under the OSI-approved Common Development and Distribution License (CDDL) allows royalty-free use, modification, and derived works

■ ■ ■ ■ ■ ■

Module 1 • What is the OpenSolaris Project?

8

Country Portals

Instructor Notes

Country Portals
The Internationalization and Localization Community is helping to translate the OpenSolaris English web site into many languages. So far, eight country portals are under development, as follows:
■ ■ ■ ■ ■ ■ ■

India portal – http://in.opensolaris.org China portal – http://cn.opensolaris.org Japan portal – http://jp.opensolaris.org Poland portal – http://pl.opensolaris.org France portal – http://fr.opensolaris.org Brazil Portal – http://opensolaris.org/os/project/br Spanish Portal – http://opensolaris.org/os/project/es

Portals for Germany, Russia, Czech Republic, Spain, Korea, and Mexico are planned. See the OpenSolaris Portals project to get involved, or chat on one of the seven OpenSolaris chat rooms using IRC at irc.freenode.net. See http://opensolaris.org/os/chat/

Module 1 • What is the OpenSolaris Project?

9

Web Resources for OpenSolaris

Instructor Notes

Web Resources for OpenSolaris
You can download the OpenSolaris source, view the license terms and access instructions for building source and installing the pre-built archives at: http://www.opensolaris.org/os/downloads. The icons in the upper-right of the OpenSolaris web pages link you to discussions, communities, projects, downloads, and source browser resources. In addition, the OpenSolaris web site provides search across all of the site content and aggregated blogs.

Discussions
Discussions provide you with access to the experts who are working on new open source technologies. Discussions also provide an archive of previous conversations that you can reference for answers to your questions. See http://www.opensolaris.org/os/discussions for the complete list of forums to which you can subscribe.

Communities
Communities provide connections to other participants with similar interests in the OpenSolaris project. Communities form around interest groups, technologies, support, tools, and user groups, for example:
Academic and Research DTrace ZFS Networking Zones Documentation Device Drivers http://www.opensolaris.org/os/community/edu

http://www.opensolaris.org/os/community/dtrace http://www.opensolaris.org/os/community/zfs http://www.opensolaris.org/os/community/networking http://www.opensolaris.org/os/community/zones http://www.opensolaris.org/os/community/documentation http://www.opensolaris.org/os/community/device_drivers

Module 1 • What is the OpenSolaris Project?

10

Web Resources for OpenSolaris

Instructor Notes
➊ Sun intends to have non-Sun contributors and wants to foster collaborations across industrial and academic affiliations. ➋ The OpenSolaris project will empower and expand the existing Solaris community. ➌ The OpenSolaris project will allow for the creation of entirely new communities. ➍ Projects give you the opportunity to share files, disk space, and an email alias. ➎ You can collaborate with other engineers across the globe to work on a new technology or an improvement to existing technology.

Tools Advocates Security Performance Storage

http://www.opensolaris.org/os/community/tools http://www.opensolaris.org/os/community/advocacy http://www.opensolaris.org/os/community/security http://www.opensolaris.org/os/community/performance http://www.opensolaris.org/os/community/storage

System Administrators http://www.opensolaris.org/os/community/sysadmin

➊–➌

These are only a few of 30 communities actively working on OpenSolaris. See http://www.opensolaris.org/os/communities for the complete list.

Projects
Projects hosted on the http://www.opensolaris.org/ web site are collaborative efforts that produce objects such as code changes, documents, graphics, or joint-authored products. Projects have code repositories and committers and may live within a community or independently. New projects are initiated by participants by request on the discussions. Projects that are submitted and accepted by at least one other interested participant in the sponsoring community are given space on the projects page to get started. See http://www.opensolaris.org/os/projects for the current list of new projects. ➍–➎
Chime Visualization Tool for DTrace Google Summer of Code Indiana OpenGrok Programming Contest Starter Kit Solaris iSCSI Target http://www.opensolaris.org/os/project/dtrace-chime

http://www.opensolaris.org/os/project/powerPC

http://www.opensolaris.org/os/project/indiana http://www.opensolaris.org/os/project/opengrok http://www.opensolaris.org/os/project/contest http://www.opensolaris.org/os/project/starterkit http://www.opensolaris.org/os/project/iscsitgt

Module 1 • What is the OpenSolaris Project?

11

Web Resources for OpenSolaris

Instructor Notes

Source Repositories
Centralized and distributed source repositories are hosted on the opensolaris.org web site. The centralized source management model uses the Subversion (SVN) source control management program. Repositories managed in a distributed fashion use the Mercurial (hg) source control management program. The creation of a source repository on opensolaris.org is completed by a Project Leader by using the Project web pages. Developers with commit rights access repositories through their opensolaris.org accounts. Commit rights are managed by Project Leaders. If you need an account, you may sign up to acquire one. Additionally, you will have to provide a Secure Shell (SSH) public key. Refer to the tools community for the most recent source control information, downloads and instructions http://opensolaris.org/os/community/tools

OpenGrok
OpenGrokTM is the fast and usable source code search and cross reference engine used in OpenSolaris. See http://cvs.opensolaris.org/source to try it out! The first project to be hosted on opensolaris.org was OpenGrok. See http://www.opensolaris.org/os/project/opengrok to find out about the ongoing development project. Take an online tour of the source and you'll discover cleanly written, extensively commented code that reads like a book. If you're interested in working on an OpenSolaris project, you can download the complete codebase. If you just need to know how some features work in the Solaris OS, the source code browser provides a convenient alternative. OpenGrok understands various program file formats and version control histories like SCCS, RCS, and CVS, so that you can better understand the open source.

Module 1 • What is the OpenSolaris Project?

12

M O D U L E

OpenSolaris Advocacy

2

Instructor Notes
2

Objectives
The Advocates Community exists to help people around the world get involved in the OpenSolaris Community. We welcome participation from people of all languages and cultures and people with all levels of technical and non-technical skills. Everyone has something to contribute. See http://opensolaris.org/os/community/advocacy/ In the Advocates community you will find independent user group projects, presentations, news, articles, blogs, technical & non-technical content, videos and podcasts, events and conferences, community metrics, swag, badges, buttons, and a variety of other promotional projects.

13

Why Use OpenSolaris?

Instructor Notes

Why Use OpenSolaris?
This section describes practical reasons to consider choosing to use OpenSolaris as your development platform.

Price
Since the availability of the Solaris 10 Operating System in January 2005, its popularity has exploded. As of July 2007, in excess of 8.7 million copies were registered, more than all of the previous versions of the Solaris OS combined. Further fueling this frenzy was the release of OpenSolaris in June 2005. Given this surge in the number of users, more developers (commercial and open-source alike) are seeing the Solaris operating system as a viable target for their software. One of the reasons the Solaris OS enjoyed a huge popularity boost was its price: $0 for everyone, for any use (commercial and non-commercial), on any machine (using both SPARC and x86 platforms). Another reason was Sun's promise (and delivering on that promise) of making the Solaris source code available under an OSI-approved open-source license, the Common Development and Distribution License (CDDL).

Innovative Core Features
However, the most important reason for the popularity of the Solaris OS is arguably the vast wealth of features it offers. In no particular order, these include the following:

Solaris Zones– Provide the ability to partition a machine into numerous virtual machines, each of which is isolated from the others. DTrace – A comprehensive dynamic tracing tool for investigating system behavior, safely on production machines. New IP stack– Providing vastly increased performance. ZFS– A 128-bit, state-of-the-art file system, with end-to-end error checking and correction, a simple command-line interface, and virtually limitless storage capacity.
14

■ ■

Module 2 • OpenSolaris Advocacy

Why Use OpenSolaris?

Instructor Notes

Backward Compatibility
All of these features build on what long-time Solaris OS users have come to expect: rock-solid stability, huge scalability, high performance, and guaranteed backwards compatibility. The last of these is especially important to commercial software developers, because maintenance is usually the largest expense associated with a piece of software. With its backwards compatibility guarantee, software vendors know that (provided they use only published APIs) software built for Solaris N will run correctly on Solaris N+1 and subsequent versions. (Contrast this with some other operating systems, where incompatible changes to system components -- for example, libraries -- are made without regard to the effect on applications. The net effect is application breakage, resulting in increased maintenance costs and frustration for application vendors and users.)

Hardware Platform Neutrality
The preceding paragraphs give some reasons why we should develop for the Solaris OS, but there are additional reasons to develop on the Solaris platform. One is that Solaris is a multi-OSOplatform OS, supporting both SPARC and x86 architectures (a community-driven port to Power is in the works, too). Although there was an issue a few years ago with the Solaris OS for x86 platforms, the fact that Sun has introduced a range of AMD-based servers and workstations demonstrates the company's commitment to x86 technology. From the developer's perspective, the Solaris versions for SPARC and x86 platforms have the same feature set and APIs. This means that developers can concentrate on the other issues endemic to cross-platform development, like CPU endianness. The SPARC platform is big-endian and x86 is little-endian, so an application that is developed and tested on the Solaris platform has a high probability of being free from endian-related problems. The Solaris OS also supports both 32-bit and 64-bit applications on both platforms, thus helping to eliminate bugs due to assumptions about word size. Perhaps the most compelling reason to develop software on the Solaris OS is the wealth of professional-grade development tools available for it.
Module 2 • OpenSolaris Advocacy 15

Why Use OpenSolaris?

Instructor Notes

Development Tools
One of the most important features of an OS from a developer's point of view is the variety and quality of the development tools available. Compilers and debuggers are the most obvious examples of these tools, but other examples include code checkers (to ensure that our code is free from subtle errors the compiler might not catch), cross-reference generators (to see which functions reference other functions and variables), and performance analyzers. The Sun Studio suite is the product of choice for Solaris OS developers. Available as a free download from the http://developers.sun.com web site, Sun Studio software is a collection of professional-grade compilers and tools. It includes C, C++, and FORTRAN compilers, code analysis tools, an integrated development environment (IDE), the dbx source-level debugger, and editors. Other tools included with Studio software are cscope (an interactive source browser), ctrace (a tool to generate a self-tracing version of our programs), cxref (a C program cross-referencer), dmake (for distributed parallel makes), and lint (the C program checker). The Solaris OS ships with the GNU C compiler, gcc, and its companion source-level debugger, gdb. The Solaris OS also ships with the very powerful modular debugger, mdb. However, mdb is not a source-level debugger. It is most useful when we are debugging kernel code, or performing post-mortem analysis on programs for which the source is not available. See the Solaris Modular Debugger Guide and Solaris Performance and Tools by McDougall, Mauro, and Gregg for more information about mdb.

Module 2 • OpenSolaris Advocacy

16

Acknowledgments

Instructor Notes

Acknowledgments
The following members of the OpenSolaris Community reviewed and provided feedback on this document:
■ ■ ■ ■ ■ ■ ■ ■

Boyd Adamson Pradhap Devarajan Alan Coopersmith Brian Gupta Rainer Heilke Eric Lowe Ben Rockwood Cindy Swearingen

The following OpenSolaris community members provided excellent new content:
■ ■ ■ ■ ■ ■

Dong-Hai Han Narayana Janga Shivani Khosa Rich Teer Sunay Tripathi Yifan Xu

Many thanks also go to Steven Cogorno, David Comay, Teresa Giacomini, Stephen Hahn, Patrick Finch, and Sue Weber for their work to make the initial version possible. To participate in future reviews of this document, use the instructions at the following URL: http://www.opensolaris.org/os/community/documentation/reviews

Module 2 • OpenSolaris Advocacy

17

18

M O D U L E

Planning the OpenSolaris Environment

3

Instructor Notes
3

Objectives
The objective of this module is to understand the system requirements, support information, and documentation available for the OpenSolaris project installation and configuration.

Additional Resources

Solaris Express Developer Edition Installation Guide: Laptop Installations. Sun Microsystems, Inc., 2007. Resources for Running Solaris OS on a Laptop: http://www.sun.com/ bigadmin/features/articles/laptop_resources.html

OpenSolaris Laptop Community: http://opensolaris.org/os/community/laptop OpenSolaris Starter Kit: http://opensolaris.org/os/project/starterkit System Administration Guide: IP Services, Sun Microsystems, Inc., 2007 OpenSolaris Networking Community at http://www.opensolaris.org/os/community/networking ZFS Administration Guide and man pages: http://opensolaris.org/os/community/zfs/docs

■ ■ ■

19

Development Environment Configuration

Instructor Notes
➊ The OpenSolaris 64-bit kernel is seamless: 32-bit applications run unmodified on it. ➋ One may alternate between the 32-bit and 64-bit kernel with only a reboot. ➌ All of the architectures supported by the OpenSolaris project are built from the source code basis. The 64-bit kernel isn't a separate version or variant of the system. ➍ 32-bit and 64-bit applications and libraries coexist seamlessly.

Development Environment Configuration
There is no substitute for hands-on experience with operating system code and direct access to kernel modules. The unique challenges of kernel development and access to root privileges for a system are made simpler by the tools, forums, and documentation provided for the OpenSolaris project.
Tip – To receive an OpenSolaris Starter Kit that includes training materials, source code, and developer tools, go to http://get.opensolaris.org.

➊–➍

Consider the following features of OpenSolaris as you plan your development environment:
TABLE 3–1

Configurable Lab Component Support
Support From the OpenSolaris Project

Configurable Component

Hardware

OpenSolaris supports systems that use the SPARC® and x86 families of processor architectures: UltraSPARC®, SPARC64, AMD64, Pentium, and Xeon EM64T. For supported systems, see the Solaris OS Hardware Compatibility List at http://www.sun.com/bigadmin/hcl. See http://opensolaris.org/os/downloads for detailed instructions about how to build from source. Pre-built OpenSolaris distributions are limited to the Solaris Express: Community Edition [DVD Version], Build 32 or newer, Solaris Express: Developer Edition, Nexenta, Schillix, Martux and Belenix. For the OpenSolaris kernel with the GNU user environment, try http://www.gnusolaris.org/gswiki/Download-form.

Source files Install images

BFU archives Build tools Compilers and tools

The on-bfu-DATE.PLATFORM.tar.bz2 file is provided if you are installing from pre-built archives. The SUNWonbld-DATE.PLATFORM.tar.bz2 file is provided if you build from source. Sun Studio 11 compilers and tools are freely available for use by OpenSolaris developers. See http://www.opensolaris.org/os/community/tools/sun_studio_tools/ for instructions about how to download and install the latest versions. Also, refer to http://www.opensolaris.org/os/community/tools/gcc for the gcc community.

Module 3 • Planning the OpenSolaris Environment

20

Development Environment Configuration

Instructor Notes
➊ Problem: machines are underutilized; utilization can be increased through virtualization with Zones. Each zone looks, feels, and smells like its own machine, you can even reboot them! ➋ Most other virtualization technologies virtualize at the hardware layer. ➌ Zones are a new facility in OpenSolaris that instead virtualizes at the operating system layer.

TABLE 3–1

Configurable Lab Component Support
Support From the OpenSolaris Project

(Continued)

Configurable Component

Memory/Disk Requirements

Memory requirement: 256M minimum (text installer only), 1GB recommended Memory Requirement: 768M minimum Solaris Express Developer Edition installer. Disk space requirement: 350M bytes

Virtual OS environments

Zones and Branded Zones in OpenSolaris provide protected and virtualized operating system environments within an instance of Solaris, allowing one or more processes to run in isolation from other activity on the system. OpenSolaris supports Xen, an open-source virtual machine monitor developed by the Xen team at the University of Cambridge Computer Laboratory. See http://www.opensolaris.org/os/community/xen/ for details and links to the Xen project. OpenSolaris is also a VMWareTM guest, see http://www.opensolaris.org/os/project/content for a recent article describing how to get started.

➊–➌

Refer to Module 4 for more information about how Zones and Branded Zones enable kernel and user mode development of Solaris and Linux applications without impacting developers in separate zones. Participation in the OpenSolaris project can improve overall performance across your network with the latest technologies. Your lab environment becomes self-sustaining when hosted on OpenSolaris because you are always running the latest and greatest environment, empowered to update it yourself.

Networking
The OpenSolaris project meets future networking challenges by radically improving your network performance without requiring changes to your existing applications.

Speeds application performance by about 50 percent by using an enhanced TCP/IP stack Supports many of the latest networking technologies, such as 10 Gigabit Ethernet, wireless networking, and hardware offloading
21

Module 3 • Planning the OpenSolaris Environment

Development Environment Configuration

Instructor Notes

Accommodates high-availability, streaming, and Voice over IP (VoIP) networking features through extended routing and protocol support Supports current IPv6 specifications

Find out more about ongoing networking developments from the OpenSolaris Networking Community: http://www.opensolaris.org/os/community/networking.

Module 3 • Planning the OpenSolaris Environment

22

Network Auto-Configuration Daemon

Instructor Notes

Network Auto-Configuration Daemon
The Solaris Express Developer Edition 5/07 release booting process runs the nwamd daemon. This daemon implements an alternate instance of the SMF service, svc:/network/physical, which enables automated network configuration with minimal intervention. The nwamd daemon monitors the Ethernet port and automatically enables DHCP on the appropriate IP interface. If no cable is plugged into a wired network, the nwamd daemon conducts a wireless scan and sends queries to the user for a WiFi access point to connect to. You don't need to spend extensive amounts of time manually configuring the interfaces on your systems. Automatic configuration also aids you in administration, because you can reconfigure network addresses with minimal intervention. To view your NWAM status, type the following command in a terminal window.
# svcs nwam

STATE STIME FMRI online 11:29:50 svc:/network/physical:nwam The OpenSolaris Network Auto-Magic Phase 0 page and nwamd man page contain further details, including instructions for turning off the nwamd daemon, if preferred. For more information and a link to the nwamd(1M) man page, see http://www.opensolaris.org/os/project/nwam.

Module 3 • Planning the OpenSolaris Environment

23

Zone Overview

Instructor Notes

Zone Overview
A zone can be thought of as a container in which one or more applications run isolated from all other applications on the system. Most software that runs on OpenSolaris will run unmodified in a zone. Since zones do not change the OpenSolaris Application Programming Interface (APIs) or Application Binary Interface (ABI), recompiling an application is not necessary in order to run it inside a zone.

Module 3 • Planning the OpenSolaris Environment

24

Zones Administration

Instructor Notes

Zones Administration
Zone administration consists of the following commands:

zonecfg – Creates zones, configures zones (add resources and properties). Stores the configuration in a private XML file under /etc/zones. zoneadm – Performs administrative steps for zones such as list, install, (re)boot, and halt. zlogin – Allows user to log in to the zone to perform maintenance tasks. zonename – Displays the current zone name.

■ ■

The following global scope properties are used with zones:

zonepath – Path in the global zone to the root directory under which the zone will be installed autoboot – To boot or not to boot when global zone boots pool – Resource pools to which zones should be bound Resources may include any of the following types:
■ ■

■ ■

fs – file system Inherit-pkg-dir – Directory that has its associated packages inherited from the global zone net – Network device device – Devices

■ ■

Module 3 • Planning the OpenSolaris Environment

25

Getting Started With Zones Administration

Instructor Notes

Getting Started With Zones Administration
This lab exercise will introduce you to creating zones.

Summary
This exercise uses detailed examples to help you understand the process of creating, installing, and booting a zone.
Note – This procedure does not apply to an lx branded zone.

Module 3 • Planning the OpenSolaris Environment

26

Getting Started With Zones Administration

Instructor Notes

To Create, Install, and Boot a Zone
1

Use the following example to configure your new zone:
Note – The following example uses a shared-IP stack, which is the default for a

zone.
# zonecfg -z Apache Apache: No such zone configured Use ’create’ to begin configuring a new zone. zonecfg:Apache> create zonecfg:Apache> set zonepath=/export/home/Apache zonecfg:Apache> add net zonecfg:Apache:net> set address=192.168.0.50 zonecfg:Apache:net> set physical=bge0 zonecfg:Apache:net> end zonecfg:Apache> verify zonecfg:Apache> commit zonecfg:Apache> exit 2

Use the following example to install and boot your new zone:
# zoneadm -z Apache install Preparing to install zone <Apache>. Creating list of files to copy from the global zone. Copying <6029> files to the zone. Initializing zone product registry. Determining zone package initialization order. Preparing to initialize <1038> packages on the zone. Initialized <1038> packages on zone. Zone <Apache> is initialized. Installation of these packages generated warnings: .... The file </export/home/Apache/root/var/sadm/system/logs/install_log> contains a log of the zone installation.

The necessary directories are created. The zone is ready for booting.
3

View the directories:
# ls /export/home/Apache/root bin etc home mnt tmp var dev export proc system usr
Module 3 • Planning the OpenSolaris Environment

platform sbin lib opt

27

Getting Started With Zones Administration

Instructor Notes

Packages are not reinstalled.
# /etc/mount /export/home/Apache/root/lib on /lib read only /export/home/Apache/root/platform on /platform read only /export/home/Apache/root/sbin on /sbin read only /export/home/Apache/root/usr on /usr read only /export/home/Apache/root/proc on proc read/write/setuid/nodevices/zone=Apache 4

Boot the zone.
# ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 bge0: flags=1004803<UP,BROADCAST,MULTICAST,DHCP,IPv4> mtu 1500 index 2 inet 192.168.0.4 netmask ffffff00 broadcast 192.168.0.255 ether 0:c0:9f:61:88:c9 # zoneadm -z Apache boot # ifconfig -a lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 lo0:1: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1 zone Apache inet 127.0.0.1 bge0: flags=1004803 inet 192.168.0.4 netmask ffffff00 broadcast 192.168.0.255 ether 0:c0:9f:61:88:c9 bge0:1: flags=1000803mtu 1500 index 2 zone Apache inet 192.168.0.50 netmask ffffff00 broadcast 192.168.0.255

5

Configure the zone and login:
# zlogin -C Apache [Connected to zone ’Apache’ pts/5] # ifconfig -a lo0:2: flags=2001000849 mtu 8232 index 1 inet 127.0.0.1 netmask ff000000 bge0:2: flags=1000803 inet 192.168.0.50 netmask ffffff00 broadcast 192.168.0.255 # ping -s 192.168.0.50 64 bytes from 192.168.0.50: icmp_seq=0. time=0.146 ms # exit [Connection to zone ’Apache’ pts/5 closed]

Module 3 • Planning the OpenSolaris Environment

28

Web Server Virtualization With Zones

Instructor Notes

Web Server Virtualization With Zones
Each zone has its own characteristics, for example, zonename, IP addresses, hostname, naming services, root and non-root users. By default, the OS runs in a global zone. The administrator can virtualize the execution environment by defining one or more non-global zones. Network services can be run limiting the damage possible in the event of security violation. Since zones are implemented in software, they aren't limited to granularity defined by hardware boundaries. Instead zones offer sub-CPU granularity.

Module 3 • Planning the OpenSolaris Environment

29

Creating Non-Global Zones

Instructor Notes

Creating Non-Global Zones
This lab exercise will demonstrate how to support two different sets of web server user groups on one physical host.

Summary
Simultaneous access to both web servers will be configured so that each web server and system will be protected should one become compromised.

Module 3 • Planning the OpenSolaris Environment

30

Creating Non-Global Zones

Instructor Notes

Creating Two Non-Global Zones
1

Create non-global zone Apache1:
# zonecfg -z Apache1 info zonepath: /export/home/Apache1 autoboot: false pool: inherit-pkg-dir: dir: /lib inherit-pkg-dir: dir: /platform inherit-pkg-dir: dir: /sbin inherit-pkg-dir: dir: /usr net: address: 192.168.0.100/24 physical: bge0

2

Create non-global zone Apache2:
# zonecfg -z Apache2 info zonepath: /export/home/Apache2 autoboot: false pool: inherit-pkg-dir: dir: /lib inherit-pkg-dir: dir: /platform inherit-pkg-dir: dir: /sbin inherit-pkg-dir: dir: /usr net: address: 192.168.0.200/24 physical: bge0

3

Log in to Apache1 and install the application:
# zlogin Apache1 # zonename Apache1 # ls /Apachedir apache_1.3.9 apache_1.3.9-i86pc-sun-solaris2.270.tar #cd /Apachedir/apache_1.3.9 ; ./install-bindist.sh /local You now have successfully installed the Apache 1.3.9 HTTP server.

4

Log in to Apache2 and install the application:
# zlogin Apache2 # zonename Apache2 # ls /Apachedir httpd-2.0.50 httpd-2.0.50-i386-pc-solaris2.8.tar # cd /Apachedir/httpd-2.0.50; ./install-bindist.sh /local You now have successfully installed the Apache 2.0.50 HTTP server.
Module 3 • Planning the OpenSolaris Environment 31

Creating Non-Global Zones

Instructor Notes

5

Start the Apache1 application:
# zonename Apache1 # hostname Apache1zone # /local/bin/apachectl start /local/bin/apachectl start: httpd started

6

Start the Apache2 application:
# zonename Apache2 # hostname Apache2zone # /local/bin/apachectl start /local/bin/apachectl start: httpd started

7

In the global zone, edit /etc/hosts file:
# cat /etc/hosts # # Internet host table # 127.0.0.1 localhost 192.168.0.1 loghost 192.168.0.100 Apache1zone 192.168.0.200 Apache2zone

8

Open a web browser and navigate to the following URL: http://apache1zone/manual/index.html The Apache1 web server is up and running.

9 10

Open a web browser and navigate to the following URL: http://apache2zone/manual/ The Apache2 web server is up and running.

Module 3 • Planning the OpenSolaris Environment

32

Creating Non-Global Zones

Instructor Notes

Discussion
The end user sees each zone as a different system. Each web server has it's own name service:
■ ■

/etc/nsswitch.conf /etc/resolv.conf

A malicious attack on one web server is contained to that zone. Port conflicts are no longer a problem!

Module 3 • Planning the OpenSolaris Environment

33

Creating ZFS Storage Pools and File Systems

Instructor Notes
➊ The most basic building block for a storage pool is a piece of physical storage. This can be any block device of at least 128 Mbytes in size. Typically, this is a hard drive that is visible to the system in the /dev/dsk directory. ➋ A storage device can be a whole disk (c0t0d0) or an individual slice (c0t0d0s7). The recommended mode of operation is to use an entire disk, in which case the disk does not need to be specially formatted. ZFS formats the disk using an EFI label to contain a single, large slice. ➌ ZFS uses the concept of storage pools to manage physical storage. Historically, file systems were constructed on top of a single physical device. To address multiple devices and provide for data redundancy, the concept of a volume manager was introduced to provide the image of a single device so that file systems would not have to be modified to take advantage of multiple devices. This design added another layer of complexity and ultimately prevented certain file system advances, because the file system had no control over the physical placement of data on the virtualized volumes. ➍ Application issues a read. ZFS mirror tries the first disk. ➎ Checksum reveals that the block is corrupt on disk. ZFS tries the second disk. ➏ Checksum indicates that the block is good. ZFS returns good data to the application and repairs the damaged block on the first disk.

Creating ZFS Storage Pools and File Systems
Each ZFS storage pool is comprised of one or more virtual devices, which describe the layout of physical storage and its fault characteristics. ➊–➋ ➌–➏ In this module, we'll start by learning about mirrored storage pool configuration. Then we'll show you how to create a RAID-Z configuration.

Module 3 • Planning the OpenSolaris Environment

34

Creating a Mirrored ZFS Storage Pool

Instructor Notes

Creating a Mirrored ZFS Storage Pool
The objective of this lab exercise is to create and list a mirrored storage pool using the zpool command. For information about determining whether a ZFS mirrored storage pool configuration or a RAID-Z storage pool configuration is right for your environment, go to: http://www.solarisinternals.com/ wiki/index.php/ZFS_Best_Practices_Guide

Summary
ZFS is easy, so let's get on with it! It's time to create your first pool:

Module 3 • Planning the OpenSolaris Environment

35

Creating a Mirrored ZFS Storage Pool

Instructor Notes

To Create Mirrored Storage Pools
1 2

Open a terminal window. Create a mirrored storage pool named tank. Then, display information about the pool.
# zpool create tank mirror c1t1d0 c2t2d0 # zpool status tank pool: tank state: ONLINE scrub: none requested config: NAME tank mirror c1t1d0 c2t2d0 STATE ONLINE ONLINE ONLINE ONLINE READ WRITE CKSUM 0 0 0 0 0 0 0 0 0 0 0 0

errors: No known data errors

The capacity of the c1t1d0 and c2t2d0 disks is 36 Gbytes each. Because the disks are mirrored, the total capacity of the pool reflects the approximate size of one of the disks. Pool metadata consumes a small quantity of disk space. For example:
# zpool list NAME tank SIZE 33.8G USED 89K AVAIL 33.7G CAP HEALTH 0% ONLINE ALTROOT -

Module 3 • Planning the OpenSolaris Environment

36

Creating ZFS File Systems as Home Directories

Instructor Notes

Creating ZFS File Systems as Home Directories
The objective of this lab exercise is to learn how to set up ZFS file systems as several home directories. By using ZFS file system features, available in the OpenSolaris project, you might be able to simplify your kernel development environment by implementing snapshots and their rollback features.

Summary
In this lab, we'll use the zfs command to create a filesystem and set its mountpoint.

Module 3 • Planning the OpenSolaris Environment

37

Creating ZFS File Systems as Home Directories

Instructor Notes

To Create ZFS File Systems as Home Directories
1

Display the default ZFS file system that is created automatically when the storage pool is created.
# zfs list NAME USED AVAIL REFER MOUNTPOINT tank 86K 33.2G 24.5K /tank

2

Create the tank/home file system:
# zfs create tank/home

3

Then, set the mount point for the tank/home file system:
# zfs set mountpoint=/export/home tank/home

4

Finally, create tank/home file systems for all of your developers:
# zfs create tank/home/developer1 # zfs create tank/home/developer2 # zfs create tank/home/developer3 # zfs create tank/home/developer4

The mountpoint property is inherited as a pathname prefix. That is, tank/home/developer1 is automatically mounted at /export/home/developer1 because tank/home is mounted at /export/home.
5

Confirm that the ZFS file systems are created:
# zfs list NAME tank tank/home tank/home/developer1 tank/home/developer2 tank/home/developer3 tank/home/developer4 USED 246K 128K 24.5K 24.5K 24.5K 24.5K AVAIL 33.2G 33.2G 33.2G 33.2G 33.2G 33.2G REFER 26.5K 29.5K 24.5K 24.5K 24.5K 24.5K MOUNTPOINT /tank /export/home /export/home/developer1 /export/home/developer2 /export/home/developer3 /export/home/developer4

6

Take a recursive snapshot of the tank/home file system. Then, display the snapshot information:
# zfs snapshot -r tank/home@today # zfs list NAME USED AVAIL REFER MOUNTPOINT tank 252K 33.2G 26.5K /tank tank/home 128K 33.2G 29.5K /tank/home
Module 3 • Planning the OpenSolaris Environment 38

Creating ZFS File Systems as Home Directories

Instructor Notes

tank/home@today tank/home/developer1 tank/home/developer1@today tank/home/developer2 tank/home/developer2@today tank/home/developer3 tank/home/developer3@today tank/home/developer4 tank/home/developer4@today

0 24.5K 0 24.5K 0 24.5K 0 24.5K 0

33.2G 33.2G 33.2G 33.2G -

29.5K 24.5K 24.5K 24.5K 24.5K 24.5K 24.5K 24.5K 24.5K

/tank/home/developer1 /tank/home/developer2 /tank/home/developer3 /tank/home/developer4 -

For more information, see zfs.1m.

Module 3 • Planning the OpenSolaris Environment

39

Creating a RAID-Z Configuration

Instructor Notes

Creating a RAID-Z Configuration
The objective of this lab exercise is to introduce you to the RAID-Z configuration.

Summary
You might want to create a RAID-Z configuration as an alternative to a mirrored storage pool configuration if you need to maximize disk space.

Module 3 • Planning the OpenSolaris Environment

40

Creating a RAID-Z Configuration

Instructor Notes

To Create a RAID-Z Configuration
1 2

Open a terminal window. Create a pool with a single RAID-Z device consisting of 5 disks. Then, display information about the storage pool.
# zpool create tank raidz c1t1d0 c2t2d0 c3t3d0 c4t4d0 c5t5d0 # zpool status tank pool: tank state: ONLINE scrub: none requested config: NAME tank raidz1 c1t1d0 c2t2d0 c3t3d0 c4t4d0 c5t5d0 STATE ONLINE ONLINE ONLINE ONLINE ONLINE ONLINE ONLINE READ WRITE CKSUM 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

errors: No known data errors

Disks can be specified by using their shorthand name or the full path. For example, /dev/dsk/c4t4d0 is identical to c4t4d0. It is possible to use disk slices for both mirrored and RAID-Z storage pool configurations, but these configurations are not recommended for production environments. For more information about using ZFS in production environments, go to: http://www.solarisinternals.com/ wiki/index.php/ZFS_Best_Practices_Guide.

Module 3 • Planning the OpenSolaris Environment

41

42

M O D U L E

Userland Consolidations

4

Instructor Notes
4

Objectives
The objective of this module is to introduce you to the userland consolidations of OpenSolaris. In general, you can think of userland consolidations as existing outside of the kernel and as components with which users interact. Each of the following consolidations deliver source files to the opensolaris.org web site or download center. To access each consolidation, refer to the following URL: http://opensolaris.org/os/downloads/

43

Userland Consolidations and Descriptions

Instructor Notes

Userland Consolidations and Descriptions
Application Server Developer Product Tools (DevPro) Documentation (Docs) Globalization Support (G11N) Installation Support (Install) Java Desktop (JDS) Java Platform, Standard Edition (Java SE) Manual Pages Message Queue Network Storage (NWS) SFW (Solaris FreeWare) SPARC Graphics Support Test X Window System (X11) The Glassfish Application Server The system math library, the media library, the microtasking library, SCCS and make and C++ runtime libraries. Developer and administration technical documentation. Internationalization and localization support. Installation support and packaging tools. A secure and comprehensive enterprise desktop software solution. Binaries for the Java Development Kit (JDK) and Java Runtime Environment (JRE) are available. Source code to the SunOS Reference Manual Pages. The Sun Java System Message Queue. Network storage device support. Open source software that is bundled with Solaris/OpenSolaris. The SPARC graphics consolidation has drivers available in binary form. OpenSolaris Test Suites and Test Tools. X11 software.

Module 4 • Userland Consolidations

44

M O D U L E

Core Features of the Solaris OS

5

Instructor Notes
5

Objectives
The objective of this module is to describe the core features of the Solaris OS and how the features have fundamentally changed operating system computing.

Additional Resources
OpenSolaris Development Process; http://www.opensolaris.org/os/community/onnv/os_dev_process/ C Style and Coding Standards for SunOS; http://www.opensolaris.org/ os/community/documentation/getting_started_docs/

45

Development Process and Coding Style

Instructor Notes

Development Process and Coding Style
The development process steps and the coding style that is used by the OS/Net consolidation (ON) are used to deliver the core Operating System and Networking components to Solaris. ON contains the source for the kernel and all platforms (on all architectures), the bulk of the drivers, filesystems, core libraries, and basic commands that you'd expect to find on a Solaris system.The development process for the OpenSolaris project follows the following high-level steps: 1. Idea First, someone has an idea for an enhancement or has a gripe about a defect. Search for an existing bug or file a new bug or request for enhancement (RFE) by using the http://bugs.opensolaris.org/ web page. Next, announce it to other developers on the appropriate E-mail list. The announcement has the following benefits:
■ ■ ■ ■

Precipitate discussion of the change or enhancement Determine the complexity of the proposed change(s) Gauge community interest Identify potential team members

2. Design The Design phase determines whether or not a formal design review is even needed. If a formal review is needed, complete the following next steps:
■ ■ ■ ■

Identify design and architectural reviewers Write a design document Write a test plan Conduct design reviews and get the appropriate approvals

3. Implementation The Implementation phase consists of the following:

Writing of the actual code in accordance with policies and standards Download C Style and Coding Standards for SunOS here: http://www.opensolaris.org/ os/community/documentation/getting_started_docs/.

■ ■

Writing the test suites Passing various unit and pre-integration tests
46

Module 5 • Core Features of the Solaris OS

Development Process and Coding Style

Instructor Notes
➊ Sometimes, the integrated change needs to be communicated by sending heads-up messages to appropriate communities and possibly presenting a transfer of information (TOI) to a support organization to help them understand the change.

■ ■

Writing or updating the user documentation, if needed Identifying code reviewers in preparation for integration

4. Integration Integration happens after all reviews have been completed and permission to integrate has been granted. The Integration phase is to make sure everything that was supposed to be done has in fact been done, which means conducting reviews for code, documentation, and completeness. ➊ The formal process document for OpenSolaris describes the previous steps in greater detail, with flow charts that illustrate the development phases. That document also details the following design principles and core values that are to be applied to source code development for the OpenSolaris project:

Reliability – OpenSolaris must perform correctly, providing accurate results with no data loss or corruption. Availability – Services must be designed to be restartable in the event of an application failure and OpenSolaris itself must be able to recover from non-fatal hardware failures. Serviceability – It must be possible to diagnose both fatal and transient issues and wherever possible, automate the diagnosis. Security – OpenSolaris security must be designed into the operating system, with mechanisms in place in order to audit changes done to the system and by whom. Performance – The performance of OpenSolaris must be second to none when compared to other operating systems running on identical environments. Manageability – It must allow for the management of individual components, software or hardware, in a consistent and straightforward manner. Compatibility – New subsystems and interfaces must be extensible and versioned in order to allow for future enhancements and changes without sacrificing compatibility. Maintainability – OpenSolaris must be architected so that common subroutines are combined into libraries or kernel modules that can be used by an arbitrary number of consumers.
47

Module 5 • Core Features of the Solaris OS

Development Process and Coding Style

Instructor Notes
➊ This coding style is very similar to that used by the Linux kernel, BSD systems, and many other non-GNU projects (the GNU project uses its own unique coding style). Also, examine the files in usr/src/prototypes; these provide examples of the correct general layout and style for most types of source files. ➋ There are style mistakes that cannot be caught by any reasonable tool, and others that cannot be caught by the particular implementations. ➌ Improving the accuracy and completeness of these tools is an ongoing task.

Platform Neutrality – OpenSolaris must continue to be platform neutral and lower level abstractions must be designed with multiple and future platforms in mind.

Refer to http://www.opensolaris.org/os/community/onnv/os_dev_process/ for more detailed information about the process that is used for collaborative development of OpenSolaris code. Like many projects, OpenSolaris enforces a coding style on contributed code, regardless of its source. This style is described in detail at http://opensolaris.org/os/community/onnv/. ➊ ➋–➌ Two tools for checking many elements of the coding style are available as part of the OpenSolaris distribution. These tools are cstyle(1) for verifying compliance of C code with most style guidelines, and hdrchk(1) for checking the style of C and C++ headers.

Module 5 • Core Features of the Solaris OS

48

Overview

Instructor Notes

Overview
Now that you have considered the development environment, processes, and values applied to engineering by OpenSolaris developers, let's discuss in more depth, features of the operating system that exemplify performance, security, serviceability, and manageability:

Performance
■ ■ ■

FireEngine Nemo Crossbow Least Privilege Packet Filtering Zones Branded Zones (BrandZ) Predictive Self-Healing Dynamic Tracing Facility (DTrace) Modular Debugger (MDB) Services Management Facility (SMF) ZFS

Security
■ ■ ■ ■

Serviceability
■ ■ ■

Manageability
■ ■

FireEngine
The "FireEngine" approach in Solaris 10 merges all protocol layers into one STREAMS module that is fully multithreaded. Inside the merged module, instead of per-data structure locks, a per-CPU synchronization mechanism called "vertical perimeter" is used. The "vertical perimeter" is implemented using a serialization queue abstraction called "squeue." Each squeue is bound to a CPU, and each connection is in turn bound to a squeue that provides any synchronization and mutual exclusion needed for the connection-specific data structures.
Module 5 • Core Features of the Solaris OS 49

Overview

Instructor Notes
Synchronization
Since the stack is fully multithreaded (barring the per-CPU serialization enforced by the vertical perimeter), it uses a reference-based scheme to ensure that the connection instance is available when needed. For an established TCP connection, three references are guaranteed to be on it. Each protocol layer has a reference on the instance (one each for TCP and IP) and the classifier itself has a reference since it is an established connection. Each time a packet arrives for the connection and the classifier looks up the connection instance, an extra reference is placed, which is dropped when the protocol layer finishes processing that packet.

TCP, IP, and UDP
The Solaris 10 OS provides the same view for TCP as previous releases -- that is, TCP appears as a clone device but it is actually a composite, with the TCP and IP code merged into a single D_MP STREAMS module. The operational part of TCP is fully protected by the vertical perimeter that entered through the squeue primitives. FireEngine changes the interface between TCP and IP from the existing STREAMS- based message passing interface to a functional call-based interface, both in the control and data paths. There is a fully multithreaded UDP module running under the same protection domain as IP. Though UDP and IP are running in the same protection domain, they are still separate STREAMS modules. Therefore, STREAMS plumbing is kept unchanged and a UDP module instance is always pushed above IP. The Solaris 10 platform allows for the following plumbing modes:

Normal– IP is first opened and later UDP is pushed directly on top. This is the default action that happens when a UDP socket or device is opened. SNMP

Sign up to vote on this title
UsefulNot useful