Skip to content

Commit 467accc

Browse files
committed
Emerald: Added thread::sleep
This is just a normal basic syscall with seconds and nanoseconds.
1 parent 3bd98b3 commit 467accc

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,19 +1193,19 @@ dependencies = [
11931193

11941194
[[package]]
11951195
name = "emerald_kernel_user_link"
1196-
version = "0.2.1"
1196+
version = "0.2.2"
11971197
source = "registry+https://github.com/rust-lang/crates.io-index"
1198-
checksum = "0785bd57d8819d6796c5d92f9406c8e83fa3317cf62abfcd9a3f0c48862a7a37"
1198+
checksum = "2f12c5d30e528a9a1dbf773e020452dc5339b0167a6fe66c683a02c6bfaffb6c"
11991199
dependencies = [
12001200
"compiler_builtins",
12011201
"rustc-std-workspace-core",
12021202
]
12031203

12041204
[[package]]
12051205
name = "emerald_std"
1206-
version = "0.2.2"
1206+
version = "0.2.3"
12071207
source = "registry+https://github.com/rust-lang/crates.io-index"
1208-
checksum = "24cefaf4e212b4da00f133b09e689ecdc1a00ac7f58fe03d530206f315a6eb42"
1208+
checksum = "fa6d6034186e8a218cd75e1481bda7981e4c136c46b8fa11c75fdf8c1cfc1d9b"
12091209
dependencies = [
12101210
"compiler_builtins",
12111211
"emerald_kernel_user_link",

library/std/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ r-efi-alloc = { version = "1.0.0", features = ['rustc-dep-of-std']}
5959

6060
[target.'cfg(target_os = "emerald")'.dependencies]
6161
# This is from `https://github.com/Amjad50/Emerald`, i.e. it must be run from that context
62-
emerald_std = { version = "0.2.2", features = ['rustc-dep-of-std'] }
62+
emerald_std = { version = "0.2.3", features = ['rustc-dep-of-std'] }
6363

6464
[features]
6565
backtrace = [

library/std/src/sys/emerald/thread.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,15 @@ impl Thread {
2121
// nope
2222
}
2323

24-
pub fn sleep(_dur: Duration) {
25-
panic!("can't sleep");
24+
pub fn sleep(duration: Duration) {
25+
let secs = duration.as_secs();
26+
let nsecs = duration.subsec_nanos() as _;
27+
28+
// For now, we don't have signals or interrupts. So the sleep will
29+
// be executed normally.
30+
unsafe {
31+
emerald_std::clock::sleep(secs, nsecs).expect("Failed to sleep");
32+
}
2633
}
2734

2835
pub fn join(self) {

0 commit comments

Comments
 (0)