From bc0c885052787237db4da8c64ec1eefe92e3fb73 Mon Sep 17 00:00:00 2001 From: Julien CLEMENT Date: Sat, 31 Dec 2022 00:05:17 +0100 Subject: [PATCH] add memory allocation for thread stack Signed-off-by: Julien CLEMENT --- src/proc/thread/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/proc/thread/mod.rs b/src/proc/thread/mod.rs index 21401a5..dd4bf94 100644 --- a/src/proc/thread/mod.rs +++ b/src/proc/thread/mod.rs @@ -1,9 +1,17 @@ +use alloc::alloc::{alloc, dealloc, Layout}; + +const STACK_SIZE: usize = 4096 * 20; + pub struct Thread { rsp: u64 } impl Thread { - pub fn new() { - + pub fn new() -> Self { + unsafe { + Thread { + rsp: alloc(Layout::new::<[u8; STACK_SIZE]>()) as u64, + } + } } } \ No newline at end of file