Objective-C Fundamentals

Total Page:16

File Type:pdf, Size:1020Kb

Objective-C Fundamentals Christopher K. Fairbairn Johannes Fahrenkrug Collin Ruffenach MANNING Objective-C Fundamentals Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> Objective-C Fundamentals CHRISTOPHER K. FAIRBAIRN JOHANNES FAHRENKRUG COLLIN RUFFENACH MANNING SHELTER ISLAND Download from Wow! eBook <www.wowebook.com> For online information and ordering of this and other Manning books, please visit www.manning.com. The publisher offers discounts on this book when ordered in quantity. For more information, please contact Special Sales Department Manning Publications Co. 20 Baldwin Road PO Box 261 Shelter Island, NY 11964 Email: [email protected] ©2012 by Manning Publications Co. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, photocopying, or otherwise, without prior written permission of the publisher. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in the book, and Manning Publications was aware of a trademark claim, the designations have been printed in initial caps or all caps. Recognizing the importance of preserving what has been written, it is Manning’s policy to have the books we publish printed on acid-free paper, and we exert our best efforts to that end. Recognizing also our responsibility to conserve the resources of our planet, Manning books are printed on paper that is at least 15 percent recycled and processed without the use of elemental chlorine. Manning Publications Co. Development editor: Troy Mott 20 Baldwin Road Technical editor: Amos Bannister PO Box 261 Copyeditor: Linda Kern Shelter Island, NY 11964 Proofreader: Katie Tennant Typesetter: Dennis Dalinnik Cover designer: Marija Tudor ISBN: 9781935182535 Printed in the United States of America 1 2 3 4 5 6 7 8 9 10 – MAL – 17 16 15 14 13 12 11 Download from Wow! eBook <www.wowebook.com> brief contents PART 1 GETTING STARTED WITH OBJECTIVE-C...........................1 1 ■ Building your first iOS application 3 2 ■ Data types, variables, and constants 28 3 ■ An introduction to objects 55 4 ■ Storing data in collections 74 PART 2 BUILDING YOUR OWN OBJECTS ....................................95 5 ■ Creating classes 97 6 ■ Extending classes 124 7 ■ Protocols 144 8 ■ Dynamic typing and runtime type information 163 9 ■ Memory management 177 PART 3 MAKING MAXIMUM USE OF FRAMEWORK FUNCTIONALITY ........................................................201 10 ■ Error and exception handling 203 11 ■ Key-Value Coding and NSPredicate 212 12 ■ Reading and writing application data 228 13 ■ Blocks and Grand Central Dispatch 257 14 ■ Debugging techniques 276 v Download from Wow! eBook <www.wowebook.com> Download from Wow! eBook <www.wowebook.com> contents preface xv acknowledgments xvi about this book xviii author online xxi about the cover illustration xxii PART 1 GETTING STARTED WITH OBJECTIVE-C ...............1 Building your first iOS application 3 1 1.1 Introducing the iOS development tools 4 Adapting the Cocoa frameworks for mobile devices 4 1.2 Adjusting your expectations 5 A survey of hardware specifications, circa mid-2011 6 Expecting an unreliable internet connection 7 1.3 Using Xcode to develop a simple Coin Toss game 7 Introducing Xcode—Apple’s IDE 8 Launching Xcode easily 8 ■ Creating the project 9 Writing the source code 12 1.4 Hooking up the user interface 15 Adding controls to a view 15 ■ Connecting controls to source code 17 vii Download from Wow! eBook <www.wowebook.com> viii CONTENTS 1.5 Compiling the Coin Toss game 21 1.6 Taking Coin Toss for a test run 21 Selecting a destination 22 ■ Using breakpoints to inspect the state of a running application 23 ■ Running the CoinToss game in the iPhone simulator 24 Controlling the debugger 25 1.7 Summary 27 Data types, variables, and constants 28 2 2.1 Introducing the Rental Manager application 29 Laying the foundations 29 2.2 The basic data types 32 Counting on your fingers—integral numbers 32 Filling in the gaps—floating-point numbers 35 Characters and strings 37 ■ Boolean truths 39 2.3 Displaying and converting values 40 NSLog and Format Specifiers 40 ■ Type casts and type conversions 43 2.4 Creating your own data types 44 Enumerations 44 ■ Structures 46 ■ Arrays 48 The importance of descriptive names 50 2.5 Completing Rental Manager v1.0, App Store here we come! 52 2.6 Summary 54 An introduction to objects 55 3 3.1 A whirlwind tour of object-oriented programming concepts 56 What’s wrong with procedural-based languages such as C? 56 What are objects? 56 ■ What are classes? 57 Inheritance and polymorphism 57 3.2 The missing data type: id 58 3.3 Pointers and the difference between reference and value types 59 Memory maps 59 ■ Obtaining the address of a variable 59 Following a pointer 60 ■ Comparing the values of pointers 61 Download from Wow! eBook <www.wowebook.com> CONTENTS ix 3.4 Communicating with objects 62 Sending a message to an object 62 ■ Sending a message to a class 63 ■ Sending nonexistent messages 64 Sending messages to nil 65 3.5 Strings 66 Constructing strings 66 ■ Extracting characters from strings 67 ■ Modifying strings 68 Comparing strings 69 3.6 Sample application 69 3.7 Summary 72 Storing data in collections 74 4 4.1 Arrays 75 Constructing an array 75 ■ Accessing array elements 76 Searching for array elements 77 ■ Iterating through arrays 79 Adding items to an array 80 4.2 Dictionaries 82 Constructing a dictionary 82 ■ Accessing dictionary entries 84 ■ Adding key/value pairs 85 Enumerating all keys and values 86 4.3 Boxing 88 The NSNumber class 89 ■ The NSValue class 90 nil vs. NULL vs. NSNull 90 4.4 Making the Rental Manager application data driven 91 4.5 Summary 94 PART 2 BUILDING YOUR OWN OBJECTS.........................95 Creating classes 97 5 5.1 Building custom classes 98 Adding a new class to the project 98 5.2 Declaring the interface of a class 99 Instance variables (ivars) 100 ■ Method declarations 101 Fleshing out the header file for the CTRentalProperty class 105 5.3 Providing an implementation for a class 106 Defining method implementations 106 ■ Accessing instance variables 106 ■ Sending messages to self 107 Fleshing out the method file for the CTRentalProperty class 108 Download from Wow! eBook <www.wowebook.com> x CONTENTS 5.4 Declared properties 109 @property syntax 109 ■ Synthesizing property getters and setters 112 ■ Dot syntax 113 5.5 Creating and destroying objects 115 Creating and initializing objects 115 ■ init is pretty dumb 116 Combining allocation and initialization 118 Destroying objects 119 5.6 Using the class in the Rental Manager application 120 5.7 Summary 123 Extending classes 124 6 6.1 Subclassing 124 What is subclassing? 125 6.2 Adding new instance variables 127 6.3 Accessing existing instance variables 129 Manual getters and setters approach 130 6.4 Overriding methods 131 Overriding the description method 132 6.5 Class clusters 134 Why use class clusters 134 ■ Multiple public clusters 135 6.6 Categories 136 Extending classes without subclassing 136 Using a category 136 ■ Considerations when using categories 138 6.7 Subclassing in your demo application 138 Creating and subclassing CTLease 139 Creating CTPeriodicLease as a subclass of CTLease 140 Creating CTFixedLease as a subclass of CTLease 141 6.8 Summary 143 Protocols 144 7 7.1 Defining a protocol 145 7.2 Implementing a protocol 146 Creating the protocol method callers 147 ■ Making a class conform to a protocol 148 Download from Wow! eBook <www.wowebook.com> CONTENTS xi 7.3 Important protocols 150 <UITableViewDataSource> 150 ■ <UITableViewDelegate> 153 <UIActionSheetDelegate> 157 ■ NSXMLParser 158 7.4 Summary 162 Dynamic typing and runtime type information 163 8 8.1 Static vs. dynamic typing 164 Making assumptions about the runtime type 164 8.2 Dynamic binding 166 8.3 How messaging works 166 Methods, selectors, and implementations 167 Handling unknown selectors 169 ■ Sending a message to nil 170 8.4 Runtime type information 171 Determining if a message will respond to a message 171 Sending a message generated at runtime 171 Adding new methods to a class at runtime 173 8.5 Practical uses of runtime type introspection 174 8.6 Summary 176 Memory management 177 9 9.1 Object ownership 178 9.2 Reference counting 179 Releasing an object 180 ■ Retaining an object 181 Determining the current retain count 182 9.3 Autorelease pools 184 What is an autorelease pool? 185 ■ Adding objects to the autorelease pool 185 ■ Creating a new autorelease pool 185 ■ Releasing objects in a pool 187 Why not use an autorelease pool for everything? 187 9.4 Memory zones 190 9.5 Rules for object ownership 192 9.6 Responding to low-memory warnings 193 Implementing the UIApplicationDelegate protocol 193 Overriding didReceiveMemoryWarning 194 ■ Observing the UIApplicationDidReceiveMemoryWarningNotification 197 9.7 Summary 199 Download from Wow! eBook <www.wowebook.com> xii CONTENTS PART 3 MAKING MAXIMUM USE OF FRAMEWORK FUNCTIONALITY.............................................201 Error and exception handling 203 10 10.1 NSError—handling errors the Cocoa way 204 Getting NSError to talk 204 ■ Examining NSError’s userInfo Dictionary 205 10.2 Creating NSError objects 206 Introducing RentalManagerAPI 206 ■ Handling and displaying RentalManagerAPI errors 209 10.3 Exceptions 210 Throwing exceptions 210 ■ Catching exceptions 211 10.4 Summary 211 Key-Value Coding and NSPredicate 212 11 11.1 Making your objects KVC-compliant
Recommended publications
  • Scoping Changes with Method Namespaces
    Scoping Changes with Method Namespaces Alexandre Bergel ADAM Project, INRIA Futurs Lille, France [email protected] Abstract. Size and complexity of software has reached a point where modular constructs provided by traditional object-oriented programming languages are not expressive enough. A typical situation is how to modify a legacy code without breaking its existing clients. We propose method namespaces as a visibility mechanism for behavioral refine- ments of classes (method addition and redefinition). New methods may be added and existing methods may be redefined in a method namespace. This results in a new version of a class accessible only within the defining method namespace. This mechanism, complementary to inheritance in object-orientation and tradi- tional packages, allows unanticipated changes while minimizing the impact on former code. Method Namespaces have been implemented in the Squeak Smalltalk system and has been successfully used to provide a translated version of a library without ad- versely impacting its original clients. We also provide benchmarks that demon- strate its application in a practical setting. 1 Introduction Managing evolution and changes is a critical part of the life cycle of all software sys- tems [BMZ+05, NDGL06]. In software, changes are modeled as a set of incremental code refinements such as class redefinition, method addition, and method redefinition. Class-based object-oriented programming languages (OOP) models code refinements with subclasses that contain behavioral differences. It appears that subclassing is well adapted when evolution is anticipated. For example, most design patterns and frame- works rely on class inheritance to express future anticipated adaptation and evolution. However, subclassing does not as easily help in expressing unanticipated software evo- lution [FF98a, BDN05b].
    [Show full text]
  • Preview Objective-C Tutorial (PDF Version)
    Objective-C Objective-C About the Tutorial Objective-C is a general-purpose, object-oriented programming language that adds Smalltalk-style messaging to the C programming language. This is the main programming language used by Apple for the OS X and iOS operating systems and their respective APIs, Cocoa and Cocoa Touch. This reference will take you through simple and practical approach while learning Objective-C Programming language. Audience This reference has been prepared for the beginners to help them understand basic to advanced concepts related to Objective-C Programming languages. Prerequisites Before you start doing practice with various types of examples given in this reference, I'm making an assumption that you are already aware about what is a computer program, and what is a computer programming language? Copyright & Disclaimer © Copyright 2015 by Tutorials Point (I) Pvt. Ltd. All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or in this tutorial, please notify us at [email protected] ii Objective-C Table of Contents About the Tutorial ..................................................................................................................................
    [Show full text]
  • Analyzing Safari 2.X Web Browser Artifacts Using SFT
    Analyzing Safari 2.x Web Browser Artifacts using SFT. Copyright 2007 - Jacob Cunningham (v1.0) Table of Contents Introduction:...............................................................................................................................................3 Safari Forensic Tools................................................................................................................................. 3 OSX Property List files..............................................................................................................................3 Safari Related Files.................................................................................................................................... 4 The Safari Preferences files....................................................................................................................... 5 Browser History......................................................................................................................................... 7 Downloads history:.................................................................................................................................... 8 Bookmarks file ........................................................................................................................................10 Cookies file:............................................................................................................................................. 11 Browser Cache........................................................................................................................................
    [Show full text]
  • Developer's Guide Sergey A
    Complex Event Processing with Triceps CEP v1.0 Developer's Guide Sergey A. Babkin Complex Event Processing with Triceps CEP v1.0 : Developer's Guide Sergey A. Babkin Copyright © 2011, 2012 Sergey A. Babkin All rights reserved. This manual is a part of the Triceps project. It is covered by the same Triceps version of the LGPL v3 license as Triceps itself. The author can be contacted by e-mail at <[email protected]> or <[email protected]>. Many of the designations used by the manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this manual, and the author was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this manual, the author assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Table of Contents 1. The field of CEP .................................................................................................................................. 1 1.1. What is the CEP? ....................................................................................................................... 1 1.2. The uses of CEP ........................................................................................................................ 2 1.3. Surveying the CEP langscape ....................................................................................................... 2 1.4. We're not in 1950s any more,
    [Show full text]
  • Operating System Engineering, Lecture 3
    6.828 2012 Lecture 3: O/S Organization plan: O/S organization processes isolation topic: overall o/s design what should the main components be? what should the interfaces look like? why have an o/s at all? why not just a library? then apps are free to use it, or not -- flexible some tiny O/Ss for embedded processors work this way key requirement: support multiple activities multiplexing isolation interaction helpful approach: abstract services rather than raw hardware file system, not raw disk TCP, not raw ethernet processes, not raw CPU/memory abstractions often ease multiplexing and interaction and more convenient and portable note: i'm going to focus on mainstream designs (xv6, Linux, &c) for *every* aspect, someone has done it a different way! example: exokernel and VMM does *not* abstract anything! xv6 has only a few abstractions / services processes (cpu, mem) I/O (file descriptors) file system i'm going to focus on xv6 processes today a process is a running program it has its own memory, share of CPU, FDs, parent, children, &c it uses system calls to interact outside itself to get at kernel services xv6 basic design here very traditional (UNIX/Linux/&c) xv6 user/kernel organization h/w, kernel, user kernel is a big program services: process, FS, net low-level: devices, VM all of kernel runs w/ full hardware privilege (very convenient) system calls switch between user and kernel 1 good: easy for sub-systems to cooperate (e.g. paging and file system) bad: interactions => complex, bugs are easy, no isolation within o/s called "monolithic";
    [Show full text]
  • Investigating Powershell Attacks
    Investigating PowerShell Attacks Black Hat USA 2014 August 7, 2014 PRESENTED BY: Ryan Kazanciyan, Matt Hastings © Mandiant, A FireEye Company. All rights reserved. Background Case Study WinRM, Victim VPN SMB, NetBIOS Attacker Victim workstations, Client servers § Fortune 100 organization § Command-and-control via § Compromised for > 3 years § Scheduled tasks § Active Directory § Local execution of § Authenticated access to PowerShell scripts corporate VPN § PowerShell Remoting © Mandiant, A FireEye Company. All rights reserved. 2 Why PowerShell? It can do almost anything… Execute commands Download files from the internet Reflectively load / inject code Interface with Win32 API Enumerate files Interact with the registry Interact with services Examine processes Retrieve event logs Access .NET framework © Mandiant, A FireEye Company. All rights reserved. 3 PowerShell Attack Tools § PowerSploit § Posh-SecMod § Reconnaissance § Veil-PowerView § Code execution § Metasploit § DLL injection § More to come… § Credential harvesting § Reverse engineering § Nishang © Mandiant, A FireEye Company. All rights reserved. 4 PowerShell Malware in the Wild © Mandiant, A FireEye Company. All rights reserved. 5 Investigation Methodology WinRM PowerShell Remoting evil.ps1 backdoor.ps1 Local PowerShell script Persistent PowerShell Network Registry File System Event Logs Memory Traffic Sources of Evidence © Mandiant, A FireEye Company. All rights reserved. 6 Attacker Assumptions § Has admin (local or domain) on target system § Has network access to needed ports on target system § Can use other remote command execution methods to: § Enable execution of unsigned PS scripts § Enable PS remoting © Mandiant, A FireEye Company. All rights reserved. 7 Version Reference 2.0 3.0 4.0 Requires WMF Requires WMF Default (SP1) 3.0 Update 4.0 Update Requires WMF Requires WMF Default (R2 SP1) 3.0 Update 4.0 Update Requires WMF Default 4.0 Update Default Default Default (R2) © Mandiant, A FireEye Company.
    [Show full text]
  • “A Magnetzed Needle and a Steady Hand”
    “A Magne)zed Needle and a Steady Hand” Alternaves in the modern world of Integrated Development Environments Jennifer Wood CSCI 5828 Spring 2012 Real Programmers hp://xkcd.com/378/ For the rest of us • Modern Integrated Development Environments (IDE) – A one-stop shop with mul)ple features that can be easily accessed by the developer (without switching modes or ac)vang other u)li)es) to ease the task of creang soYware – A mul)tude of IDEs exist for each programming language (Java, C++, Python, etc.) and each plaorm (desktops, cell phones, web-based, etc.) – Some IDEs can handle mul)ple programming languages, but most are based in just one – There are many good free IDEs out there, but you can also pay for func)onality from $ to $$$$ – IDEs are like opinions, everyone has one and everyone thinks everyone else's s)nks Why are IDEs a good thing? • They aack many of the sources of accidental difficul)es in soYware development by having: – Real-)me protec)on from fault generang typos and bad syntax – High levels of abstrac)on to keep developers from being forced to redevelop basic (and not so basic) classes and structures for every project – IDE increases the power of many development tools by merging them into one that provides “integrated libraries, unified file formats, and pipes and filters. As a result, conceptual structures that in principle could always call, feed, and use one another can indeed easily do so in prac)ce.” (Brooks, 1987). • A core focus of IDE developers is con)nuous improvement in transparency to minimize searching for func)ons
    [Show full text]
  • The Design of a Pascal Compiler Mohamed Sharaf, Devaun Mcfarland, Aspen Olmsted Part I
    The Design of A Pascal Compiler Mohamed Sharaf, Devaun McFarland, Aspen Olmsted Part I Mohamed Sharaf Introduction The Compiler is for the programming language PASCAL. The design decisions Concern the layout of program and data, syntax analyzer. The compiler is written in its own language. The compiler is intended for the CDC 6000 computer family. CDC 6000 is a family of mainframe computer manufactured by Control Data Corporation in the 1960s. It consisted of CDC 6400, CDC 6500, CDC 6600 and CDC 6700 computers, which all were extremely rapid and efficient for their time. It had a distributed architecture and was a reduced instruction set (RISC) machine many years before such a term was invented. Pascal Language Imperative Computer Programming Language, developed in 1971 by Niklaus Wirth. The primary unit in Pascal is the procedure. Each procedure is represented by a data segment and the program/code segment. The two segments are disjoint. Compiling Programs: Basic View Machine Pascal languag program Pascal e compile program filename . inpu r gp output a.out p t c Representation of Data Compute all the addresses at compile time to optimize certain index calculation. Entire variables always are assigned at least one full PSU “Physical Storage Unit” i.e CDC6000 has ‘wordlength’ of 60 bits. Scalar types Array types the first term is computed by the compiler w=a+(i-l)*s Record types: reside only within one PSU if it is represented as packed. If it is not packed its size will be the size of the largest possible variant. Data types … Powerset types The set operations of PASCAL are realized by the conventional bit-parallel logical instructions ‘and ‘ for intersection, ‘or’ for union File types The data transfer between the main store buffer and the secondary store is performed by a Peripheral Processor (PP).
    [Show full text]
  • Entry Point Specification
    EMV® Contactless Specifications for Payment Systems Book B Entry Point Specification Version 2.6 July 2016 © 2016 EMVCo, LLC. All rights reserved. Reproduction, distribution and other use of this document is permitted only pursuant to the applicable agreement between the user and EMVCo found at www.emvco.com. EMV® is a registered trademark or trademark of EMVCo, LLC in the United States and other countries. EMV Contactless Book B Entry Point Specification version 2.6 Legal Notice The EMV® Specifications are provided “AS IS” without warranties of any kind, and EMVCo neither assumes nor accepts any liability for any errors or omissions contained in these Specifications. EMVCO DISCLAIMS ALL REPRESENTATIONS AND WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT, AS TO THESE SPECIFICATIONS. EMVCo makes no representations or warranties with respect to intellectual property rights of any third parties in or in relation to the Specifications. EMVCo undertakes no responsibility to determine whether any implementation of the EMV® Specifications may violate, infringe, or otherwise exercise the patent, copyright, trademark, trade secret, know-how, or other intellectual property rights of third parties, and thus any person who implements any part of the EMV® Specifications should consult an intellectual property attorney before any such implementation. Without limiting the foregoing, the Specifications may provide for the use of public key encryption and other technology, which may be the subject matter of patents in several countries. Any party seeking to implement these Specifications is solely responsible for determining whether its activities require a license to any such technology, including for patents on public key encryption technology.
    [Show full text]
  • CS 403/503: Programming Languages
    BNF for <expression> <expression> → identifier | number | CS 403 -<expression> | (<expression>) | <expression><operator><expression> Organization of Programming Languages <operator> → + | - | * | / Class 3 - August 30, 2001 Topics For Today Parse Tree Review of BNF (Chapter 2.1) Derivations and parse trees (Chapter 2.1) Binding time (Chapter 3.1) Object lifetime and storage slope * x + intercept management (Chapter 3.2) BNF Concept Review Another Parse Tree Terminal symbols: Actual items that are part of the language (0,1,+,-,*,/,etc.) Non-Terminal symbols: <expr>, <op>, etc. Rule/production: A single line of BNF Alternatives: Expressed with | Also: slope * x + intercept *: 0 or more occurrences +:1 or more occurrences 1 Binding Lifetimes • Binding lifetime: The period of time Def: A binding is an association, such between the creation and destruction of a as between an attribute and an entity, name-to-object binding • Object lifetime: The period of time or between an operation and a between the creation and destruction of symbol. an object • These don’t necessarily coincide Def: Binding time is the time at which a • EX. Reference parameters binding takes place. Possible binding times Object Lifetimes… 1. Language design time--e.g., bind operator …correspond to one of three principal symbols to operations 2. Language implementation time--e.g., bind fl. pt. storage allocation mechanisms: type to a representation Static objects: Object lifetime = program 3. Compile time--e.g., bind a variable to a type in C execution. Object bound to one storage or Java location from load time on. 4. Load time--e.g., bind a FORTRAN 77 variable to a memory cell (or a C static variable) Stack objects: Object lifetime = subroutine 5.
    [Show full text]
  • Resource Management: Linux Kernel Namespaces and Cgroups
    Resource management: Linux kernel Namespaces and cgroups Rami Rosen [email protected] Haifux, May 2013 www.haifux.org 1/121 http://ramirose.wix.com/ramirosen TOC Network Namespace PID namespaces UTS namespace Mount namespace user namespaces cgroups Mounting cgroups links Note: All code examples are from for_3_10 branch of cgroup git tree (3.9.0-rc1, April 2013) 2/121 http://ramirose.wix.com/ramirosen General The presentation deals with two Linux process resource management solutions: namespaces and cgroups. We will look at: ● Kernel Implementation details. ●what was added/changed in brief. ● User space interface. ● Some working examples. ● Usage of namespaces and cgroups in other projects. ● Is process virtualization indeed lightweight comparing to Os virtualization ? ●Comparing to VMWare/qemu/scaleMP or even to Xen/KVM. 3/121 http://ramirose.wix.com/ramirosen Namespaces ● Namespaces - lightweight process virtualization. – Isolation: Enable a process (or several processes) to have different views of the system than other processes. – 1992: “The Use of Name Spaces in Plan 9” – http://www.cs.bell-labs.com/sys/doc/names.html ● Rob Pike et al, ACM SIGOPS European Workshop 1992. – Much like Zones in Solaris. – No hypervisor layer (as in OS virtualization like KVM, Xen) – Only one system call was added (setns()) – Used in Checkpoint/Restart ● Developers: Eric W. biederman, Pavel Emelyanov, Al Viro, Cyrill Gorcunov, more. – 4/121 http://ramirose.wix.com/ramirosen Namespaces - contd There are currently 6 namespaces: ● mnt (mount points, filesystems) ● pid (processes) ● net (network stack) ● ipc (System V IPC) ● uts (hostname) ● user (UIDs) 5/121 http://ramirose.wix.com/ramirosen Namespaces - contd It was intended that there will be 10 namespaces: the following 4 namespaces are not implemented (yet): ● security namespace ● security keys namespace ● device namespace ● time namespace.
    [Show full text]
  • C++/CLI Language Specification
    Ecma/TC39-TG5/2004/25 C++/CLI Language Specification Working Draft 1.5, Jun, 2004 Public Review Document Text highlighted like this indicates a placeholder for some future action. It might be a note from the editor to himself, or an indication of the actual or expected direction of some as-yet open issue. Note: In the spirit of the "Working Draft, Standard for Programming Language C++", this is an early draft. It’s known to be incomplet and incorrekt, and it has lots of bad formatting. Publication Time: 6/17/2004 11:44 PM Table of Contents Table of Contents Introduction....................................................................................................................................................xi 1. Scope............................................................................................................................................................. 1 2. Conformance ............................................................................................................................................... 2 3. Normative references .................................................................................................................................. 3 4. Definitions .................................................................................................................................................... 4 5. Notational conventions................................................................................................................................ 7 6. Acronyms and abbreviations
    [Show full text]