1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00

unimportant changes

This commit is contained in:
WangRunji 2019-03-18 00:18:03 +08:00
parent 480bf0d14c
commit 17e644e54e
8 changed files with 126 additions and 131 deletions

View File

@ -203,7 +203,7 @@ impl ThreadPool {
self.set_status(tid, Status::Exited(code));
}
/// Called when a thread exit
fn exit_handler(&self, tid: Tid, proc: &mut Thread) {
fn exit_handler(&self, _tid: Tid, proc: &mut Thread) {
// wake up waiter
if let Some(waiter) = proc.waiter {
self.wakeup(waiter);

View File

@ -235,7 +235,7 @@ ifeq ($(arch), riscv32)
--disable-fp-emulation \
--host=riscv64-unknown-elf \
--with-payload=$(abspath $(kernel)) && \
make -j32 && \
make -j && \
cp bbl $(abspath $@)
else ifeq ($(arch), riscv64)
ifeq ($(board), k210)
@ -249,7 +249,7 @@ else
--disable-fp-emulation \
--host=riscv64-unknown-elf \
--with-payload=$(abspath $(kernel)) && \
make -j32 && \
make -j && \
cp bbl $(abspath $@)
endif
else ifeq ($(arch), aarch64)

View File

@ -11,9 +11,7 @@ extern fn eh_personality() {
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
let location = info.location().unwrap();
let message = info.message().unwrap();
error!("\n\nPANIC in {} at line {}\n {}", location.file(), location.line(), message);
error!("\n\n{}", info);
backtrace::backtrace();
loop { crate::arch::cpu::halt() }
}

View File

@ -376,6 +376,13 @@ impl Process {
}
self.futexes.get(&uaddr).unwrap().clone()
}
pub fn clone_for_exec(&mut self, other: &Self) {
self.files = other.files.clone();
self.cwd = other.cwd.clone();
self.pid = other.pid.clone();
self.parent = other.parent.clone();
self.threads = other.threads.clone();
}
}

View File

@ -6,11 +6,7 @@ use crate::fs::{ROOT_INODE, INodeExt};
use crate::process::*;
pub fn run_user_shell() {
//use crate::net::server;
//processor().manager().add(Thread::new_kernel(server, 0), 0);
if let Ok(inode) = ROOT_INODE.lookup("rust/sh") {
println!("Going to user mode shell.");
println!("Use 'ls' to list available programs.");
let data = inode.read_as_vec().unwrap();
processor().manager().add(Thread::new_user(data.as_slice(), "sh".split(' ')));
} else {

View File

@ -30,7 +30,7 @@ use crate::arch::interrupt;
use core::cell::UnsafeCell;
use core::fmt;
use core::ops::{Deref, DerefMut};
use core::sync::atomic::{ATOMIC_BOOL_INIT, AtomicBool, Ordering};
use core::sync::atomic::{AtomicBool, Ordering};
use super::Condvar;
pub type SpinLock<T> = Mutex<T, Spin>;
@ -78,7 +78,7 @@ impl<T, S: MutexSupport> Mutex<T, S>
/// ```
pub fn new(user_data: T) -> Mutex<T, S> {
Mutex {
lock: ATOMIC_BOOL_INIT,
lock: AtomicBool::new(false),
data: UnsafeCell::new(user_data),
support: S::new(),
}

View File

@ -13,7 +13,7 @@ use crate::process::*;
use crate::thread;
use crate::util;
use crate::arch::cpu;
use crate::arch::syscall;
use crate::arch::syscall::*;
use self::fs::*;
use self::mem::*;
@ -48,155 +48,155 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
// And https://fedora.juszkiewicz.com.pl/syscalls.html.
let ret = match id {
// file
syscall::SYS_READ => sys_read(args[0], args[1] as *mut u8, args[2]),
syscall::SYS_WRITE => sys_write(args[0], args[1] as *const u8, args[2]),
syscall::SYS_CLOSE => sys_close(args[0]),
syscall::SYS_FSTAT => sys_fstat(args[0], args[1] as *mut Stat),
syscall::SYS_LSEEK => sys_lseek(args[0], args[1] as i64, args[2] as u8),
syscall::SYS_MMAP => sys_mmap(args[0], args[1], args[2], args[3], args[4] as i32, args[5]),
syscall::SYS_MPROTECT => sys_mprotect(args[0], args[1], args[2]),
syscall::SYS_MUNMAP => sys_munmap(args[0], args[1]),
syscall::SYS_PREAD64 => sys_pread(args[0], args[1] as *mut u8, args[2], args[3]),
syscall::SYS_PWRITE64 => sys_pwrite(args[0], args[1] as *const u8, args[2], args[3]),
syscall::SYS_READV => sys_readv(args[0], args[1] as *const IoVec, args[2]),
syscall::SYS_WRITEV => sys_writev(args[0], args[1] as *const IoVec, args[2]),
syscall::SYS_SCHED_YIELD => sys_yield(),
syscall::SYS_NANOSLEEP => sys_nanosleep(args[0] as *const TimeSpec),
syscall::SYS_GETPID => sys_getpid(),
syscall::SYS_SOCKET => sys_socket(args[0], args[1], args[2]),
syscall::SYS_CONNECT => sys_connect(args[0], args[1] as *const SockAddr, args[2]),
syscall::SYS_ACCEPT => sys_accept(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
syscall::SYS_SENDTO => sys_sendto(args[0], args[1] as *const u8, args[2], args[3], args[4] as *const SockAddr, args[5]),
syscall::SYS_RECVFROM => sys_recvfrom(args[0], args[1] as *mut u8, args[2], args[3], args[4] as *mut SockAddr, args[5] as *mut u32),
// syscall::SYS_SENDMSG => sys_sendmsg(),
// syscall::SYS_RECVMSG => sys_recvmsg(),
syscall::SYS_SHUTDOWN => sys_shutdown(args[0], args[1]),
syscall::SYS_BIND => sys_bind(args[0], args[1] as *const SockAddr, args[2]),
syscall::SYS_LISTEN => sys_listen(args[0], args[1]),
syscall::SYS_GETSOCKNAME => sys_getsockname(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
syscall::SYS_GETPEERNAME => sys_getpeername(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
syscall::SYS_SETSOCKOPT => sys_setsockopt(args[0], args[1], args[2], args[3] as *const u8, args[4]),
syscall::SYS_GETSOCKOPT => sys_getsockopt(args[0], args[1], args[2], args[3] as *mut u8, args[4] as *mut u32),
syscall::SYS_CLONE => sys_clone(args[0], args[1], args[2] as *mut u32, args[3] as *mut u32, args[4], tf),
syscall::SYS_EXECVE => sys_exec(args[0] as *const u8, args[1] as *const *const u8, args[2] as *const *const u8, tf),
syscall::SYS_EXIT => sys_exit(args[0] as usize),
syscall::SYS_WAIT4 => sys_wait4(args[0] as isize, args[1] as *mut i32), // TODO: wait4
syscall::SYS_KILL => sys_kill(args[0], args[1]),
syscall::SYS_UNAME => sys_uname(args[0] as *mut u8),
syscall::SYS_FSYNC => sys_fsync(args[0]),
syscall::SYS_FDATASYNC => sys_fdatasync(args[0]),
syscall::SYS_TRUNCATE => sys_truncate(args[0] as *const u8, args[1]),
syscall::SYS_FTRUNCATE => sys_ftruncate(args[0], args[1]),
syscall::SYS_GETCWD => sys_getcwd(args[0] as *mut u8, args[1]),
syscall::SYS_CHDIR => sys_chdir(args[0] as *const u8),
syscall::SYS_GETTIMEOFDAY => sys_gettimeofday(args[0] as *mut TimeVal, args[1] as *const u8),
// syscall::SYS_GETRLIMIT => sys_getrlimit(),
syscall::SYS_GETRUSAGE => sys_getrusage(args[0], args[1] as *mut RUsage),
syscall::SYS_SYSINFO => sys_sysinfo(args[0] as *mut SysInfo),
syscall::SYS_GETPPID => sys_getppid(),
syscall::SYS_SETPRIORITY => sys_set_priority(args[0]),
// syscall::SYS_SETRLIMIT => sys_setrlimit(),
// syscall::SYS_SYNC => sys_sync(),
syscall::SYS_REBOOT => sys_reboot(args[0] as u32, args[1] as u32, args[2] as u32, args[3] as *const u8),
syscall::SYS_GETTID => sys_gettid(),
syscall::SYS_FUTEX => sys_futex(args[0], args[1] as u32, args[2] as i32, args[3] as *const TimeSpec),
syscall::SYS_SCHED_GETAFFINITY => sys_sched_getaffinity(args[0], args[1], args[2] as *mut u32),
syscall::SYS_GETDENTS64 => sys_getdents64(args[0], args[1] as *mut LinuxDirent64, args[2]),
syscall::SYS_CLOCK_GETTIME => sys_clock_gettime(args[0], args[1] as *mut TimeSpec),
syscall::SYS_EXIT_GROUP => sys_exit_group(args[0]),
syscall::SYS_OPENAT => sys_open(args[1] as *const u8, args[2], args[3]), // TODO: handle `dfd`
syscall::SYS_MKDIRAT => sys_mkdir(args[1] as *const u8, args[2]), // TODO: handle `dfd`
// syscall::SYS_MKNODAT => sys_mknod(),
syscall::SYS_NEWFSTATAT => sys_stat(args[1] as *const u8, args[2] as *mut Stat), // TODO: handle `dfd`, `flag`
syscall::SYS_UNLINKAT => sys_unlink(args[1] as *const u8), // TODO: handle `dfd`, `flag`
syscall::SYS_RENAMEAT => sys_rename(args[1] as *const u8, args[3] as *const u8), // TODO: handle `olddfd`, `newdfd`
syscall::SYS_LINKAT => sys_link(args[1] as *const u8, args[3] as *const u8), // TODO: handle `olddfd`, `newdfd`, `flags`
syscall::SYS_FACCESSAT => sys_access(args[1] as *const u8, args[2]), // TODO: handle `dfd`
syscall::SYS_ACCEPT4 => sys_accept(args[0], args[1] as *mut SockAddr, args[2] as *mut u32), // use accept for accept4
syscall::SYS_DUP3 => sys_dup2(args[0], args[1]), // TODO: handle `flags`
syscall::SYS_PIPE2 => sys_pipe(args[0] as *mut u32), // TODO: handle `flags`
SYS_READ => sys_read(args[0], args[1] as *mut u8, args[2]),
SYS_WRITE => sys_write(args[0], args[1] as *const u8, args[2]),
SYS_CLOSE => sys_close(args[0]),
SYS_FSTAT => sys_fstat(args[0], args[1] as *mut Stat),
SYS_LSEEK => sys_lseek(args[0], args[1] as i64, args[2] as u8),
SYS_MMAP => sys_mmap(args[0], args[1], args[2], args[3], args[4] as i32, args[5]),
SYS_MPROTECT => sys_mprotect(args[0], args[1], args[2]),
SYS_MUNMAP => sys_munmap(args[0], args[1]),
SYS_PREAD64 => sys_pread(args[0], args[1] as *mut u8, args[2], args[3]),
SYS_PWRITE64 => sys_pwrite(args[0], args[1] as *const u8, args[2], args[3]),
SYS_READV => sys_readv(args[0], args[1] as *const IoVec, args[2]),
SYS_WRITEV => sys_writev(args[0], args[1] as *const IoVec, args[2]),
SYS_SCHED_YIELD => sys_yield(),
SYS_NANOSLEEP => sys_nanosleep(args[0] as *const TimeSpec),
SYS_GETPID => sys_getpid(),
SYS_SOCKET => sys_socket(args[0], args[1], args[2]),
SYS_CONNECT => sys_connect(args[0], args[1] as *const SockAddr, args[2]),
SYS_ACCEPT => sys_accept(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
SYS_SENDTO => sys_sendto(args[0], args[1] as *const u8, args[2], args[3], args[4] as *const SockAddr, args[5]),
SYS_RECVFROM => sys_recvfrom(args[0], args[1] as *mut u8, args[2], args[3], args[4] as *mut SockAddr, args[5] as *mut u32),
// SYS_SENDMSG => sys_sendmsg(),
// SYS_RECVMSG => sys_recvmsg(),
SYS_SHUTDOWN => sys_shutdown(args[0], args[1]),
SYS_BIND => sys_bind(args[0], args[1] as *const SockAddr, args[2]),
SYS_LISTEN => sys_listen(args[0], args[1]),
SYS_GETSOCKNAME => sys_getsockname(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
SYS_GETPEERNAME => sys_getpeername(args[0], args[1] as *mut SockAddr, args[2] as *mut u32),
SYS_SETSOCKOPT => sys_setsockopt(args[0], args[1], args[2], args[3] as *const u8, args[4]),
SYS_GETSOCKOPT => sys_getsockopt(args[0], args[1], args[2], args[3] as *mut u8, args[4] as *mut u32),
SYS_CLONE => sys_clone(args[0], args[1], args[2] as *mut u32, args[3] as *mut u32, args[4], tf),
SYS_EXECVE => sys_exec(args[0] as *const u8, args[1] as *const *const u8, args[2] as *const *const u8, tf),
SYS_EXIT => sys_exit(args[0] as usize),
SYS_WAIT4 => sys_wait4(args[0] as isize, args[1] as *mut i32), // TODO: wait4
SYS_KILL => sys_kill(args[0], args[1]),
SYS_UNAME => sys_uname(args[0] as *mut u8),
SYS_FSYNC => sys_fsync(args[0]),
SYS_FDATASYNC => sys_fdatasync(args[0]),
SYS_TRUNCATE => sys_truncate(args[0] as *const u8, args[1]),
SYS_FTRUNCATE => sys_ftruncate(args[0], args[1]),
SYS_GETCWD => sys_getcwd(args[0] as *mut u8, args[1]),
SYS_CHDIR => sys_chdir(args[0] as *const u8),
SYS_GETTIMEOFDAY => sys_gettimeofday(args[0] as *mut TimeVal, args[1] as *const u8),
// SYS_GETRLIMIT => sys_getrlimit(),
SYS_GETRUSAGE => sys_getrusage(args[0], args[1] as *mut RUsage),
SYS_SYSINFO => sys_sysinfo(args[0] as *mut SysInfo),
SYS_GETPPID => sys_getppid(),
SYS_SETPRIORITY => sys_set_priority(args[0]),
// SYS_SETRLIMIT => sys_setrlimit(),
// SYS_SYNC => sys_sync(),
SYS_REBOOT => sys_reboot(args[0] as u32, args[1] as u32, args[2] as u32, args[3] as *const u8),
SYS_GETTID => sys_gettid(),
SYS_FUTEX => sys_futex(args[0], args[1] as u32, args[2] as i32, args[3] as *const TimeSpec),
SYS_SCHED_GETAFFINITY => sys_sched_getaffinity(args[0], args[1], args[2] as *mut u32),
SYS_GETDENTS64 => sys_getdents64(args[0], args[1] as *mut LinuxDirent64, args[2]),
SYS_CLOCK_GETTIME => sys_clock_gettime(args[0], args[1] as *mut TimeSpec),
SYS_EXIT_GROUP => sys_exit_group(args[0]),
SYS_OPENAT => sys_open(args[1] as *const u8, args[2], args[3]), // TODO: handle `dfd`
SYS_MKDIRAT => sys_mkdir(args[1] as *const u8, args[2]), // TODO: handle `dfd`
// SYS_MKNODAT => sys_mknod(),
SYS_NEWFSTATAT => sys_stat(args[1] as *const u8, args[2] as *mut Stat), // TODO: handle `dfd`, `flag`
SYS_UNLINKAT => sys_unlink(args[1] as *const u8), // TODO: handle `dfd`, `flag`
SYS_RENAMEAT => sys_rename(args[1] as *const u8, args[3] as *const u8), // TODO: handle `olddfd`, `newdfd`
SYS_LINKAT => sys_link(args[1] as *const u8, args[3] as *const u8), // TODO: handle `olddfd`, `newdfd`, `flags`
SYS_FACCESSAT => sys_access(args[1] as *const u8, args[2]), // TODO: handle `dfd`
SYS_ACCEPT4 => sys_accept(args[0], args[1] as *mut SockAddr, args[2] as *mut u32), // use accept for accept4
SYS_DUP3 => sys_dup2(args[0], args[1]), // TODO: handle `flags`
SYS_PIPE2 => sys_pipe(args[0] as *mut u32), // TODO: handle `flags`
// custom temporary syscall
syscall::SYS_MAP_PCI_DEVICE => sys_map_pci_device(args[0], args[1]),
syscall::SYS_GET_PADDR => sys_get_paddr(args[0] as *const u64, args[1] as *mut u64, args[2]),
SYS_MAP_PCI_DEVICE => sys_map_pci_device(args[0], args[1]),
SYS_GET_PADDR => sys_get_paddr(args[0] as *const u64, args[1] as *mut u64, args[2]),
// for musl: empty impl
syscall::SYS_BRK => {
SYS_BRK => {
warn!("sys_brk is unimplemented");
Ok(0)
}
syscall::SYS_RT_SIGACTION => {
SYS_RT_SIGACTION => {
warn!("sys_sigaction is unimplemented");
Ok(0)
}
syscall::SYS_RT_SIGPROCMASK => {
SYS_RT_SIGPROCMASK => {
warn!("sys_sigprocmask is unimplemented");
Ok(0)
}
syscall::SYS_IOCTL => {
SYS_IOCTL => {
warn!("sys_ioctl is unimplemented");
Ok(0)
}
syscall::SYS_MADVISE => {
SYS_MADVISE => {
warn!("sys_madvise is unimplemented");
Ok(0)
}
syscall::SYS_SETITIMER => {
SYS_SETITIMER => {
warn!("sys_setitimer is unimplemented");
Ok(0)
}
syscall::SYS_FCNTL => {
SYS_FCNTL => {
warn!("sys_fcntl is unimplemented");
Ok(0)
}
syscall::SYS_UMASK => {
SYS_UMASK => {
warn!("sys_umask is unimplemented");
Ok(0o777)
}
syscall::SYS_GETUID => {
SYS_GETUID => {
warn!("sys_getuid is unimplemented");
Ok(0)
}
syscall::SYS_GETGID => {
SYS_GETGID => {
warn!("sys_getgid is unimplemented");
Ok(0)
}
syscall::SYS_SETUID => {
SYS_SETUID => {
warn!("sys_setuid is unimplemented");
Ok(0)
}
syscall::SYS_GETEUID => {
SYS_GETEUID => {
warn!("sys_geteuid is unimplemented");
Ok(0)
}
syscall::SYS_GETEGID => {
SYS_GETEGID => {
warn!("sys_getegid is unimplemented");
Ok(0)
}
syscall::SYS_SETSID => {
SYS_SETSID => {
warn!("sys_setsid is unimplemented");
Ok(0)
}
syscall::SYS_SIGALTSTACK => {
SYS_SIGALTSTACK => {
warn!("sys_sigaltstack is unimplemented");
Ok(0)
}
syscall::SYS_SYNC => {
SYS_SYNC => {
warn!("sys_sync is unimplemented");
Ok(0)
}
syscall::SYS_SET_TID_ADDRESS => {
SYS_SET_TID_ADDRESS => {
warn!("sys_set_tid_address is unimplemented");
Ok(thread::current().id())
}
syscall::SYS_UTIMENSAT => {
SYS_UTIMENSAT => {
warn!("sys_utimensat is unimplemented");
Ok(0)
}
syscall::SYS_EPOLL_CREATE1 => {
SYS_EPOLL_CREATE1 => {
warn!("sys_epoll_create1 is unimplemented");
Err(SysError::ENOSYS)
}
syscall::SYS_PRLIMIT64 => {
SYS_PRLIMIT64 => {
warn!("sys_prlimit64 is unimplemented");
Ok(0)
}
@ -226,37 +226,37 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize {
#[cfg(target_arch = "x86_64")]
fn x86_64_syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> Option<SysResult> {
let ret = match id {
syscall::SYS_OPEN => sys_open(args[0] as *const u8, args[1], args[2]),
syscall::SYS_STAT => sys_stat(args[0] as *const u8, args[1] as *mut Stat),
syscall::SYS_LSTAT => sys_lstat(args[0] as *const u8, args[1] as *mut Stat),
syscall::SYS_POLL => sys_poll(args[0] as *mut PollFd, args[1], args[2]),
syscall::SYS_ACCESS => sys_access(args[0] as *const u8, args[1]),
syscall::SYS_PIPE => sys_pipe(args[0] as *mut u32),
syscall::SYS_SELECT => sys_select(args[0], args[1] as *mut u32, args[2] as *mut u32, args[3] as *mut u32, args[4] as *const TimeVal),
syscall::SYS_DUP2 => sys_dup2(args[0], args[1]),
// syscall::SYS_PAUSE => sys_pause(),
SYS_OPEN => sys_open(args[0] as *const u8, args[1], args[2]),
SYS_STAT => sys_stat(args[0] as *const u8, args[1] as *mut Stat),
SYS_LSTAT => sys_lstat(args[0] as *const u8, args[1] as *mut Stat),
SYS_POLL => sys_poll(args[0] as *mut PollFd, args[1], args[2]),
SYS_ACCESS => sys_access(args[0] as *const u8, args[1]),
SYS_PIPE => sys_pipe(args[0] as *mut u32),
SYS_SELECT => sys_select(args[0], args[1] as *mut u32, args[2] as *mut u32, args[3] as *mut u32, args[4] as *const TimeVal),
SYS_DUP2 => sys_dup2(args[0], args[1]),
// SYS_PAUSE => sys_pause(),
SYS_FORK => sys_fork(tf),
// use fork for vfork
syscall::SYS_VFORK => sys_fork(tf),
syscall::SYS_RENAME => sys_rename(args[0] as *const u8, args[1] as *const u8),
syscall::SYS_MKDIR => sys_mkdir(args[0] as *const u8, args[1]),
syscall::SYS_LINK => sys_link(args[0] as *const u8, args[1] as *const u8),
syscall::SYS_UNLINK => sys_unlink(args[0] as *const u8),
syscall::SYS_ARCH_PRCTL => sys_arch_prctl(args[0] as i32, args[1], tf),
syscall::SYS_TIME => sys_time(args[0] as *mut u64),
syscall::SYS_ALARM => {
SYS_VFORK => sys_fork(tf),
SYS_RENAME => sys_rename(args[0] as *const u8, args[1] as *const u8),
SYS_MKDIR => sys_mkdir(args[0] as *const u8, args[1]),
SYS_LINK => sys_link(args[0] as *const u8, args[1] as *const u8),
SYS_UNLINK => sys_unlink(args[0] as *const u8),
SYS_ARCH_PRCTL => sys_arch_prctl(args[0] as i32, args[1], tf),
SYS_TIME => sys_time(args[0] as *mut u64),
SYS_ALARM => {
warn!("sys_alarm is unimplemented");
Ok(0)
}
syscall::SYS_READLINK => {
SYS_READLINK => {
warn!("sys_readlink is unimplemented");
Err(SysError::ENOENT)
}
syscall::SYS_CHOWN => {
SYS_CHOWN => {
warn!("sys_chown is unimplemented");
Ok(0)
}
syscall::SYS_EPOLL_CREATE => {
SYS_EPOLL_CREATE => {
warn!("sys_epoll_create is unimplemented");
Err(SysError::ENOSYS)
}

View File

@ -1,6 +1,7 @@
//! Syscalls for process
use super::*;
use crate::fs::INodeExt;
/// Fork the current process. Return the child's PID.
pub fn sys_fork(tf: &TrapFrame) -> SysResult {
@ -120,19 +121,12 @@ pub fn sys_exec(name: *const u8, argv: *const *const u8, envp: *const *const u8,
// Read program file
let path = args[0].as_str();
let inode = crate::fs::ROOT_INODE.lookup(path)?;
let size = inode.metadata()?.size;
let mut buf = Vec::with_capacity(size);
unsafe { buf.set_len(size); }
inode.read_at(0, buf.as_mut_slice())?;
let buf = inode.read_as_vec()?;
// Make new Thread
let iter = args.iter().map(|s| s.as_str());
let mut thread = Thread::new_user(buf.as_slice(), iter);
thread.proc.lock().files = proc.files.clone();
thread.proc.lock().cwd = proc.cwd.clone();
thread.proc.lock().pid = proc.pid.clone();
thread.proc.lock().parent = proc.parent.clone();
thread.proc.lock().threads = proc.threads.clone();
thread.proc.lock().clone_for_exec(&proc);
// Activate new page table
unsafe { thread.proc.lock().memory_set.activate(); }