.Net PowerPoint PPT Presentation

presentation player overlay
1 / 20
About This Presentation
Transcript and Presenter's Notes

Title: .Net


1
.Nets Common Language Runtime How does
it really work?Presented byArjun Kumar
Polu Instructor Dr. Ravi
Mukkamala
2
Overview
  • What is CLR Why we need it?
  • CLR Architecture
  • How does CLR work?
  • What is its role in .Net Security?
  • Managed vs Unmanaged code
  • Conclusion

3
Microsoft .NET Framework Architecture
Microsoft Visual Basic .NET
C
C
Microsoft JScript

Microsoft Visual Studio .NET
Common Language Specification
Framework Class Library
Common Language Runtime
Windows
LINUX
4
What is CLR?
  • CLR is Common Language Runtime
  • The CLR is actually an environment in which we
    can run our .NET applications that have been
    compiled to IL (Intermediate language).
  • CLR is analogous to JRE in Java.
  • CLR facilitates
  • Runtime Environment
  • Runtime Services

5
CLR Facilitates
  • 1.Run-time environment CLR Compiles
    application into the runtime, compile the IL
    code into native code, execute the code
  • 2.Run-time services like a. Memory management,
    b. Type safety, c. Enforces Security, d.
    Exception Management. e. Thread support f.
    Debugging support

6
Execution of an .Net application
7
Architecture of CLR
8
Functions of each Module in CLR
  • Class loader, which loads classes into CLR.
  • MSIL to native code compiles, this converts MSIL
    code into native code.
  • Code manager, this manages the code during
    execution.
  • Memory allocation and Garbage collector, this
    performs automatic memory management.
  • Security engine, this enforces security
    restrictions as code level security folder level
    and machine level security using tools provided
    by Microsoft .NET and using .NET Framework
    setting under control panel.

9
Functions of each Module in CLR
  • Type checker, which enforces strict type
    checking.
  • Thread support, which provides multithreading
    support to applications.
  • Exception manager, which provides a mechanism to
    handle the run-time exceptions handling.
  • Debug engine, which allows developer to debug
    different types of applications.
  • COM marshaler, which allows .NET applications to
    exchange data with COM applications.
  • Base class library support, which provides the
    classes (types) that the applications need at run
    time.

10
C Code
CCompiler
CLR
IL
JITCompiler
Visual Basic Code
Visual BasicCompiler
COBOL Code
COBOL Compiler
NativeCode
11
JIT Compilers
  • The IL code is compiled to native machine and is
    not interpreted at all. For such a compilation
    the CLR uses the following two JIT compilers
  • Econo-JIT This compiler has a very fast
    compilation time but it produces un-optimized
    code - thus the program may start quickly but
    would run slow. This compiler is suitable for
    running scripts.
  • Standard-JIT This compiler has a slow
    compilation time but it produces highly
    optimized code. Most of the times the CLR would
    use this compiler to run your IL code.

12
Role of CLR in .Net Security
  • CLR enforces security in following manner
  • To control and access the system resources like
    hard disk
  • To control and access the network connections
  • To control and access the other hard ware
    resources.

13
Managed Code
  • The code which can be executed by the CLR is
    managed code.
  • Managed code gives information to the CLR for
    multiple run-time services in .Net Framework.
  • This information is stored in the form of
    metadata inside the PE file.
  • Managed data is allocated and released from
    memory automatically by garbage collection.
  • Managed data can be accessible from managed code
    but managed code can be accessible from managed
    and unmanaged data.

14
Managed Code Execution steps
  • Managed code execution is known as the process
    executed by the CLR which is as follows
  • CLR loads the MSIL refers metadata,
  • CLR executes the Native code,
  • CLR provides automatic memory management.
  • Managed execution also performs JIT compilations,
  • Ensuring type safety,
  • Enforcing security,
  • Handling exceptions.

15
Unmanaged Code
  • The code which is executed without the
    involvement of CLR is unmanaged code.
  • Any code that tries to bypass the CLR and
    attempts to handle the functions like memory
    management is considered "unsafe.
  • The compiler would not compile the code.

16
Unmanaged Demo
  • using System
  • using System.Collections.Generic
  • using System.Text
  • namespace UnsafeApplication
  • class Program
  • static unsafe void Main(string args)
  • int MyInteger 123
  • int MyIntegerPointer MyInteger
  • Console.WriteLine(MyIntegerPointer)
  • Console.ReadLine()

17
Memory Management
  • Automatic memory management means no need to
    write code to allocate memory when objects are
    created or to release memory when objects are not
    required the application.
  • Automatic memory management involves
  • Allocation of memory
  • Deallocation of Memory

18
Garbage Collector
  • Garbage Collector will take care of memory
    management in managed code.
  • Garbage collector improves performance as it uses
    memory allocation algorithm employed by the CLR
    is much faster than the memory allocation
    routines used in C runtime.
  • Garbage collection occurs infrequently which will
    have effect on the performance of the application
    as that process stops momentarily during that
    period.

19
Conclusion
  • CLR is heart and soul for the Dot Net. Then we
    have gone through the need for such an
    environment and then we have seen the
    architecture of the CLR and the working of the
    CLR.
  • Then we have gone through the managed and
    unmanaged code, then through the different JIT
    compilers . Then through the memory management
    and finally Garbage collector.

20
References
  • http//www.codeproject.com/dotnet/clr.asp_clr
  • http//www.codeproject.com/dotnet/DotNetWhitePaper
    .asp
  • http//www.codeproject.com/useritems/C__basics.asp
  • http//msdn2.microsoft.com/en-us/library/ddk909ch.
    aspx
Write a Comment
User Comments (0)
About PowerShow.com