Adding a System Call to Plan 9

Similar documents
OPTIMIZING CHEMICAL SENSOR ARRAY SIZES

NIF ICCS Test Controller for Automated & Manual Testing

Go SOLAR Online Permitting System A Guide for Applicants November 2012

In-Field Programming of Smart Meter and Meter Firmware Upgrade

LosAlamos National Laboratory LosAlamos New Mexico HEXAHEDRON, WEDGE, TETRAHEDRON, AND PYRAMID DIFFUSION OPERATOR DISCRETIZATION

Portable Data Acquisition System

Testing PL/SQL with Ounit UCRL-PRES

Intelligent Grid and Lessons Learned. April 26, 2011 SWEDE Conference

METADATA REGISTRY, ISO/IEC 11179

COMPUTATIONAL FLUID DYNAMICS (CFD) ANALYSIS AND DEVELOPMENT OF HALON- REPLACEMENT FIRE EXTINGUISHING SYSTEMS (PHASE II)

High Scalability Resource Management with SLURM Supercomputing 2008 November 2008

Large Scale Test Simulations using the Virtual Environment for Test Optimization

SmartSacramento Distribution Automation

On Demand Meter Reading from CIS

Graphical Programming of Telerobotic Tasks

Saiidia National Laboratories. work completed under DOE ST485D sponsored by DOE

ENDF/B-VII.1 versus ENDFB/-VII.0: What s Different?

Alignment and Micro-Inspection System

FY97 ICCS Prototype Specification

CHANGING THE WAY WE LOOK AT NUCLEAR

Advanced Synchrophasor Protocol DE-OE-859. Project Overview. Russell Robertson March 22, 2017

Final Report for LDRD Project Learning Efficient Hypermedia N avi g a ti o n

Entergy Phasor Project Phasor Gateway Implementation

@ST1. JUt EVALUATION OF A PROTOTYPE INFRASOUND SYSTEM ABSTRACT. Tom Sandoval (Contractor) Los Alamos National Laboratory Contract # W7405-ENG-36

DOE EM Web Refresh Project and LLNL Building 280

The APS Control System-Network

Real Time Price HAN Device Provisioning

and opinions of authors expressed herein do not necessarily state or reflect those of the United States Government or any agency thereof.

Optimizing Bandwidth Utilization in Packet Based Telemetry Systems. Jeffrey R Kalibjian

Stereo Vision Based Automated Grasp Planning

Integrated Volt VAR Control Centralized

EPICS Add On Products SourceRelease Control

Cross-Track Coherent Stereo Collections

PJM Interconnection Smart Grid Investment Grant Update

TUCKER WIRELINE OPEN HOLE WIRELINE LOGGING

GA A22637 REAL TIME EQUILIBRIUM RECONSTRUCTION FOR CONTROL OF THE DISCHARGE IN THE DIII D TOKAMAK

Bridging The Gap Between Industry And Academia

ACCELERATOR OPERATION MANAGEMENT USING OBJECTS*

Tim Draelos, Mark Harris, Pres Herrington, and Dick Kromer Monitoring Technologies Department Sandia National Laboratories

Electronic Weight-and-Dimensional-Data Entry in a Computer Database

Clusters Using Nonlinear Magnification

Java Based Open Architecture Controller

Centrally Managed. Ding Jun JLAB-ACC This process of name resolution and control point location

Development of Web Applications for Savannah River Site

NATIONAL GEOSCIENCE DATA REPOSITORY SYSTEM

PJM Interconnection Smart Grid Investment Grant Update

Site Impact Policies for Website Use

Contributors: Surabhi Jain, Gengbin Zheng, Maria Garzaran, Jim Cownie, Taru Doodi, and Terry L. Wilmarth

zorder-lib: Library API for Z-Order Memory Layout

5A&-qg-oOL6c AN INTERNET ENABLED IMPACT LIMITER MATERIAL DATABASE

KCP&L SmartGrid Demonstration

Washington DC October Consumer Engagement. October 4, Gail Allen, Sr. Manager, Customer Solutions

ALAMO: Automatic Learning of Algebraic Models for Optimization

MAS. &lliedsignal. Design of Intertransition Digitizing Decomutator KCP Federal Manufacturing & Technologies. K. L.

A VERSATILE DIGITAL VIDEO ENGINE FOR SAFEGUARDS AND SECURITY APPLICATIONS

The ANLABM SP Scheduling System

GA A22720 THE DIII D ECH MULTIPLE GYROTRON CONTROL SYSTEM

