Recent Changes - Search:

edit SideBar

RustHost

"Rust is a general-purpose, multi-paradigm, compiled programming language sponsored by Mozilla Research. It is designed to be a "safe, concurrent, practical language", supporting functional and imperative-procedural paradigms." (source: Wikipedia)

Summary

  • We have a Rust Accessor Host can execute the TestComposite.js composite accessor, see accessors/web/hosts/duktape/rusteduk/examples/rusteduk.js
    • Note that the Rust Accessor Host uses Duktape and Duktape is written in C, so we are calling unsafe code.
    • To be useful, we would need to create modules like to support WebSockets or UDP.
    • The rusteduk binary is 4.4Mb in size and strips down to 1.2Mb. See Why do Rust programs use more memory than C?
      • A duktape binary that does not use Rust (accessors/web/hosts/duktape/duktape/duktape) is 364k, which strips down to 334k
      • A very minimal duktape binary (accessors/web/hosts/duktape/eduk/eduk) strips down to 320k
  • The TockOS kernel is written in Rust, but TockOS userland programs are written in C.
    • Since the Rust Host uses Duktape and Duktape is in C, then we can write our TockOS userland Accessor Host in C and we don't really need the Rust Host (See TockOS).
      • However, if we had a 100% Rust implementation of Duktape, then perhaps Rusteduk could be part of the TockOS kernel.

How to run the Rust Accessor Host

  1. It is a bit easier to use rustup to manage the different versions of rust than to install just one version. So, see https://www.rustup.rs/ for how to install rustup
  2. The rust accessor host worked with rust 1.12.1. Probably running
    rustup default stable
    will install a version that works.
  3. Download the accessors svn repo. See the instructions, or do
    svn co https://repo.eecs.berkeley.edu/svn-anon/projects/terraswarm/accessors/trunk/accessors
  4. Build and run:
    cd accessors/web/hosts/duktape/rusteduk
    make test
    The makefile merely builds the examples/rusteduk.js example with
    cargo build --example rusteduk
    and the runs it with
    (cd ../..; duktape/rusteduk/target/debug/examples/rusteduk duktape/test/testComposite.js)
    For example:
    [cxh@terra rusteduk]$ make test
    (cd ../..; duktape/rusteduk/target/debug/examples/rusteduk duktape/test/testComposite.js)
    Read in duktape/duktapeHost.js.
    module_loader: Done! Successfully found common/commonHost.js.
    module_loader: Done! Successfully found common/modules/util.js.
    module_loader: Done! Successfully found common/modules/events.js.
    duktapeHost.js done
    duktape/rusteduk/target/debug/examples/rusteduk: duktapeHost.js: result was Undefined
    Read in duktape/duktape/examples/eventloop/ecma_eventloop.js.
    duktape/rusteduk/target/debug/examples/rusteduk: duktapeHost.js: result was Object({"clearInterval": Object({}), "setInterval": Object({}), "setTimeout": Object({})})
    Read in duktape/test/testComposite.js.
    duktape/test/testComposite.js: OK: output was 50, which is equal to 50.
    duktape/rusteduk/target/debug/examples/rusteduk: result was Undefined
    [cxh@terra rusteduk]$

See Also

  • Rust - notes about accessors and Rust
  • http://www.tockos.org/ "Tock is a safe, multitasking operating system for low-power, low-memory microcontrollers." ... written in Rust
  • "Ownership is Theft: Experiences Building an Embedded OS in Rust"
    Amit Levy, Michael P Andersen, Bradford Campbell, David Culler, Prabal Dutta, Branden Ghena, Philip Levis, and Pat Pannuto
    In 8th Workshop on Programming Languages and Operating Systems (PLOS'15)
    Monterey, CA, USA, October 4, 2015
  • TockOS - notes about TockOS
Edit - History - Print - Recent Changes - Search
Page last modified on December 30, 2016, at 04:58 PM