Skip to content

Instantly share code, notes, and snippets.

@matu3ba
Created April 13, 2023 22:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matu3ba/3f4dbb975ad8e656828bdd9073beb923 to your computer and use it in GitHub Desktop.
Save matu3ba/3f4dbb975ad8e656828bdd9073beb923 to your computer and use it in GitHub Desktop.
Idea for zig thread status (macos implementation idea missing and other portable questions on freebsd etc)
diff --git a/lib/std/Thread.zig b/lib/std/Thread.zig
index 8004f94d7f..22996939a3 100644
--- a/lib/std/Thread.zig
+++ b/lib/std/Thread.zig
@@ -275,6 +275,14 @@ pub fn getCurrentId() Id {
return Impl.getCurrentId();
}
+pub fn getStatus() c_int {
+ // https://stackoverflow.com/questions/9577231/how-to-check-the-state-of-linux-threads
+ // => parse /self/proc
+ // darwin: darwin thread_get_state looks to be Kernel internal
+ // windows: https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntquerysysteminformation
+ return 0;
+}
+
pub const CpuCountError = error{
PermissionDenied,
SystemResources,
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment