Wednesday, May 9, 2007

Before Time Stopped

NatGeo carries out a series named 'Before Time Stopped'. It speaks about what happened before something started like one which told about how earth was formed.

Similarly in .NET, before execution starts a lot of things happen:

1) You develop something in C#
2) You compile it using the C# compiler
3) The C# compiler spits out IL code and a manifest into a read-only part of the exe that has a standard PE header.
4) The compiler also imports a function named _CorExeMain from the .NET EE
5) When you attempt to run the PE, the OS loads the PE (which loads the DLL that exports the _CorExeMain function: MSCorEE.DLL).
7) The OS loader then jumps to the entry-point inside the PE (put there by the C# compiler)
8) That code is just a small stub that jumps to the _CorExeMain function
9) _CorExeMain then starts the execution of the managed code that was placed in the PE
10) Since IL can not be executed directly, the EE compiles the IL using a JITter into native CPU instructions as it processes the IL. This part only occurs as functions are called the first time.

and hence time starts ..

No comments: