From e2dedd1e38c111d08c194ef4ad0a6c8d2329dabd Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Sat, 13 Aug 2016 15:18:41 -0600 Subject: [PATCH] Add some source --- .gitignore | 2 ++ Cargo.toml | 4 ++++ LICENSE | 21 +++++++++++++++++++++ src/main.rs | 39 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.toml create mode 100644 LICENSE create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fa8d85a --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Cargo.lock +target diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..bdd2881 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,4 @@ +[package] +name = "acid" +version = "0.1.0" +authors = ["Jeremy Soller "] diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..7a0e9c2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2016 Jeremy Soller + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..a44e857 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,39 @@ +///Acid testing program +use std::process::Command; +use std::thread; + +fn main() { + println!("Trying to kill kernel..."); + + let mut threads = Vec::new(); + for i in 0..10 { + threads.push(thread::spawn(move || { + let mut sub_threads = Vec::new(); + for j in 0..10 { + sub_threads.push(thread::spawn(move || { + Command::new("sh") + .arg("-c") + .arg(&format!("echo {}:{}", i, j)) + .spawn().unwrap() + .wait().unwrap(); + })); + } + + Command::new("sh") + .arg("-c") + .arg(&format!("echo {}", i)) + .spawn().unwrap() + .wait().unwrap(); + + for sub_thread in sub_threads { + sub_thread.join().unwrap(); + } + })); + } + + for thread in threads { + thread.join().unwrap(); + } + + println!("Kernel survived!"); +}