- Q807/ J.p 7y qj7 7 w SfiAJ D--q8-0?dSC. CSNf. Interferometric S A R Coherence ClassificationUtility Assessment

Resource Management at LLNL SLURM Version 1.2

Testing of PVODE, a Parallel ODE Solver

MULTIPLE HIGH VOLTAGE MODULATORS OPERATING INDEPENDENTLY FROM A SINGLE COMMON 100 kv dc POWER SUPPLY

Ecma International Policy on Submission, Inclusion and Licensing of Software

A METHOD FOR EFFICIENT FRACTIONAL SAMPLE DELAY GENERATION FOR REAL-TIME FREQUENCY-DOMAIN BEAMFORMERS

Information to Insight

DERIVATIVE-FREE OPTIMIZATION ENHANCED-SURROGATE MODEL DEVELOPMENT FOR OPTIMIZATION. Alison Cozad, Nick Sahinidis, David Miller

Reduced Order Models for Oxycombustion Boiler Optimization

The NMT-5 Criticality Database

DNA Sequences. Informatics Group Computer Science and Mathematics Division Oak Ridge National Laboratory Oak Ridge, TN

REAL-TIME MULTIPLE NETWORKED VIEWER CAPABILITY OF THE DIII D EC DATA ACQUISITION SYSTEM

Big Data Computing for GIS Data Discovery

Automating Groundwater Sampling at Hanford

ESNET Requirements for Physics Reseirch at the SSCL

python Roll: Users Guide 5.5 Edition

Southern Company Smart Grid

for use with the WINDOW 4.1 Computer Program

Common Persistent Memory POSIX* Runtime (CPPR) API Reference (MS21) API Reference High Performance Data Division

8) Subroutines and functions

Leonard E. Duda Sandia National Laboratories. PO Box 5800, MS 0665 Albuquerque, NM

ADAPTIVE MESH REFINEMENT IN CTH

Implementation of the AES as a Hash Function for Confirming the Identity of Software on a Computer System

REAL-TIME CONTROL OF DIII D PLASMA DISCHARGES USING A LINUX ALPHA COMPUTING CLUSTER

NFRC Spectral Data Library #4 for use with the WINDOW 4.1 Computer Program

IETF TRUST. Legal Provisions Relating to IETF Documents. Approved November 6, Effective Date: November 10, 2008

HELIOS CALCULATIONS FOR UO2 LATTICE BENCHMARKS

Materials Science and Technology

Ecma International Policy on Submission, Inclusion and Licensing of Software

Displacements and Rotations of a Body Moving About an Arbitrary Axis in a Global Reference Frame

R. P. Evans (INEEL) J. G. Keller (INEEL) A. G. Stephens (ISU) J. Blotter (ISU) May 17, 1999 May 20, 1999

IETF TRUST. Legal Provisions Relating to IETF Documents. February 12, Effective Date: February 15, 2009

INCLUDING MEDICAL ADVICE DISCLAIMER

Collaborating with Human Factors when Designing an Electronic Textbook

Stereoscopic Height Estimation from Multiple Aspect Synthetic Aperture Radar Images

Motion Planning of a Robotic Arm on a Wheeled Vehicle on a Rugged Terrain * Abstract. 1 Introduction. Yong K. Hwangt

IN-SITU PROPERTY MEASUREMENTS ON LASER-DRAWN STRANDS OF SL 5170 EPOXY AND SL 5149 ACRYLATE

Python Roll Users Guide. 6.2 Edition

FSEC Procedure for Testing Stand-Alone Photovoltaic Systems

Protecting Control Systems from Cyber Attack: A Primer on How to Safeguard Your Utility May 15, 2012

APPLICATION-SPECIFIC INTEGRATED CIRCUIT DESIGN FOR A TYPICAL PRESSURIZED WATER REACTOR PRESSURE CHANNEL TRIP*

CA File Master Plus. Release Notes. Version

BWXT Y-12 Y-12. A BWXT/Bechtel Enterprise COMPUTER GENERATED INPUTS FOR NMIS PROCESSOR VERIFICATION. Y-12 National Security Complex

Transcription:

