Platform Architecture
Mike Zintel
Development Manager
.NET Compact Framework
Microsoft Corporation
Agenda



Design goals
Internals of the platform
Key features that enable applications
Platform Design Goals


Portable & small .NET Common
Language Runtime
Leverage .NET tools



Peacefully co-exist with host OS


Run .EXEs generated by .NET tools
Cross-debug with VS.NET
Scheduling, UI display surface & input,
resource contention
Enable rich client Web Services apps

GUI, local storage, networking
.NET Terminology




Execution Engine (EE)
Common Language Runtime (CLR)
.NET Compact Framework
Programming Frameworks




Class Libraries
Native Code, Managed Code, IL
Common Language Runtime
Applications
OEM Application
Developing A .NET App
D e ve lo p m e n t
T e stin g o n W in d o w s
V S .N ET
.N ET
Ed it
(M u lt ip le L ang .) C o m p ile
So ur ce Co de
C om p ilers
T a rg e t P la tfo rm s
V S .N ET
Run &
De bug
C L R A p p licat io n D e p lo y
.N ET C F
C L R A p p licat io n
( .EX E & DL L s )
( .EX E & DL L s )
.N ET C F
.N ET C F
.N ET C F
C lass L ib r ar ies
C lass L ib r ar ies
C lass L ib r ar ies
.N ET C F
.N ET C F
Exe cu t io n En g ine
Exe cu t io n En g ine
W in 32 PA L
W in d ow s
Ho s t O/S
PA L & NSLs
Ho s t
Op er at ing Sys tem
.NET CLR Features

Verifiable typesafe execution


Garbage Collection


No ref-counting, no leaks
JIT compilation


No unsafe casts, no uninitialized variables,
no out of bounds array indexing, no bad
pointer math
Portable & fast
Common type system

Call, inherit, and source-level debug across
different languages
.NET API Design

Code and data are expressed as classes





Described in metadata, no .h or idl files
Inheritance can be used to extend a class
APIs work across languages
APIs are organized in namespaces with
strong naming conventions
Garbage Collection eliminates memory
ownership issues
.NET Error Handling

Error handling through exceptions


Error handling is mandatory


Not bools or HRESULTS
Default isn’t to “muddle on”
Descriptive exception messages

Not cryptic HRESULTS
Language Support

Plans for…






C#
VB.NET
JScript (ECMAScript)
Will deliver in staggered fashion
Platform extensible to other languages
VS.NET packages planned for C#, VB
Different Types of Host O/S

Static address space





System image defined at manufacturing time
pSOS, OSE, many custom O/S
Boot loader only
No “application” loader or interactive shell
CLR adds app loader, makes system extensible


Apps run in “App Domains”
Dynamic address space



Boot loader & application loader
Windows, Unix
Shell is provided by the O/S
System Architecture
C LR Ap ps
la u n c h
C LR Ap ps
.N E T
C o m pa c t
F ram ew o rk
P la tf orm E x te ns ion F ra m ew ork s
B ase F ra m ew orks (C la ss L ibs)
A pp D o m a in H ost
m a n a ge d
E xecu t ion E ng ine
A pp D o m ai n Lo ad er
I nstr uctio n E ngi ne/JIT
C lass Lo a der
G arb age C o llec tio n
V erif ie r
P /I nvo ke
D eb ug ge r
CLR
n a tive
N at iv e S u pp o rt L ibs (N S L)
P la tf orm A da pt at ion La ye r (P A L)
H o st O /S
H ost O /S A pp s
H ost O /S S e rv ices
B o o t Lo ader
T im ers
T hr ead s
N et wo rki ng
S ync
Filesyst em s
H ard w are D rive rs
H a rdw a re
Execution Engine





