File:System Programming Textbook from Illinois

Total Page:16

File Type:pdf, Size:1020Kb

File:System Programming Textbook from Illinois Coursebook B. Venkatesh, L. Angrave, et Al. Contents 1 Introduction 1 1.1 Authors . 1 2 Background 7 2.1 Systems Architecture . 7 2.1.1 Assembly . 7 2.1.2 Atomic Operations . 7 2.1.3 Caching . 8 2.1.4 Interrupts . 8 2.1.5 Optional: Hyperthreading . 9 2.2 Debugging and Environments . 9 2.2.1 ssh . 9 2.2.2 git . 10 2.2.3 Editors . 12 2.2.4 Clean Code . 13 2.2.5 Asserts . 14 2.3 Valgrind . 14 2.3.1 TSAN . 16 2.4 GDB......................................................... 17 2.4.1 Involved gdb example . 19 2.4.2 Shell . 21 2.4.3 Undefined Behavior Sanitizer . 21 2.4.4 Clang Static Build Tools . 21 2.4.5 strace and ltrace . 21 2.4.6 printfs . 23 2.5 Homework 0 . 25 2.5.1 So you want to master System Programming? And get a better grade than B? . 25 2.5.2 Watch the videos and write up your answers to the following questions . 26 2.5.3 Chapter 1 . 26 2.5.4 Chapter 2 . 27 2.5.5 Chapter 3 . 28 2.5.6 Chapter 4 . 28 2.5.7 Chapter 5 . 29 2.5.8 C Development . 29 2.5.9 Optional: Just for fun . 30 2.6 UIUC Specific Guidelines . 30 2.6.1 Piazza . 30 3 The C Programming Language 33 ii CONTENTS CONTENTS 3.1 History of C . 33 3.1.1 Features . 34 3.2 Crash course introduction to C . 34 3.2.1 Preprocessor . 35 3.3 Language Facilities . 36 3.3.1 Keywords . 36 3.3.2 C data types . 48 3.3.3 Operators . 49 3.4 The C and Linux . 50 3.4.1 Everything is a file . 50 3.4.2 System Calls . 51 3.4.3 C System Calls . 51 3.5 Common C Functions . 51 3.5.1 Handling Errors . 51 3.5.2 Input / Output . 52 3.5.3 stdin oriented functions . 54 3.5.4 string.h . 56 3.6 C Memory Model . 58 3.6.1 Structs . 58 3.6.2 Strings in C . 61 3.6.3 Places for strings . 61 3.7 Pointers . 63 3.7.1 Pointer Basics . 63 3.7.2 Pointer Arithmetic . 65 3.7.3 So what is a void pointer? . 66 3.8 Common Bugs . 66 3.8.1 Nul Bytes . 66 3.8.2 Double Frees . 67 3.8.3 Returning pointers to automatic variables . 67 3.8.4 Insufficient memory allocation . 67 3.8.5 Buffer overflow/ underflow . 68 3.8.6 Strings require strlen(s)+1 bytes . 68 3.8.7 Using uninitialized variables . 69 3.8.8 Assuming Uninitialized memory will be zeroed . 69 3.9 Logic and Program flow mistakes . 69 3.9.1 Equal vs. Equality . 69 3.9.2 Undeclared or incorrectly prototyped functions . 70 3.9.3 Extra Semicolons . 70 3.10 Topics ..
Recommended publications
  • The Evolution of Econometric Software Design: a Developer's View
    Journal of Economic and Social Measurement 29 (2004) 205–259 205 IOS Press The evolution of econometric software design: A developer’s view Houston H. Stokes Department of Economics, College of Business Administration, University of Illinois at Chicago, 601 South Morgan Street, Room 2103, Chicago, IL 60607-7121, USA E-mail: [email protected] In the last 30 years, changes in operating systems, computer hardware, compiler technology and the needs of research in applied econometrics have all influenced econometric software development and the environment of statistical computing. The evolution of various representative software systems, including B34S developed by the author, are used to illustrate differences in software design and the interrelation of a number of factors that influenced these choices. A list of desired econometric software features, software design goals and econometric programming language characteristics are suggested. It is stressed that there is no one “ideal” software system that will work effectively in all situations. System integration of statistical software provides a means by which capability can be leveraged. 1. Introduction 1.1. Overview The development of modern econometric software has been influenced by the changing needs of applied econometric research, the expanding capability of com- puter hardware (CPU speed, disk storage and memory), changes in the design and capability of compilers, and the availability of high-quality subroutine libraries. Soft- ware design in turn has itself impacted applied econometric research, which has seen its horizons expand rapidly in the last 30 years as new techniques of analysis became computationally possible. How some of these interrelationships have evolved over time is illustrated by a discussion of the evolution of the design and capability of the B34S Software system [55] which is contrasted to a selection of other software systems.
    [Show full text]
  • Alpha AXP Firmware Porting Guide Revision/Update Information: Version 1.0
    Alpha AXP Firmware Porting Guide Revision/Update Information: Version 1.0 Order Number: EK-AXFRM-PG. A01 November, 1994 Digital Equipment Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description. Reproduction or duplication of this courseware in any form, in whole or in part, is prohibited without the prior written permission of Digital Equipment Corporation. Possession, use, or copying of the software described in this publication is authorized only pursuant to a valid written license from Digital or an authorized sublicensor. © Digital Equipment Corporation 1994. All Rights Reserved. Printed in U.S.A. The following are trademarks of Digital Equipment Corporation: Alpha AXP, AXP, Bookreader, DEC, DECchip, DEC OSF/1, DECwindows, Digital, OpenVMS, VAX, VMS, VMScluster, the DIGITAL logo and the AXP mark. MIPS is a trademark of MIPS Computer Systems, Inc. NCR is a registered trademark of the NCR Corporation. NetWare is a registered trademark of Novell, Inc. OSF/1 is a registered trademark of the Open Software Foundation, Inc. UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company Ltd. Windows NT is a registered trademark of the Microsoft Corporation. All other trademarks and registered trademarks are the property of their respective holders. This document was prepared using VAX DOCUMENT Version 2.1. Contents Preface ............................................................ xiii 1 Porting Strategy Overview .......................................................
    [Show full text]
  • The Commission's Assessment of Microsoft's
    The Commission's assessment of Microsoft's innovation claims In the column "Prior Art", the symbol [PA] indicates that the reference is cited as prior art, the symbol [R] means that it is cited as a reference. The following applies in the column "References": [July-T, x] = 8 July Trustee report, page x [March-T, x] = 3 March Trustee report (as amending the 22 February Trustee report), page x [Ecis, x] = Ecis's comments to Microsoft's Response to the 1 March SO, page x Date of Reference in Microsoft's Protocol Technology Description of the technology Claimed benefit Assessment Prior Art References claim filing Active ADFS Combination of The combination of all the mentioned April 2004 The use of the five Microsoft's innovation report The claimed innovation is the [July-T, 4] Directory ADFS ADFS technologies. individual ADFS on "Microsoft Web Browse combination of different features Federation Technologies innovations in Federated Sign-on Protocol & belonging to the same protocol. Services combination is Microsoft Web Browser Combining these individual undisclosed and not Federated Sign-On Protocol features is an obvious step for a obvious. Extensions" person skilled in the art. NON-INNOVATIVE Active ADFS Defining ADFS defines communications between April 2004 The protocol Microsoft's innovation report The claim concerns resolving [PA] Anderson, Steve et al: Web Services [July-T, 4] Directory Authentication a resource identity provider and a web delivers on "Microsoft Web Browse problems which are specific to Trust Language (WS-Trust) (1 May 2004; [March-T, 110] Federation Communications service resource. maintainability by Federated Sign-on Protocol & Microsoft's implementation.
    [Show full text]
  • Digital Alphastation 250 Series User Information
    Digital AlphaStation™ 250 Series User Information Order Number: EK-PCCTA-UI. A01 Digital Equipment Corporation Maynard, Massachusetts January 1995 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that might appear in this document. The software, if any, described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software or equipment that is not supplied by Digital Equipment Corporation or its affiliated companies. Restricted Rights: Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013. Copyright 1995 Digital Equipment Corporation. All Rights Reserved. The following are trademarks of Digital Equipment Corporation: AlphaGeneration, AlphaStation, DEC, Digital, OpenVMS, ThinWire, and the DIGITAL logo. The following are third-party trademarks: Microsoft and Windows NT are registered trademarks of Microsoft Corporation. SIMM is a trademark of Molex Corporation. OSF/1 is a trademark of the Open Software Foundation, Inc. All other trademarks or registered trademarks are the property of their respective holders. This document was produced with Microsoft Word for Windows, V2.0c. FCC Information - Class B This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to Part 15 of the FCC rules.
    [Show full text]
  • Digital Personal Workstation Service Maintenance Guide
    Digital Personal Workstation Service Maintenance Manual DIGITAL PERSONAL WORKSTATION Digital Personal Workstation Service Maintenance Manual Part Number: ER-B30WW-SM. A01 DIGITAL PERSONAL WORKSTATION Digital Equipment Corporation September 1996 The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that might appear in this document. The software described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software or equipment that is not supplied by Digital Equipment Corporation or its affiliated companies. Restricted Rights: Use, duplication, or disclosure by the U.S. Government is subject to restrictions as set forth in subparagraph (c) (1) (ii) of the Rights in Technical Data and Computer Software clause at DFARS 252.227-7013. Digital Personal Workstation Service Maintenance Manual Copyright Digital Equipment Corporation. All Rights Reserved. DEC and the Digital logo are registered trademarks of Digital Equipment Corporation. Intel is a registered trademark of Intel Corporation. Pentium-Pro are registered trademarks of Intel Corporation. Microsoft and Windows NT are registered trademarks of Microsoft Corporation. SIMM is a registered trademark of Wang Laboratories. All other trademarks and registered trademarks are the property of their respective holders. The FCC wants you to know... This equipment has been tested and found to comply with the limits for a Class B digital device, pursuant to Part 15 of the FCC rules.
    [Show full text]
  • The Computer History Simulation Project
    The Computer History Simulation Project The Computer History Simulation Project The Computer History Simulation Project is a loose Internet-based collective of people interested in restoring historically significant computer hardware and software systems by simulation. The goal of the project is to create highly portable system simulators and to publish them as freeware on the Internet, with freely available copies of significant or representative software. Simulators SIMH is a highly portable, multi-system simulator. ● Download the latest sources for SIMH (V3.5-1 updated 15-Oct-2005 - see change log). ● Download a zip file containing Windows executables for all the SIMH simulators. The VAX and PDP-11 are compiled without Ethernet support. Versions with Ethernet support are available here. If you download the executables, you should download the source archive as well, as it contains the documentation and other supporting files. ● If your host system is Alpha/VMS, and you want Ethernet support, you need to download the VMS Pcap library and execlet here. SIMH implements simulators for: ● Data General Nova, Eclipse ● Digital Equipment Corporation PDP-1, PDP-4, PDP-7, PDP-8, PDP-9, PDP-10, PDP-11, PDP- 15, VAX ● GRI Corporation GRI-909 ● IBM 1401, 1620, 1130, System 3 ● Interdata (Perkin-Elmer) 16b and 32b systems ● Hewlett-Packard 2116, 2100, 21MX ● Honeywell H316/H516 ● MITS Altair 8800, with both 8080 and Z80 ● Royal-Mcbee LGP-30, LGP-21 ● Scientific Data Systems SDS 940 Also available is a collection of tools for manipulating simulator file formats and for cross- assembling code for the PDP-1, PDP-7, PDP-8, and PDP-11.
    [Show full text]
  • A File System Component Compiler
    A File System Component Compiler Erez Zadok [email protected] Computer Science Department Columbia University New York, NY 10027 CUCS-033-97 April 28, 1997 THESIS PROPOSAL File System development is a difficult and time consuming task, the results of which are rarely portable across operating systems. Several proposals to improve the vnode interface to allow for more flexible file system design and implementation have been made in recent years, but none is used in practice because they require costly fundamental changes to kernel interfaces, only operating systems vendors can make those changes, are still non-portable, tend to degrade performance, and do not appear to provide immediate return on such an investment. This proposal advocates a language for describing file systems, called FiST. The associated translator can generate portable C code — kernel resident or not — that implements the described file system. No kernel source code is needed and no existing vnode interface must change. The performance of the file systems automatically generated by FiST can be within a few percent of comparable hand-written file systems. The main benefits to automation are that development and maintenance costs are greatly reduced, and that it becomes practical to prototype, implement, test, debug, and compose a vastly larger set of such file systems with different properties. The proposed thesis will describe the language and its translator, use it to implement a few file systems on more than one platform, and evaluate the performance of the automatically generated code. i Contents 1 Introduction 1 1.1TheProblem.......................................... 2 1.2MySolution........................................... 2 1.3AdvantagesofMySolution.................................
    [Show full text]
  • Hack Attacks Revealed
    Hack Attacks Revealed A Complete Reference with Custom Security Hacking Toolkit John Chirillo This netLibrary eBook does not include the ancillary media that was packaged with the original printed version of the book. Publisher: Robert Ipsen Editor: Carol A. Long Assistant Editor: Adaobi Obi Managing Editor: Micheline Frederick New Media Editor: Brian Snapp Text Design & Composition: Thomark Design Designations used by companies to distinguish their products are often claimed as trademarks. In all instances where John Wiley & Sons, Inc., is aware of a claim, the product names appear in initial capital or ALL CAPITAL LETTERS. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and registration. Copyright © 2001 by John Chirillo. All rights reserved. Published by John Wiley & Sons, Inc. No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic, mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per- copy fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750- 8400, fax (978) 750-4744. Requests to the Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 605 Third Avenue, New York, NY 10158-0012, (212) 850-6011, fax (212) 850-6008, E-Mail: PERMREQ @ WILEY.COM. This publication is designed to provide accurate and authoritative information in regard to the subject matter covered. It is sold with the understanding that the publisher is not engaged in professional services.
    [Show full text]
  • Alpha Architecture Handbook
    Alpha Architecture Handbook Order Number EC–QD2KB–TE Revision/Update Information: This is Version 3 of the Alpha Architecture Handbook. The changes and additions in this book are subsequent to the Alpha AXP Architecture Reference Manual, Second Edition, and the Alpha AXP Architecture Handbook, Version 2. Digital Equipment Corporation Maynard, Massachusetts October 1996 While Digital believes the information included in this publication is correct as of the date of publication, it is subject to change without notice. Digital Equipment Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description. Copyright ©1996 Digital Equipment Corporation. All rights reserved. The following are trademarks of Digital Equipment Corporation: AlphaGeneration, Alpha AXP, AXP, DEC, Digital, OpenVMS, PDP–11, VAX, VAX DOCUMENT, the AlphaGeneration design mark, and the DIGITAL logo. Cray is a registered trademark of Cray Research, Inc. IBM is a registered trademark of International Business Machines Corporation. UNIX is a registered trademark in the United States and other countries licensed exclusively through X/Open Company Ltd. Windows NT is a trademark of Microsoft Corporation. All other trademarks and registered trademarks are the property of their respective holders. This document was prepared using VAX DOCUMENT, Version 2.1-1. Contents Preface xv Chapter 1 Introduction (I) 1.1 The Alpha Approach to RISC Architecture ................................. 1–1 1.2 Data Format Overview ................................................. 1–3 1.3 Instruction Format Overview .
    [Show full text]
  • Alphaserver 1200 User's Guide
    AlphaServer 1200 User’s Guide Order Number: EK–AS120–UG. A01 This manual is for anyone who manages, operates, or services the AlphaServer 1200 system. It covers operation, firmware, initial troubleshooting, and component installation. Digital Equipment Corporation Maynard, Massachusetts First Printing, October 1997 Digital Equipment Corporation makes no representations that the use of its products in the manner described in this publication will not infringe on existing or future patent rights, nor do the descriptions contained in this publication imply the granting of licenses to make, use, or sell equipment or software in accordance with the description. The information in this document is subject to change without notice and should not be construed as a commitment by Digital Equipment Corporation. Digital Equipment Corporation assumes no responsibility for any errors that may appear in this document. The software, if any, described in this document is furnished under a license and may be used or copied only in accordance with the terms of such license. No responsibility is assumed for the use or reliability of software or equipment that is not supplied by Digital Equipment Corporation or its affiliated companies. Copyright 1997 by Digital Equipment Corporation. All rights reserved. The following are trademarks of Digital Equipment Corporation: AlphaServer, OpenVMS, StorageWorks, VAX, and the DIGITAL logo. The following are third-party trademarks: Lifestyle 28.8 DATA/FAX Modem is a trademark of Motorola, Inc. UNIX is a registered trademark in the U.S. and other countries, licensed exclusively through X/Open Company Ltd. U.S. Robotics and Sportster are registered trademarks of U.S.
    [Show full text]
  • Security Probes for Industrial Control Networks
    Master in Informatics Engineering Dissertation Final Report Security Probes for Industrial Control Networks Jorge Filipe Barrigas [email protected] Academic Advisor: Prof. Tiago José dos Santos Martins da Cruz Date: July 01, 2014 Acknowledgements I would like to express my special appreciation and thanks to my advisor Professor Tiago Cruz for his excellent guidance, caring, patience, and providing me with an excellent atmosphere for doing research. I would also like to thank the LCT team and Professor Dr. Paulo Simões for all the support in my research. Finally, I would also like to thank my parents. They were always supporting me and encouraging me with their best wishes. Summary During the last years, some of the attacks towards SCADA made headlines, helping raise awareness . Some of the vulnerabilities may even be exploited to harm other systems, eventually, ending compromising specific points of SCADA networks. At the same time, a growing number of threats related with the physical layer made new issues and low-level mechanisms emerged, requiring careful approach and monitoring to secure such devices. Threats of this type are considered to be even more dangerous than SCADA-specific ones, since these operate at a lower level, unnoticed to scanners and anti-viruses. Considering this scenario we can expect a growing number of these threats to be affecting SCADA components, if adequate countermeasures are not taken. Over the last ten months (from September 16, 2013 until June 27, 2014), a new concept was developed, in the context of the FP7 CockpitCI project, for the current thesis, to reinforce the security of SCADA systems.
    [Show full text]
  • A Review of Low-End, Middle-End, and High-End Iot Devices
    Received September 28, 2018, accepted October 22, 2018, date of publication November 9, 2018, date of current version December 18, 2018. Digital Object Identifier 10.1109/ACCESS.2018.2879615 A Review of Low-End, Middle-End, and High-End Iot Devices MIKE O. OJO , (Student Member, IEEE), STEFANO GIORDANO, (Senior Member, IEEE), GREGORIO PROCISSI , AND ILIAS N. SEITANIDIS Department of Information Engineering, University of Pisa, 56122 Pisa, Italy Corresponding author: Mike O. Ojo ([email protected]). This work was supported by the University of Pisa under the PRA 2018-2019 Research Project CONCEPT-Communication and Networking for vehicular CybEr-Physical sysTems. ABSTRACT Internet of Things (IoT) devices play a crucial role in the overall development of IoT in providing countless applications in various areas. Due to the increasing interest and rapid technological growth of sensor technology, which have certainly revolutionized the way we live today, a need to provide a detailed analysis of the embedded platforms and boards is consequential. This paper presents a compre- hensive survey of the recent and most-widely used commercial and research embedded systems and boards in different classification emphasizing their key attributes including processing and memory capabilities, security features, connectivity and communication interfaces, size, cost and appearance, operating system support, power specifications, and battery life and listing some interesting projects for each device. Through this exploration and discussion, readers can have an overall understanding on this area and foster more subsequent studies. INDEX TERMS Internet of Things, embedded systems, hardware platform, microcontrollers, microproces- sors, operating systems. I. INTRODUCTION components, such as memory, I/O, peripherals and wireless It is not news that Internet of things (IoT) has enormous connectivity chips in a pre-built, ready to program package.
    [Show full text]