Adding a System Call to Plan 9 John Floren (john@csplan9.rit.edu) Sandia National Laboratories Livermore, CA 94551 DOE/NNSA Funding Statement Sandia is a multiprogram laboratory operated by Sandia Corporation, a Lockheed Martin Company, for the United States Department of Energy s National Nuclear Security Administration under contract DE-AC04-94AL85000. Disclaimer of Liability This work of authorship was prepared as an account of work sponsored by an agency of the United States Government. Accordingly, the United States Government retains a nonexclusive, royalty-free license to publish or reproduce the published form of this contribution, or allow others to do so for United States Government purposes. Neither Sandia Corporation, the United States Government, nor any agency thereof, nor any of their employees makes any warranty, express or implied, or assumes any legal liability or responsibility for the accuracy, completeness, or usefulness of any information, apparatus, product, or process disclosed, or represents that its use would not infringe upon privately-owned rights. Reference herein to any specific commercial product, process, or service by trade name, trademark, manufacturer, or otherwise does not necessarily constitue or imply its endorsement, recommendation, or favoring by Sandia Corporation, the United States Government, or any agency thereof. The views and opinions expressed herein do not necessarily state or reflect those of Sandia Corporation, the United States Government, or any agency thereof. SAND number 2008-2232W

- 2 - Adding a System Call The process for adding a new system call to Plan 9 is rather simple. For this example, a "kernel getpid " function will be added, mirroring the functionality of the getpid() function, but using a system call rather than a libc function. There are four files that must be modified to add a new system call: /sys/src/libc/9syscall/sys.h /sys/include/libc.h /sys/src/9/port/systab.h One of /sys/src/9/port/[sysauth, sysfile, sysproc, sysseg].c, depending on the syscall type /sys/src/libc/9syscall/sys.h (User-mode and Kernel-mode) The first file that will be modified is /sys/src/libc/9syscall/sys.h. This file numbers the system calls; by default, the last syscall listed is pwrite, index 51. We will add #define KGET- PID 52 to the end of the file. When libc is built, it generates a set of small assembly functions that move the system call number to a register and perform interrupt 0x40; now that kgetpid has been added, a function will be generated that moves 52 to the register and does the interrupt. /sys/include/libc.h (User-mode) It is necessary to modify /sys/include/libc.h to define kgetpid. The appropriate line in this case is extern int kgetpid(void);. Failing to insert this definition will result in a compiler warning. /sys/src/9/port/systab.h (Kernel-mode) Next, the new system call must be registered in /sys/src/9/port/systab.h ; this file contains an array of the system call functions. When a system call interrupt is generated, the correct function is located in the array and called; it then performs the desired operation and returns, allowing the system to go back to user mode. A script, /sys/src/9/port/mksystab, will create a new systab.h file automatically; simply run rc /sys/src/9/port/mksystab > /sys/src/9/port/systab.h Examining the new file, a new line containing Syscall syskgetpid; is now among the rest of the Syscall definitions, and two new entries in the systab[] and sysctab[] arrays have been added, containing [KGETPID] syskgetpid, in systab[] and [KGETPID] Kgetpid, in sysctab[]. This means that when a system call interrupt is generated with an argument of 52 (the index of kgetpid in the array), the trap handler will access systab[kgetpid] and call the handler function, syskgetpid. /sys/src/9/port/[sysauth, sysfile, sysproc, sysseg].c (Kernel-mode) Finally, the handler function, syskgetpid, must be written. Since kgetpid is a process-related function, /sys/src/9/port/sysproc.c is the appropriate file to modify. The syskgetpid function is exceptionally simple: long syskgetpid(ulong *arg) { return up->pid; Examples of more complex functions are in the sysproc.c file. Compiling and Testing The new kernel is now ready to be built. Since libc was modified, rebuild libc first, then build the kernel as usual. Now, a test program will work as expected:

- 3 - % cat > kgetpid.c #include <u.h> #include <libc.h> void main() { print("my pid: %d\n", kgetpid()); exits(0); ^D % 8c kgetpid.c; 8l kgetpid.8; 8.out My pid: 123 Tracing the New System Call Using a kernel tracing tool still in development, it is possible to examine the relative amount of time spent in executing the system call. The test program is changed as shown below; data is then collected with the tracing tool and plotted. The plot on the next page shows the results gathered; since many functions were called during the execution of the program, it is difficult to read the function labels on the y-axis, but a box has been placed around the area of time where the kgetpid system call ran. The execution time for the system call is minimal compared to the process startup and shutdown overhead. The second plot shows the area within the box; as the graph shows, the actual process of executing a syscall is very simple.g4 #include <u.h> #include <libc.h> void main() { kgetpid(); exits(0);

- 4 -

syscall plotme-kgetpidonly using 1:2:3:ytic(5):xtic(1) kexit notify procctl - 5 - syskgetpid memmove userureg