fib-example #42
10
README.md
10
README.md
@ -2,6 +2,16 @@
|
||||
|
||||
## Running the examples
|
||||
|
||||
### examples/fib
|
||||
|
||||
The fib example performs fibonacci trivially on a fixed number. It is the most basic example of a process that requires no privilege, excluding `Stdout` to print the result.
|
||||
JakeHillion marked this conversation as resolved
Outdated
|
||||
|
||||
To run this example:
|
||||
|
||||
cargo build
|
||||
cargo build --example fib
|
||||
target/debug/clone-shim -s examples/fib/spec.json target/debug/examples/fib
|
||||
|
||||
### examples/basic
|
||||
|
||||
The basic example instructs the shim to spawn two processes, each of which writes "hello from main{1,2}!" to stdout.
|
||||
|
@ -1 +1,16 @@
|
||||
fn main() {}
|
||||
fn main() {
|
||||
println!("fib(1) = {}", fib(1));
|
||||
println!("fib(7) = {}", fib(7));
|
||||
println!("fib(19) = {}", fib(19));
|
||||
}
|
||||
|
||||
fn fib(i: u64) -> u64 {
|
||||
let mut a = 0;
|
||||
let mut b = 1;
|
||||
|
||||
for _ in 0..i {
|
||||
(a, b) = (b, a + b);
|
||||
}
|
||||
|
||||
a
|
||||
}
|
||||
|
30
examples/fib/spec.json
Normal file
30
examples/fib/spec.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"entrypoints": {
|
||||
"fib": {
|
||||
JakeHillion marked this conversation as resolved
Outdated
JakeHillion
commented
s/main1/fib/ s/main1/fib/
|
||||
"args": [
|
||||
"BinaryName"
|
||||
],
|
||||
"environment": [
|
||||
"Stdout",
|
||||
{
|
||||
"Filesystem": {
|
||||
"host_path": "/lib/x86_64-linux-gnu/libgcc_s.so.1",
|
||||
"environment_path": "/lib/libgcc_s.so.1"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Filesystem": {
|
||||
"host_path": "/lib/x86_64-linux-gnu/libc.so.6",
|
||||
"environment_path": "/lib/libc.so.6"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Filesystem": {
|
||||
"host_path": "/lib64/ld-linux-x86-64.so.2",
|
||||
"environment_path": "/lib64/ld-linux-x86-64.so.2"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
{
|
||||
"entrypoints": {
|
||||
"main1": {
|
||||
"args": [
|
||||
"BinaryName"
|
||||
],
|
||||
"environment": [
|
||||
"Stdout"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user
s/Stderr/Stdout/