Introduction to AppDomains

Slides:



Advertisements
Similar presentations
Ahead of Time Dynamic Translation PreJit/NGEN by any other name George Bosworth Microsoft MRE04 March 21, 2004.
Advertisements

Linking & Loading CS-502 Operating Systems
CS 31003: Compilers ANIRUDDHA GUPTA 11CS10004 G2 CLASS DATE : 24/07/2013.
Deployment Your Salvation from DLL Hell. Objectives Overview Assemblies „XCopy“ Deployment Configuration Administration.
Loader- Machine Independent Loader Features
Assembly Where it all gets physical. Objectives Introduce concepts of assemblies Discuss elements of assemblies Show how to build assemblies Runtime aspects.
ASP.Net Security: Fundamentals Chapters 1-4 Freeman and Jones Book.
Chapter 6 - Implementing Processes, Threads and Resources Kris Hansen Shelby Davis Jeffery Brass 3/7/05 & 3/9/05 Kris Hansen Shelby Davis Jeffery Brass.
Types of software. Sonam Dema..
Lecture Roger Sutton CO530 Automation Tools 5: Class Libraries and Assemblies 1.
Introduction to .Net Framework
Introduction to ASP.NET. Prehistory of ASP.NET Original Internet – text based WWW – static graphical content  HTML (client-side) Need for interactive.
CIS NET Applications1 Chapter 2 –.NET Component- Oriented Programming Essentials.
.NET Framework & C#.
Understanding Code Compilation and Deployment Lesson 4.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
JIT in webkit. What’s JIT See time_compilation for more info. time_compilation.
ASSEMBLIES AND THE GAC CHAPTER 1, LESSONS 4-7 & LAB.
.NET Framework Danish Sami UG Lead.NetFoundry
© Janice Regan, CMPT 300, May CMPT 300 Introduction to Operating Systems Memory: Relocation.
Writing a Run Time DLL The application loads the DLL using LoadLibrary() or LoadLibraryEx(). The standard search sequence is used by the operating system.
Win32 Programming Lesson 19: Introduction to DLLs.
The Execution System1. 2 Introduction Managed code and managed data qualify code or data that executes in cooperation with the execution engine The execution.
Text Introduction to.NET Framework. CONFIDENTIAL Agenda .NET Training – Purpose  What is.NET?  Why.NET?  Advantages  Architecture  Components: CLR,
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
OE-NIK HP Advanced Programming Using and creating DLL files.
Just-In-Time Compilation. Introduction Just-in-time compilation (JIT), also known as dynamic translation, is a method to improve the runtime performance.
Adding Concurrency to a Programming Language Peter A. Buhr and Glen Ditchfield USENIX C++ Technical Conference, Portland, Oregon, U. S. A., August 1992.
Prof. Jong-Moon Chung’s Lecture Notes at Yonsei University
Computer System Structures
Object Oriented Programming in
Visit for more Learning Resources
INF230 Basics in C# Programming
Processes and threads.
Memory management.
Outline Introduction to the Phalanger System
Maintaining Windows Server 2008 File Services
An Introduction to the Shared Source Common Language Infrastructure (SSCLI) Damien Watkins Copyright Watkins 2002.
File System Implementation
Using Application Domains Effectively
Compiler Construction (CS-636)
Linking & Loading.
Chapter 4 Threads.
Writing Highly Available .Net Framework Applications
Security mechanisms and vulnerabilities in .NET
CS-3013 Operating Systems C-term 2008
Oracle Solaris Zones Study Purpose Only
2.1. Compilers and Interpreters
Chapter 3: Windows7 Part 4.
.NET and .NET Core 2. .NET Runtimes Pan Wuming 2017.
Module 1: Getting Started
Introduction to C# AKEEL AHMED.
Chapter 2: The Linux System Part 2
Machine Independent Features
Chapter 2: System Structures
Chapter 3: Operating-System Structures
Module IV Memory Organization.
Memory Management Tasks
Computer Organization and Design Assembly & Compilation
Linking & Loading CS-502 Operating Systems
Module 10: Implementing Managed Code in the Database
Linking & Loading CS-502 Operating Systems
DOT NET ARCHITECTURE (OR) DOT NET FRAME WORK ARCHITECTURE
Web Servers (IIS and Apache)
.Net Application Domains
JIT Compiler Design Maxine Virtual Machine Dhwani Pandya
IIS and .NET Security Application Pools Pamella Smith June 18, 2009.
ASP.NET Core Middleware Fundamentals
How to install and manage exchange server 2010 OP Saklani.
Presentation transcript:

