CHAPTER 1 The CLR’s Execution Model Flashcards
What is CLR
a runtime that is usable by different and varied programming languages
core features of the CLR
memory management assembly loading security exception handling thread synchronization
managed modules
Compiling source code result
managed assemblies advantage
Data Execution Prevention
Address Space Layout Randomization
Parts of a Managed Module
PE32 or PE32+ header
CLR header
Metadata
IL code
managed code
IL code is sometimes referred to as managed code because the CLR manages its execution
Metadata usage
Metadata removes the need for native C/C++ header and library files when compiling
Microsoft Visual Studio uses metadata to help you write code
The CLR’s code verification process uses metadata to ensure that your code performs only “type-safe” operations
Metadata allows an object’s fields to be serialized into a memory block, sent to another machine, and then deserialized, re-creating the object’s state on the remote machine
Metadata allows the garbage collector to track the lifetime of objects
assembly
First, an assembly is a logical grouping of one or more modules or resource files.
Second, an assembly is the smallest unit of reuse, security, and versioning.
In the CLR world, an assembly is what we would call a component.
What is IL
IL is a CPU-independent machine language
IL is a much higher-level language than most CPU machine languages.
IL as an object-oriented machine language
how executing assembly’s code
IL must first be converted to native CPU instructions. This is the job of the
CLR’s JIT (just-in-time) compiler
IL verification
Verification examines the high-level IL code and ensures that everything the code does is safe。
Unsafe code
Unsafe code is allowed to work
directly with memory addresses and can manipulate bytes at these addresses.
This is a very powerful feature and is typically useful when interoperating with unmanaged code or when you want to
improve the performance of a time-critical algorithm.
what is NGen.exe tool
compile IL code to native code
NGen.exe tool pro
Improving an application’s startup time
Reducing an application’s working set
NGen.exe tool con
No intellectual property protection
NGen’d files can get out of sync
Inferior execution-time performance
FCL
the Framework Class Library
CTS
the Common Type System that describes
how types are defined and how they behave
CLS
Common Language Specification that details for compiler vendors the minimum set of features their compilers must support if these compilers are to generate types compatible with other components written by other CLS-compliant languages on top of the CLR
Interoperability with Unmanaged Code
Managed code can call an unmanaged function in a DLL
Managed code can use an existing COM component (server)
Unmanaged code can use a managed type (server)