Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

mruby/c in TokyoRubyKaigi#11

1,827 views

Published on

東京Ruby会議の資料

Published in: Software
  • Be the first to comment

mruby/c in TokyoRubyKaigi#11

  1. 1. mruby/c Kazuaki Tanaka Kyushu Institute of Technology
  2. 2. 自己紹介 • 九州工業大学 Kyutech, Fukuoka • Lectures – Programming – Algorithms and data structures – Database – Robot sensor processing
  3. 3. Joint research project • Digital signage devices
  4. 4. mruby 軽量Ruby • Ruby for embedded systems – Small, Lightweight – Portable – Configurable • METI project work
  5. 5. mruby Lightweight • < 400KB • One chip microprocessor ARM Coretex-M4 168MHz 1MB SRAM, 1MB Flash enzi mruby board, http://enzi.cc/
  6. 6. mruby Portable • Executing mruby bytecode using mruby VM Source Code program.rb Byte Code program.mrb mrbc Device A Execute mruby VM Device B Execute mruby VM PC Execute mruby VM
  7. 7. mruby Configurable • mrbgems – VM configuration • Add one line in build_config.rb conf.gem :github => 'iij/mruby-socket’ http://mruby.org/libraries/
  8. 8. mruby/c project • mruby for more smaller device • Concurrent mruby execution without OS • “/c” stands for compact and concurrent ARM Coretex-M3 80MHz 64KB SRAM, 256KB Flash PSoC5LP, http://cypress.com/
  9. 9. Demo mruby/c PSoC5LP ARM Coretex-M3 80MHz 64KB SRAM, 256KB Flash
  10. 10. Details mruby/c • GC • Concurrency • Boot
  11. 11. GC mruby/c No GC
  12. 12. How it works? • Small mruby/c program only supported • When a program ended, memory initialized • How to support long term execution? – Use concurrency
  13. 13. Concurrency mruby/c • mruby/c is for Non-OS environment • But expect multiple programs execution VM dispatches mruby programs
  14. 14. Concurrency mruby/c OP_LOAD OP_ADDI OP_JMP ・ ・ OP_LOADI OP_SEND OP_LOAD ・ ・ mruby VM One Instruction One Instruction Execute Program A Program B Reg. Stack Program A work Reg. Stack Program B work Symbol Class Method Global Shared
  15. 15. Demo mruby/c, concurrency i = 100 while i<200 do puts i i = i + 1 end i = 1000 while i<1100 do puts i i = i + 1 end
  16. 16. Demo mruby/c, concurrency $lock = true i = 1 while i<10 do puts i i = i + 1 end $lock = false while $lock do end i = 100 while i<110 do puts i i = i + 1 end Using spinlock without mutual exclusion >_<
  17. 17. Boot • Boot process = + Initialize VM work + Create classes + Register all the methods to classes 1. Create entry point to a method 2. Get symbol of a method 3. Add a element to hash table for all methods
  18. 18. Boot mruby/c • Simple Registration, using linked list. [s] Loop count
  19. 19. GET mruby and mruby/c • mruby • mruby/c https://github.com/mrubyc/mrubyc https://github.com/mruby/mruby http://forum.mruby.org/ http://www.s-itoc.jp/activity/research/mruby/
  20. 20. 良いことづくめ? • mruby/cは,多くの制約があります – クラス,メソッド不足 – Fixnum だけ,だからあふれます – Arrayは線形リスト,だから… – メソッドは線形リストで管理,だから… – メモリは静的に確保します まだまだ開発途上です ご協力ください!

×