1 / 33

JavaME Connected Device Configure

JavaME Connected Device Configure. Development Environment and Garbage Collector of Virtual Machine. Speaker: Chu, Hua-Rong Advisor: Chung Yung. OUTLINE. CDC implementation overview Build Sun CDC1.0.1 in Ubuntu What happens during the build process Garbage Collector of Sun CVM.

Télécharger la présentation

JavaME Connected Device Configure

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. JavaME Connected Device Configure Development Environment and Garbage Collector of Virtual Machine Speaker: Chu, Hua-RongAdvisor: Chung Yung

  2. OUTLINE • CDC implementation overview • Build Sun CDC1.0.1 in Ubuntu • What happens during the build process • Garbage Collector of Sun CVM

  3. JavaME CDC Implementation overview

  4. CDC platform Survey • IBM • WebSphere Everyplace Micro Environment • Support CDC1.1 • Ref: 劉惠玲, 嵌入式系統裝置走向跨平台的推手 - IBM J9, 2007 IBM developerWorks(~/cdc/CDC doc/IBMJ9.ppt) • Sun • Offical CDC • Mobile & Embedded Community: phoneME Advanced

  5. Sun CDC History Personal Java (1999) JavaME CDC1.0 (2001) JavaME CDC1.1 (2005) JavaSE for Embedded? (2007) phoneME Advanced(2008)

  6. Sun CDC family • JavaME CDC1.0 (based on JavaSE1.3) • JavaME CDC1.0.1 (based on JavaSE1.3.1) • JavaME CDC1.1 (based on JavaSE1.4) • ARM, PowerPC, MIPS, SPARC, x86 (interpreter only) • Linux, Solaris, Darwin, Win32 • phoneME Advanced MR2 (2008) • ARM, x86 • Linux, Windows Mobile, OpenWRT

  7. JavaME CDC Build Sun cdc 1.0.1

  8. PartI: Source Code • Source Code: • j2me_cdcfp-1_0_1-fcs-src-b12-linux-i686-14_May_2002.zip • Download: http://jtrue.pl/files/GPS/

  9. PartII: Environment • Redhat7.1 / Ubuntu 6.06 • JDK1.3 / JDK1.4 • egcs6 / gcc3.3 and related C develop tool • ksh

  10. PartIII: Troubleshooting • Problem: This Version's java code is based on JavaSE1.3.1. • Java Compile time error: • JDK6javac with option -source 1.4/1.3 is no use • Solution:downgradeto JDK1.4/1.3 ../../src/share/classes/java/lang/SecurityManager.java:299: cannot find symbol symbol : method initCause(java.lang.ClassNotFoundException) location: class java.lang.NoClassDefFoundError synchronized(SecurityManager.class) { ^

  11. PartIII: Troubleshooting • Problem: GCC4 is restricted for nonstandard C code in this Version. • C Compile time error: complie time Error: Checking for test classes to compile ... ... ../../build/linux-i686/obj/globals.o ../../src/share/javavm/runtime/globals.c:121:1: 錯誤: 粘貼「.」和「nullClassLoaderLock」不能給出一個有效的預先處理識別字

  12. PartIII: Troubleshooting • Solution:use GCC3.3(gcc -V3.3 if gcc4 is installed) change line 117 of /cdcfoundation/src/share/javavm/runtime/globals.c from #define CVM_SYSMUTEX_ENTRY(mutex, name) {&CVMglobals.##mutex, name} #define CVM_SYSMUTEX_ENTRY(mutex, name) {&CVMglobals. mutex, name}

  13. PartIII: Troubleshooting • Problem: glibc <2.2 is needed in this Version • Linking Time Error: Linking ../../build/linux-i686/bin/cvm ../../build/linux-i686/obj/UNIXProcess_md.o:在函式「sigchld_handler」中 :../../src/linux/native/java/lang/UNIXProcess_md.c:213: 未定義參考到「 __libc_wait」 collect2: ld 回傳 1 make: *** [../../build/linux-i686/bin/cvm] Error 1

  14. PartIII: Troubleshooting • Solution: patch ~/src/linux/native/java/lang/UNIXProcess_md.c 34,53c34 < < /* following lines Hacked by Kent Hulick based on < * ftp://people.redhat.com/drepper/libcwait.c < * fixes a broken calls to a removed glibc function:*/ < #include < #include < pid_t __libc_wait (int *status) < { < int res; < asm volatile ("pushl %%ebx\n\t" < "movl %2, %%ebx\n\t" < "movl %1, %%eax\n\t" < "int $0x80\n\t" < "popl %%ebx" < : "=a" (res) < : "i" (__NR_wait4), "0" (WAIT_ANY), "c" (status), "d" (0), < "S" (0)); < return res; < } < --

  15. PartIV: Preperation&Configure #sudosu #cd/usr/local/src #wget http://jtrue.pl/files/GPS/j2me_cdcfp-1_0_1-fcs-src-b12-linux-i686-14_May_2002.zip #unzip j2me_cdcfp-1_0_1-fcs-src-b12-linux-i686-14_May_2002.zip #unzip cdcfoundation-1_0_1-fcs-src.zip #cdcdcfoundation/build

  16. PartIV: Preperation&Configure Edit Makefile ./linux/defs.mk : ./linux/defs.mk:#petertc1026 ./linux/defs.mk-#CFLAGS_SPEED = -c $(CC_ARCH_FLAGS) $(CCFLAGS) $(CCFLAGS_SPEED) $(CPPFLAGS) ./linux/defs.mk-#CFLAGS_SPACE = -c $(CC_ARCH_FLAGS) $(CCFLAGS) $(CCFLAGS_SPACE) $(CPPFLAGS) ./linux/defs.mk-#SO_CFLAGS = -c $(SO_CC_ARCH_FLAGS) $(CCFLAGS) $(CPPFLAGS) ./linux/defs.mk-CFLAGS_SPEED = -V3.3 -c $(CC_ARCH_FLAGS) $(CCFLAGS) $(CCFLAGS_SPEED) $(CPPFLAGS) ./linux/defs.mk-CFLAGS_SPACE = -V3.3 -c $(CC_ARCH_FLAGS) $(CCFLAGS) $(CCFLAGS_SPACE) $(CPPFLAGS) ./linux/defs.mk-SO_CFLAGS = -V3.3 -c $(SO_CC_ARCH_FLAGS) $(CCFLAGS) $(CPPFLAGS)

  17. PartIV: Preperation&Configure Edit Makefile./share/defs.mk : ./share/defs.mk:#petertc1026 ./share/defs.mk-#CVM_GNU_TOOLS_PATH=/micro/tools/i686-redhat-linux/gnu/bin ./share/defs.mk-CVM_GNU_TOOLS_PATH=/usr/bin

  18. PartIV: Preperation&Configure Patch /usr/local/src/cdcfoundation/src/share/javavm/runtime/globals.c:117 //petertc1026 /*#define CVM_SYSMUTEX_ENTRY(mutex, name) {&CVMglobals.##mutex, name}*/ #define CVM_SYSMUTEX_ENTRY(mutex, name) {&CVMglobals. mutex, name}

  19. PartIV: Preperation&Configure Patch /usr/local/src/cdcfoundation/src/linux/native/java/lang/UNIXProcess_md.c:213 34,53c34 < < /* following lines Hacked by Kent Hulick based on < * ftp://people.redhat.com/drepper/libcwait.c < * fixes a broken calls to a removed glibc function:*/ < #include <errno.h> < #include <sys/syscall.h> < pid_t __libc_wait (int *status) < { < int res; < asm volatile ("pushl %%ebx\n\t" < "movl %2, %%ebx\n\t" < "movl %1, %%eax\n\t" < "int $0x80\n\t" < "popl %%ebx" < : "=a" (res) < : "i" (__NR_wait4), "0" (WAIT_ANY), "c" (status), "d" (0), < "S" (0)); < return res; < } <

  20. PartV: Build #cdlinux-i686 #make CVM_DEBUG=true JAVABIN=/usr/java/j2sdk1.4.2_18/bin

  21. PartVI: Demo # bin/cvm -Djava.class.path=testclasses.zip HelloWorld > GC[SS]: Initialized semi-space gen for generational GC > Size of *each* semispace in bytes=1048576 > Limits of generation = [0xb7942200,0xb7b42200) > First semispace = [0xb7942200,0xb7a42200) > Second semispace = [0xb7a42200,0xb7b42200) > GC[MC]: Initialized mark-compact gen for generational GC > Size of the space in bytes=3145728 > Limits of generation = [0xb7b42200,0xb7e42200) > GC[generational]: Auxiliary data structures > heapBaseMemoryArea=[0xb7942008,0xb7e42208) > cardTable=[0x8322f90,0x8325790) > objectHeaderTable=[0x8325798,0x8327f98) > summaryTable=[0x8327fa0,0x8331fa0) > Hello world.

  22. JavaME CDC What Happens During the Build Process

  23. In build/linux-i686/directory • bin/cvm: executable image • lib/cdc.jar: JAR archive, default boot class path • testclasses.zip: a collection of simple tests

  24. JavaME CDC Garbage collector

  25. Build Options • -CVM_GCCHOICE (Generational/marksweep/semispace) • default: generational • Example: • -CVM_GCCHOICE=semispace

  26. Runtime Options • -Xgc:gc_specific_options(In generational is youngGen=nnnin bytes) • Default: 1M

  27. Runtime Options • -Xmssize (memory allocation pool) • Default: 4M • Example: • -Xms6291456 • -Xms6144k • -Xms6m

  28. Source Organization • src/share/javavm/include/gc_common.h The shared GC interface. • src/share/javavm/include/gc/gc_impl.hThe gcimpl GC interface that has to be implemented for each GC. • src/share/javavm/include/gc/<gcname>/gc_config.hThe configuration file for a specific GC. • src/share/javavm/runtime/gc/<gcname>/gc_impl.cThe implementation file for a specific GC.

  29. Execution Flow 1. CVM allocates memory using the shared routine CVMgcAllocNewInstance(). 2. CVMgcAllocNewInstance() does some processing and calls the GC-specific CVMgcimplAllocObject() to allocate the actual space for the object. 3. CVMgcimplAllocObject() performs the GC and calls the shared routine CVMgcStopTheWorldAndGC() to stop all threads at GC-safe points. 4. CVMgcStopTheWorldAndGC() ensures that all threads rendezvous at GC-safe points. When that is done, it calls the GC implementation CVMgcimplDoGC() to perform the GC action. 5. CVMgcimplDoGC() may call shared GC service routines to scan GC state: For example, CVMgcScanRoots() to scan all roots or CVMobjectWalkRefs() to scan the pointers in a given object or array. 6. When CVMgcimplDoGC() returns, all threads that were stopped at GC points resume execution. Eventually, CVMgcAllocNewInstance() returns and the thread that originally initiated GC resumes execution.

  30. JavaME CDC Reference

  31. CDCfoundation_porting_guide.pdf

  32. JavaME CDC <!--EOF->

More Related