1 cheng-chun hsu training for new students 2009/9/11
TRANSCRIPT
![Page 1: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/1.jpg)
1
Platform Optimization
Cheng-Chun Hsu
Training for New Students
2009/9/11
![Page 2: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/2.jpg)
2
Outline First Part
Introduction of Java Introduction of Garbage Collection
Second Part Introduction of Actor Model
Third Part CVM’s Implementation
(Linux, Windows Mobile, Andes Platform, Windows)
2009/9/11
![Page 3: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/3.jpg)
3
Java Version J2SE J2EE J2ME
2009/9/11
![Page 4: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/4.jpg)
4
ArchitectureDesktop Low-end
devicesEnterprise High-end
devicesSmartCards
Optional
packages
Foundation
profile
CDC
Personal
profile
JavaCard
Card VM
MIDP
Optionalpackages
CLDC
KVMKVMJava Virtual MachineJava Virtual Machine
Java 2 Micro Edition (J2ME)
Optionalpackages
JEE
Optionalpackages
JSE
CVMCVM
2009/9/11
![Page 5: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/5.jpg)
5
Configuration and Profile
2009/9/11
![Page 6: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/6.jpg)
6
Java Compile Processes
2009/9/11
![Page 7: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/7.jpg)
7
Outline First Part
Introduction of Java Introduction of Garbage Collection
Second Part Introduction of Actor Model
Third Part CVM’s Implementation
(Linux, Windows Mobile, Andes Platform, Windows)
2009/9/11
![Page 8: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/8.jpg)
8
Garbage Collection
2009/9/11
![Page 9: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/9.jpg)
9
G.C. Benefits No dangling references No memory leaks Greater programmer productivity
Ex: Java, C#
2009/9/11
![Page 10: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/10.jpg)
10
Related G.C. G.C. stage
Identify (must pause time) Collect
When is the G.C. happened ?1) Allocate new object (not enough memory)2) System idle3) System.gc( )4) Intialization
2009/9/11
![Page 11: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/11.jpg)
11
Kind of G.C.• Classical G.C.
1. Mark and Sweep (Tracing)2. Copying Collection (Semi-space)3. Reference Counting => cyclic problem
• Advanced G.C. 1. Generational Collection => hybrid
algorithm2. Incremental Collection => real-time
system)2009/9/11
![Page 12: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/12.jpg)
12
Mark-Sweep Collectors (Graph) DFS(x)
2009/9/11
![Page 13: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/13.jpg)
13
Mark-Sweep Algo. Marking phase
Starting from the roots, set the mark bit on all live cells.
Sweep phase Return all unmarked cells to the free list. Reset the mark bit on all marked cells.
2009/9/11
![Page 14: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/14.jpg)
14
Features If less garbage, then high speed Disadvantage
Memory has internal fragment. Must be pause.
2009/9/11
![Page 15: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/15.jpg)
15
Semi-Space (Graph) From-space, To-space
2009/9/11
![Page 16: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/16.jpg)
16
Features If much garbage, then high
performance Advantage
Only visits live objects (therefore fast) No fragmentation and fast allocation
Disadvantage Only from-space used Must be pause
2009/9/11
![Page 17: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/17.jpg)
17
Reference Counting (Graph) Counting pointers and cyclic structure
2009/9/11
![Page 18: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/18.jpg)
18
Features Advantage
Quickly Disadvantage
Cannot reclaim cyclic structure Maintain a counter per chunk Extra space requirements Fragmentation
2009/9/11
![Page 19: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/19.jpg)
19
Generational (Graph) Old generation (mark-compact) New generation (copying)
2009/9/11
![Page 20: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/20.jpg)
20
Outline First Part
Introduction of Java Introduction of Garbage Collection
Second Part Introduction of Actor Model
Third Part CVM’s Implementation
(Linux, Windows Mobile, Andes Platform, Windows)
2009/9/11
![Page 21: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/21.jpg)
Object-Reference Graph
21
4
5
7
8
6
2
3
1
2009/9/11
![Page 22: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/22.jpg)
22
Actor Model Graph
A
CB D
H
FE
G
I
2009/9/11
![Page 23: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/23.jpg)
Compare Two SystemsObject-Oriented System Actor System
Passive Active
Heavy Sightly
Have suitable storage No stacks, heap, register
Computation has independent threads of control manipulating the object they refer to.
Thread of control is encapsulated in the object itself.
Thread of control is important.
Thread of control is unimportant.
232009/9/11
![Page 24: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/24.jpg)
24
Actor Model Actor
The universe consists of autonomous computation agents.
Garbage Actor Unable to receive a message from or
send a message to the root actor.
2009/9/11
![Page 25: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/25.jpg)
25
States of Actors Active()
An actor which is either processing a message or has message pending in its mail-queue.
Blocked() An actor that is waiting for the arrival of a
message to its empty mail queue. Root()
An actor that is always considered as non-garbage.
2009/9/11
![Page 26: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/26.jpg)
26
Communication between Actors Each actor has a unique mail address. Communication is asynchronous. Message for an actor are buffer in a mail
queue.
2009/9/11
![Page 27: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/27.jpg)
27
Three Behaviors in The Actor System Create
Create a new actor. Send
Send a message into other mail queue. Ready
Prepare process next message in mail queue.
2009/9/11
![Page 28: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/28.jpg)
Two Types of Transformations in The Actor System The state of an individual actor
The topology of the system of actors
28
BA A B
A AB B
2009/9/11
![Page 29: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/29.jpg)
29
Garbage Collection Algorithm for Actor Model Is-Black Push-Pull Table-Driven Dickman GCE
2009/9/11
![Page 30: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/30.jpg)
Is-Black (Initialization)
30
B FA C ED
B FA C ED
2009/9/11
![Page 31: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/31.jpg)
Is-Black (first)
31
B FA C ED
B FA C ED
2009/9/11
![Page 32: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/32.jpg)
Is-Black (secand)
32
B FA C ED
B FA C ED
2009/9/11
![Page 33: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/33.jpg)
Is-Black (third)
33
B FA C ED
B FA C ED
2009/9/11
![Page 34: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/34.jpg)
34
A
CB D
H
FE
G
I
Push-Pull (Initialization)
2009/9/11
![Page 35: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/35.jpg)
Puller
35
A
CB D
H
FE
G
I
2009/9/11
![Page 36: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/36.jpg)
Pusher
36
A
CB D
H
FE
G
I
2009/9/11
![Page 37: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/37.jpg)
Termination
37
A
CB D
H
FE
G
I
2009/9/11
![Page 38: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/38.jpg)
38
Table-Driven
A
CB D
H
FE
G
I
2009/9/11
![Page 39: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/39.jpg)
39
Table-Driven
A
CB D
H
FE
G
I
2009/9/11
![Page 40: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/40.jpg)
40
Table-Drivenb R(b)
C A
D A
F A
F E
D G
a F(A)
A E
E A
A G
G A
2009/9/11
![Page 41: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/41.jpg)
41
Outline First Part
Introduction of Java Introduction of Garbage Collection
Second Part Introduction of Actor Model
Third Part CVM’s Implementation
(Linux, Windows Mobile, Andes Platform, Windows)
2009/9/11
![Page 42: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/42.jpg)
42
CDC Documents CDC Porting Guide (Ch6) CDC Build Guide CDC Runtime Guide CDC Dynamic Compiler
2009/9/11
![Page 43: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/43.jpg)
43
Linux1. Install JDK 1.4.2.19 (or default JDK 1.7.0 in Fedora 8)
(set path “export PATH=$PATH:$HOME/j2sdk1.4.2_19/bin” )
2. Extract “phoneme_advanced-mr2-dev-src-b97-20_nov_2008.zip”
3. Input “cd phoneme_advanced_mr2/cdc/build/ linux-x86-generic”
4. Input “make”, after run “cvm”
Next, move to the Eclipse(Please refer to “cvm環境建置和指令 for linux.doc”)
2009/9/11
![Page 44: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/44.jpg)
44
Windows Mobile1. Install JDK 1.4.2.19(set path “C:\j2sdk1.4.2_19\bin;”)2. Install Pocket PC 2003 SDK3. Install Embedded Visual C++ 44. Install Embedded Visual C++ 4.0 SP35. Install Cygwin (include gcc, g++, zip, flex, bison,
packages)6. Extract “phoneme_advanced-mr2-dev-src-win32-b34-
04_oct_2007.zip”7. Open “Cygwin”8. Input “cd phoneme_advanced_mr2/cdc/build/win32-x86-
ppc03”9. Input “make”
2009/9/11
![Page 45: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/45.jpg)
45
Windows MobileConnect PDA1. Install ActiveSync 4.5 (synchronize between PC
and PDA)2. Install WindowsMobilePowerToys.msi (use
cmd.exe in the PDA)3. After, go to “C:\Program Files\Windows Mobile
Developer Power Toys\PPC_Command_Shell\arm”
4. Copy all files to the PDA’s “windows” folder
2009/9/11
![Page 46: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/46.jpg)
46
Windows MobileRun an example of “cvm”1. After compiler successfully, copy “win32-x86-ppc03”
folder to your root of “SD Card”2. Open “notepad”3. Input 255#“\SD Card\win32-x86-ppc03\bin\cvm.exe”
–cp “\SD Card\win32-x86-ppc03\testclasses.zip” HelloWorld
4. Save the file, and set file name “EX_helloworld.lnk”5. Go to SD card folder of PDA, after run
“EX_helloworld.lnk”6. Wait for a long time, and then show “HelloWorld.”
2009/9/11
![Page 47: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/47.jpg)
47
Andes Platform1. Install JDK 1.4.2.19 (set path “C:\j2sdk1.4.2_19\
bin;”)2. Install andesight-1_3_1-windows
(complete installation and include Cygwin)3. Extract “pmea-mr2-b114-nds32-20090602.zip”
to “C:\”, and then produce the folder “pmea”4. Open “Cygwin”5. Input “export
PATH=$PATH:/cygdrive/c/Andestech/AndeSight/toolchains/nds32-elf-n1213-s-full/bin”
2009/9/11
![Page 48: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/48.jpg)
48
Andes Platform (con.)6. Input “nds32-elf-gcc”, and then show “nds32-elf-
gcc: no input files”7. Input “mkdir /pmea”8. Input “mount c:/pmea /pmea”9. Input “cd pmea/cdc/build/linux-nds32-xc5”10. Input “make”
Next, upload and test PMEA to the Andes platform. (Please refer to “教育改進計畫課程實驗模組 -Java Virtual Machine-2009-06-02.doc”)
2009/9/11
![Page 49: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/49.jpg)
49
Windows1. Install JDK 1.4.2.19 (set path “C:\j2sdk1.4.2_19\bin;”)2. Install Microsoft Platform SDK for Windows Server 2003 R2
(install location “C:\Program Files\Microsoft Platform SDK”)3. Install Visual C++ 2005 express(vc8)
(install location “C:\Program Files\Microsoft Visual Studio 8”)4. Install Cygwin(include gcc, g++, zip, flex, bison, packages)5. Extract “phoneme_advanced-mr2-dev-src-win32-b34-
04_oct_2007.zip”6. Open “Cygwin”7. Input “cd phoneme_advanced_mr2/cdc/build/win32-x86-
vc8”8. Input “make”, after run “cvm”
2009/9/11
![Page 50: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/50.jpg)
50
How to run ? Run
bin/cvm –cp testclasses.zip HelloWorld Change G.C.
make CVM_GCCHOICE=semispace/generational/marksweep
View CVM’s options bin/cvm -XshowBuildOptions
Build Java program Javac -target 1.4 -source 1.4 -bootclasspath /home/test-
cdc/btclasses.zip MyApp.java
(More information, refer to “cvm環境建置和指令 for linux.doc”)2009/9/11
![Page 51: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/51.jpg)
51
Reference Books
深入嵌入式 Java虛擬機器 Inside KVM Java虛擬機深入解析 SCJP 6.0/5.0猛虎出閘
Document CDC Porting Guide
2009/9/11
![Page 52: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/52.jpg)
52
Reference Official Website of PhoneME
https://phoneme.dev.java.net/ phoneME for Windows Mobile
http://www.cs.kuleuven.be/~davy/phoneme/ Richard Jones
http://www.ssw.uni-linz.ac.at/Teaching/Lectures/Sem/2005/
ActorFoundry http://osl.cs.uiuc.edu/research?
action=topic&topic=Actor+Systems2009/9/11
![Page 53: 1 Cheng-Chun Hsu Training for New Students 2009/9/11](https://reader035.vdocuments.net/reader035/viewer/2022062712/56649c905503460f9494ac48/html5/thumbnails/53.jpg)
53
Reference Keywords
J2ME, CDC/CLDC, CVM/KVM, Java Virtual Machine, Garbage Collection, Memory Management, Mark-Sweep, Semi-Space, Reference Counting, Generational, Actor Model, Active Objects, Push-Pull, Is-Black
2009/9/11