Compare commits

..

No commits in common. "5f56e4b63a9524b2aa9dd119c9e9f96a1a527ea6" and "ec6ceb4c8d323641c80f93124b58c42b48da9587" have entirely different histories.

6 changed files with 9 additions and 21 deletions

View File

@ -12,4 +12,4 @@ target_compile_definitions(moon PRIVATE DEVICE_REGISTRY_DEBUG)
target_compile_definitions(moon PRIVATE FORK_DEBUG) target_compile_definitions(moon PRIVATE FORK_DEBUG)
target_compile_definitions(moon PRIVATE MOUNT_DEBUG) target_compile_definitions(moon PRIVATE MOUNT_DEBUG)
target_compile_definitions(moon PRIVATE CACHE_DEBUG) target_compile_definitions(moon PRIVATE CACHE_DEBUG)
#target_compile_options(moon PRIVATE -fsanitize=undefined) target_compile_options(moon PRIVATE -fsanitize=undefined)

View File

@ -15,7 +15,7 @@ void Thread::set_ip(u64 ip)
regs.rip = ip; regs.rip = ip;
} }
u64 Thread::ip() const u64 Thread::ip()
{ {
return regs.rip; return regs.rip;
} }
@ -25,7 +25,7 @@ void Thread::set_sp(u64 sp)
regs.rsp = sp; regs.rsp = sp;
} }
u64 Thread::sp() const u64 Thread::sp()
{ {
return regs.rsp; return regs.rsp;
} }

View File

@ -243,7 +243,7 @@ Result<u64> sys_fork(Registers* regs, SyscallArgs)
Scheduler::add_process(process); Scheduler::add_process(process);
#ifdef FORK_DEBUG #ifdef FORK_DEBUG
kdbgln("fork: thread %d forked into child %d", current->id, process->id); kdbgln("fork: thread %d forked into child %d", current->id, thread->id);
#endif #endif
return process->id; return process->id;

View File

@ -251,7 +251,7 @@ namespace Scheduler
CPU::disable_interrupts(); CPU::disable_interrupts();
#ifdef REAP_DEBUG #ifdef REAP_DEBUG
kdbgln("reap: reaping thread with id %d", thread->tid); kdbgln("reap: reaping thread with id %d", thread->id);
#endif #endif
if (thread->is_kernel) if (thread->is_kernel)
@ -409,16 +409,6 @@ namespace Scheduler
return {}; 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 has_children(Process* process)
{ {
bool result { false }; bool result { false };
@ -457,9 +447,8 @@ namespace Scheduler
for (const auto* thread : g_threads) for (const auto* thread : g_threads)
{ {
kdbgln("Thread %p (belongs to pid %4d) %c [%-20s] %4d, state = %d, ip = %p", thread, thread->process->id, 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, thread->is_kernel ? 'k' : 'u', thread->cmdline.chars(), thread->tid, (int)thread->state);
(void*)thread->ip());
} }
for (const auto* process : g_processes) for (const auto* process : g_processes)

View File

@ -38,7 +38,6 @@ namespace Scheduler
LinkedList<Process> check_for_dead_processes(); LinkedList<Process> check_for_dead_processes();
Option<Process*> find_by_pid(pid_t pid); 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) template <typename Callback> void for_each_child(Process* process, Callback callback)
{ {

View File

@ -198,10 +198,10 @@ struct Thread : public LinkedListNode<Thread>
void set_arguments(u64 arg1, u64 arg2, u64 arg3, u64 arg4); void set_arguments(u64 arg1, u64 arg2, u64 arg3, u64 arg4);
void set_ip(u64 ip); void set_ip(u64 ip);
u64 ip() const; u64 ip();
void set_sp(u64 sp); void set_sp(u64 sp);
u64 sp() const; u64 sp();
void set_return(u64 ret); void set_return(u64 ret);
u64 return_register(); u64 return_register();