feature (threads): added default end point for thread execution
This commit is contained in:
parent
23af4ccdab
commit
6709aa9de5
|
@ -111,7 +111,6 @@ thread_T* scheduler_register_thread(thread_T* thread) {
|
|||
thread->process->num_threads++;
|
||||
g_scheduler.num_threads++;
|
||||
|
||||
log(LOG_INFO, "<Scheduler> Registered thread");
|
||||
scheduler_update_info();
|
||||
|
||||
return thread;
|
||||
|
@ -119,13 +118,11 @@ thread_T* scheduler_register_thread(thread_T* thread) {
|
|||
|
||||
void scheduler_pause_thread(thread_T* thread) {
|
||||
scheduler_queue_remove_thread(thread);
|
||||
log(LOG_INFO, "<Scheduler> Paused thread");
|
||||
scheduler_update_info();
|
||||
}
|
||||
|
||||
void scheduler_start_thread(thread_T* thread) {
|
||||
scheduler_queue_add_thread(thread);
|
||||
log(LOG_INFO, "<Scheduler> Started thread");
|
||||
scheduler_update_info();
|
||||
}
|
||||
|
||||
|
@ -147,7 +144,6 @@ void scheduler_kill_thread(thread_T* thread) {
|
|||
thread->process->num_threads--;
|
||||
g_scheduler.num_threads--;
|
||||
|
||||
log(LOG_INFO, "<Scheduler> Killed thread");
|
||||
scheduler_update_info();
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
#include "utils/memory.h"
|
||||
#include "utils/logger.h"
|
||||
|
||||
void thread_end_point() {
|
||||
// this has to kill the thread in future
|
||||
while (1) asm("hlt");
|
||||
}
|
||||
|
||||
thread_T* thread_spawn(pid_t process, void* function) {
|
||||
thread_T* thread = memory_allocate(sizeof(thread_T));
|
||||
|
||||
|
@ -29,8 +34,6 @@ thread_T* thread_spawn(pid_t process, void* function) {
|
|||
|
||||
uint8_t* base = (uint8_t*)((process == PROCESS_KERNEL ? MEM_REGION_KERNEL_THREAD_BASE : MEM_REGION_PROCESS_THREAD_BASE) + (MEM_REGION_THREAD_OFFSET * thread->local_id));
|
||||
|
||||
log(LOG_DEBUG, "spawning thread with base address: 0x%x", base);
|
||||
|
||||
thread->cpu_time = 0;
|
||||
|
||||
thread->stack_size = PFRAME_SIZE * 4;
|
||||
|
@ -41,6 +44,8 @@ thread_T* thread_spawn(pid_t process, void* function) {
|
|||
page_map_map_memory(g_kernel_page_map, MEM_REGION_KERNEL_STACK_DUMMY + i * PFRAME_SIZE, physical_address, PM_FLAG_READ_WRITE);
|
||||
}
|
||||
|
||||
*((uint64_t*)(MEM_REGION_KERNEL_STACK_DUMMY + (thread->stack_size - sizeof(cpu_state_T) - 8))) = (uint64_t)thread_end_point;
|
||||
|
||||
cpu_state_T state = {
|
||||
.cr3 = (uint64_t)thread->process->page_map,
|
||||
.rax = 0,
|
||||
|
|
Loading…
Reference in New Issue