Compare commits
5 Commits
ec6ceb4c8d
...
5f56e4b63a
Author | SHA1 | Date | |
---|---|---|---|
5f56e4b63a | |||
24b886b0d1 | |||
d8e4489079 | |||
2868fd8122 | |||
56a2b607b5 |
@ -12,4 +12,4 @@ target_compile_definitions(moon PRIVATE DEVICE_REGISTRY_DEBUG)
|
||||
target_compile_definitions(moon PRIVATE FORK_DEBUG)
|
||||
target_compile_definitions(moon PRIVATE MOUNT_DEBUG)
|
||||
target_compile_definitions(moon PRIVATE CACHE_DEBUG)
|
||||
target_compile_options(moon PRIVATE -fsanitize=undefined)
|
||||
#target_compile_options(moon PRIVATE -fsanitize=undefined)
|
||||
|
@ -15,7 +15,7 @@ void Thread::set_ip(u64 ip)
|
||||
regs.rip = ip;
|
||||
}
|
||||
|
||||
u64 Thread::ip()
|
||||
u64 Thread::ip() const
|
||||
{
|
||||
return regs.rip;
|
||||
}
|
||||
@ -25,7 +25,7 @@ void Thread::set_sp(u64 sp)
|
||||
regs.rsp = sp;
|
||||
}
|
||||
|
||||
u64 Thread::sp()
|
||||
u64 Thread::sp() const
|
||||
{
|
||||
return regs.rsp;
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
|
||||
Scheduler::add_process(process);
|
||||
|
||||
#ifdef FORK_DEBUG
|
||||
kdbgln("fork: thread %d forked into child %d", current->id, thread->id);
|
||||
kdbgln("fork: thread %d forked into child %d", current->id, process->id);
|
||||
#endif
|
||||
|
||||
return process->id;
|
||||
|
@ -251,7 +251,7 @@ namespace Scheduler
|
||||
CPU::disable_interrupts();
|
||||
|
||||
#ifdef REAP_DEBUG
|
||||
kdbgln("reap: reaping thread with id %d", thread->id);
|
||||
kdbgln("reap: reaping thread with id %d", thread->tid);
|
||||
#endif
|
||||
|
||||
if (thread->is_kernel)
|
||||
@ -409,6 +409,16 @@ namespace Scheduler
|
||||
return {};
|
||||
}
|
||||
|
||||
Option<Thread*> find_by_tid(pid_t tid)
|
||||
{
|
||||
for (auto* const thread : g_threads)
|
||||
{
|
||||
if (thread->tid == tid) return thread;
|
||||
}
|
||||
|
||||
return {};
|
||||
}
|
||||
|
||||
bool has_children(Process* process)
|
||||
{
|
||||
bool result { false };
|
||||
@ -447,8 +457,9 @@ namespace Scheduler
|
||||
|
||||
for (const auto* thread : g_threads)
|
||||
{
|
||||
kdbgln("Thread %p (belongs to pid %4d) %c [%-20s] %4d, state = %d", thread, thread->process->id,
|
||||
thread->is_kernel ? 'k' : 'u', thread->cmdline.chars(), thread->tid, (int)thread->state);
|
||||
kdbgln("Thread %p (belongs to pid %4d) %c [%-20s] %4d, state = %d, ip = %p", thread, thread->process->id,
|
||||
thread->is_kernel ? 'k' : 'u', thread->cmdline.chars(), thread->tid, (int)thread->state,
|
||||
(void*)thread->ip());
|
||||
}
|
||||
|
||||
for (const auto* process : g_processes)
|
||||
|
@ -38,6 +38,7 @@ namespace Scheduler
|
||||
LinkedList<Process> check_for_dead_processes();
|
||||
|
||||
Option<Process*> find_by_pid(pid_t pid);
|
||||
Option<Thread*> find_by_tid(pid_t tid);
|
||||
|
||||
template <typename Callback> void for_each_child(Process* process, Callback callback)
|
||||
{
|
||||
|
@ -198,10 +198,10 @@ struct Thread : public LinkedListNode<Thread>
|
||||
void set_arguments(u64 arg1, u64 arg2, u64 arg3, u64 arg4);
|
||||
|
||||
void set_ip(u64 ip);
|
||||
u64 ip();
|
||||
u64 ip() const;
|
||||
|
||||
void set_sp(u64 sp);
|
||||
u64 sp();
|
||||
u64 sp() const;
|
||||
|
||||
void set_return(u64 ret);
|
||||
u64 return_register();
|
||||
|
Loading…
Reference in New Issue
Block a user