Introduction to AppDomains - Vijay Appadurai Brown Bag Seminar 2005

Introduction Many environments have their own models of scoping code execution For IIS and ASP it is the virtual directory; for an Operating System it is a process For the .Net Common Language Runtime (CLR), the AppDomain is the fundamental scope of code execution.

Execution Scope and CLR A process is an abstraction created by an Operating System whereas an AppDomain is an abstraction created by the CLR. An AppDomain can reside in exactly one OS process But an OS process can host multiple AppDomains.

Objects and Types An object resides in exactly one AppDomain, as do values. Object references must refer to objects in the same AppDomain. Like objects, types reside in exactly one AppDomain. So if two AppDomains need to use a type, one must initialize and allocate the type once per AppDomain

Types cont. If a type is used in more than one AppDomain, one must load and initialize the type’s module and assembly once for each AppDomain the type is used in. Since each such AppDomain maintains a separate copy of the type, each has its own private copy of the type’s static fields.

Resources and Memory An AppDomains’ resources are held in memory as long as the owning AppDomain is loaded. Unloading an AppDomain is the only way to unload a module or an assembly or to reclaim the memory consumed by a type’s static fields.

Threads and AppDomains A CLR System.Threading.Thread object is different from an OS hard thread, and is referred to as a soft thread. A soft thread resides in exactly one AppDomain. A given AppDomain can have multiple soft thread objects. If a hard thread winds up executing code in multiple AppDomains, each AppDomain will have a distinct soft thread object affiliated with it for a given AppDomain.

AppDomain Events The AppDomain Type supports a handful of events that allow interested parties to be notified of significant conditions in a running program. Events: AssemblyLoad AssemblyResolve TypeResolve ResourceResolve DomainUnload ProcessExit Unhandled Exception

AppDomains and Assembly Resolver AppDomains play a critical role in controlling the behavior of the assembly resolver Each AppDomain can have its own APPBASE and configuration file. So each can have its own probe path and version policy The AppDomain stores the properties used by the assembly resolver in a data structure called AppDomainSetup which is maintained on a per-AppDomain basis.

AppDomains and Dynamic Directories Consider the case in which an application needs to generate code dynamically. If the application needs to load the code by probing, then the application needs to have write access to a directory underneath APPBASE However we may want to execute code from a read-only part of file system.

Dynamic Directories This means that we need to have an alternate location for dynamic code generation. This is the role of the AppDomain.DynamicDirectory property. Each AppDomain may have at most one dynamic directory. This dynamic directory is added automatically to the probe path. ASP.Net is a heavy user of this feature

Shadow Copying Shadow copying addresses the problem related to server side development and deployment. The classic Win32 loader takes a read lock on a file that it loads to ensure that no changes are made to the underlying executable image. So overwriting this dll with a new version requires shutting down the server.

.Net Solution In .Net we have the shadow copying facility. When the CLR loads an assembly using shadow copying, a temporary copy of the underlying files is made in a different directory. These temporary files are loaded in lieu of the original assemblies. When shadow copying is enabled for an AppDomain, we need to specify two directory paths.

Shadow Copying cont. One path is the directory which needs to be shadow copied. The other is the path to which it needs to be shadow copied. This can be accomplished using the SetShadowCopyPath() and the SetCachePath() functions provided by the AppDomain class. Again, ASP.NET is a heavy user of this feature

AppDomains and Code Management Each AppDomain has its own private copy of a type’s static data. The JIT compiler can generate code either on a per-AppDomain basis or on a per-process basis. So we can decide which one to use. There are three types of Loader Optmizations SingleDomain MultiDomain MultiDomainHost

SingleDomain The SingleDomain assumes that the process will contain only one AppDomain. The JIT compiler therefore generates machine code seperately for each domain. This makes static field access faster and because we expect only one AppDomain we generate only one copy of machine code.

MultiDomain The MultiDomain flag assumes that the process contains several AppDomains running the same application. The JIT compiler generates only one machine code for the entire process. This makes static field access slower but significantly reduces memory needed.

MultiDomain Host This flag assumes that the process will contain several AppDomains, each of which will run different Application code. In this hybrid mode, only assemblies loaded from the GAC share machine code. (MultiDomain) Assemblies not loaded from GAC are assumed to be used only by the loading AppDomain.(SingleDomain) ASP.Net uses this flag.

Reference Essential .Net – Don Box MSDN