Class loader, verifier, JIT, GC, exception
handling, code access security,
debugging
Provides hardware and O/S independent
program execution
No MMU required on the target CPU
Garbage collection eliminates reference
counting and leaks
JIT architecture for fast execution
Supported Data Types
I1 (SByte)
8-bit 2's complement signed value
U1 (Boolean , Byte)
8-bit unsigned binary value
I2 (Int16)
16-bit 2's complement signed value
U2 (Uint16, Char)
16-bit unsigned binary value
I4 (Int32)
32-bit 2’s complement signed value
U4 (UInt32)
32-bit unsigned binary value
I8 (Int64)
64-bit 2’s complement signed value
U8 (UInt64)
64-bit unsigned binary value
R4 (Float)
32-bit IEEE 754 floating point value
R8 (Double)
64-bit IEEE 754 floating point value
O
natural size object reference to managed memory
&
natural size managed pointer (may point into managed
memory)
Natural size unmanaged pointer
*
Array
String
Unicode string class
Same as on the full .NET Framework
Native Code Interoperability

Issues




Platform Invoke (P/Invoke)


Managed  Native
IL_CallDelegate


Calling conventions
Garbage collection
Security Vs. extensibility
Native  Managed
Inter-App Domain Message Passing
App Domains

Runtime construct that supports a
running application




Logical container of application threads
Provides memory isolation
Single execution engine instance can
support multiple app domains
Execution engine ensures all resources
are released on app termination
App Domain Hosts



Bootstrap the execution engine
Written in C, call C APIs to start, pause
and stop CLR applications
Few constraints on execution models




Loader hooks on Windows & Windows CE
Web server in ASP.NET
SQL uses CLR for stored procedures
Graphical shell or browser as shell
Security

Type-safety


Code Access Security with simple policy



Exposed through the PAL
Network security


Add/remove apps from banned list
User Identity/authentication


Evidence determines access permission buckets
Evidence includes location, signing, banned list
Protocol for remote policy configuration


On-device verification for software isolation
SSL for Web Services, secure email, commerce
System quality
Remote Debugging, VS.NET








File copy and run (F5)
Source code breakpoints
Source code single-step
Stack trace
Variable inspection
Thread suspend/resume
Data watchpoints
Multiple device transports
Application Installation

Install


Uninstall




Copy files, perform configuration tasks
Deletes files
Dynamic dependency walk removes
orphaned shared components
Perform configuration tasks
Shared class lib versioning


“Never break a functioning app”
Apps are written to specific class lib
version or “latest”
GUI Architecture

Two flavors

Generic – provides cross-OS portability




Drawing primitives
Controls and Forms
OEM-customizable look and feel
Windows Forms




Supersets generic functionality
Available for Windows CE devices
Consistent with WinForms on .NET Framework
Drag n’ drop UI designer in Visual Studio
Drawing
Basic Networking
Network Threading



Apps can make synchronous (blocking)
or asynchronous calls
Synchronous calls run on the caller’s
thread
The system spins threads to support
asynchronous calls

Threads terminate after a short no-use
timeout
Web Services & Devices

Clean, protocol level separation of
publishing and usage





Many producers, many consumers
Separation of data from presentation
enables rich client applications
Client applications can aggregate web
services from multiple sources
Client applications can control
“chunkiness” of transfers
.NET CF can execute VS.NET generated
client proxy code
Performance





JIT compilation
Focus on resource constrained devices
Scalable to more capable devices
Tunable
Tradeoff different memory types
Memory Usage
FLASH
R /W F ile s y s te m
R /O F ile s y s te m
C LR Apps
.E X E an d .D L L
ROM
RAM
C LR Apps
.E X E an d .D L L s
C LR App
D ata
E xecu tio n E n g in e
Code
E xecu tio n E n g in e
D ata
A p p D o m ain H o st
Code
A p p D o m ain H o st
D ata
H o st O /S
Code
H o st O /S
D ata
O b je c t D a ta .
J IT C a c h e .
R e le a s e d o n
a p p e x it.
Questions?
Descargar

.NET Compact Framework