<commit_before>#include <kernel.h>
#include <mm/heap.h>
#include <mm/virtual.h>
#include <string.h>
#include <tm/sched.h>

struct runqueue rq;

extern void process_init(void);

void sched_init(void)
{
    process_init();
    memset(&rq, 0, sizeof(struct runqueue));
    list_runtime_init(&rq.runnable);
    struct process* kernel_process = process_allocate();
    kernel_process->ctx.page_table = kernel_context.page_table;
    struct thread* kinit = kzalloc(sizeof(struct thread));
    struct thread* kidle = kzalloc(sizeof(struct thread));
    list_add(&kernel_process->threads, &kinit->process_list);
    kinit->process = kernel_process;
    process_add(kernel_process);
    sched_add(kinit);
    current_thread = kinit;
}

void sched_add(struct thread* thread)
{
    runqueue_insert(&rq, thread);
}

void sched_tick(struct interrupt_ctx* ctx)
{
    struct thread* next = runqueue_next(&rq);
    thread_switch(ctx, current_thread, next);
}

void runqueue_insert(struct runqueue* rq, struct thread* thread)
{
    list_add(&rq->runnable, &thread->runqueue_list);
    rq->num_threads++;
}

void runqueue_remove(struct runqueue* rq, struct thread* thread)<commit_msg>No need to allocate kidle yet<commit_after>#include <kernel.h>
#include <mm/heap.h>
#include <mm/virtual.h>
#include <string.h>
#include <tm/sched.h>

struct runqueue rq;

extern void process_init(void);

void sched_init(void)
{
    process_init();
    memset(&rq, 0, sizeof(struct runqueue));
    list_runtime_init(&rq.runnable);
    struct process* kernel_process = process_allocate();
    kernel_process->ctx.page_table = kernel_context.page_table;
    struct thread* kinit = kzalloc(sizeof(struct thread));
    list_add(&kernel_process->threads, &kinit->process_list);
    kinit->process = kernel_process;
    process_add(kernel_process);
    sched_add(kinit);
    current_thread = kinit;
}

void sched_add(struct thread* thread)
{
    runqueue_insert(&rq, thread);
}

void sched_tick(struct interrupt_ctx* ctx)
{
    struct thread* next = runqueue_next(&rq);
    thread_switch(ctx, current_thread, next);
}

void runqueue_insert(struct runqueue* rq, struct thread* thread)
{
    list_add(&rq->runnable, &thread->runqueue_list);
    rq->num_threads++;
}

void runqueue_remove(struct runqueue* rq, struct thread* thread)
{'fraction_non_alphanumeric': 0.12800349497597205, 'fraction_numerical': 0.0008737439930100481, 'mean_word_length': 5.122994652406417, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2671299', 'n_tokens_mistral': 778, 'n_tokens_neox': 764, 'n_words': 163}