XenevaOS
Loading...
Searching...
No Matches
Functions | Variables
sched.c File Reference
#include <stdint.h>
#include <Hal/AA64/aa64cpu.h>
#include <Hal/AA64/sched.h>
#include <Mm/pmmngr.h>
#include <Mm/kmalloc.h>
#include <Mm/vmmngr.h>
#include <string.h>
#include <_null.h>
#include <Hal/AA64/aa64lowlevel.h>
#include <Drivers/uart.h>
#include <Hal/AA64/gic.h>
#include <aucon.h>
#include <aurora.h>
Include dependency graph for sched.c:

Functions

void aa64_store_context (AA64Thread *thr)
 
void store_syscall (AA64Thread *thr)
 
bool aa64_restore_context (AA64Thread *thr)
 
void ret_from_syscall (AA64Thread *thr)
 
void first_time_sex (AA64Thread *thr)
 
void first_time_sex2 (AA64Thread *thr)
 
uint64_t read_sp ()
 
void AuThreadInsert (AA64Thread *new_task)
 AuThreadInsert – insert a thread into thread list.
 
void AuThreadDelete (AA64Thread *thread)
 AuThreadDelete – remove a thread from thread list.
 
void AuThreadInsertBlock (AA64Thread *new_task)
 AuThreadInsertBlock – insert a thread to block thread list.
 
void AuThreadDeleteBlock (AA64Thread *thread)
 AuThreadDeleteBlock – remove a thread from thread list.
 
void AuThreadInsertTrash (AA64Thread *new_task)
 AuThreadInsertTrash – Insert a thread to trash list.
 
void AuThreadDeleteTrash (AA64Thread *thread)
 AuThreadDeleteTrash – remove a thread from thread list.
 
void AuThreadInsertSleep (AA64Thread *new_task)
 AuThreadInsertSleep – Insert a thread to sleep list.
 
void AuThreadDeleteSleep (AA64Thread *thread)
 AuThreadDeleteSleep – remove a thread from sleep list.
 
void AA64NextThread ()
 
AA64Thread * AuCreateKthread (void(*entry)(uint64_t), uint64_t *pml, char *name)
 AuCreateKthread – create kernel thread.
 
void PrintThreadInfo ()
 
void AuIdleThread (uint64_t ctx)
 
void resume_user (AA64Thread *thr, void *ksp)
 
void AuResumeUserThread ()
 
uint64_t read_x30 ()
 
void settimerdebug ()
 
void enscheddebug ()
 
void AuHandleSleepThreads ()
 
void PrintThrIn ()
 
void AuThreadSafeReturn (uint64_t rcx)
 
void AuPrintStack (uint64_t st)
 
void AuScheduleThread (AA64Registers *regs)
 AuScheduleThread – the core of multi-tasking. It schedules threads next to be runned.
 
bool setStk ()
 
uint64_t AuCreateKernelStack (uint64_t *pml)
 AuCreateKernelStack – maps kernel stack and return the top of the stack, it only maps 4KiB of stack.
 
void AuSchedulerInitialize ()
 AuSchedulerInitialize – initialize the scheduler.
 
void AuSchedulerStart ()
 AuSchedulerStart – start the scheduler.
 
AA64Thread * AuGetIdleThread ()
 
AA64Thread * AuGetCurrentThread ()
 
void AuForceScheduler ()
 AuForceScheduler – force the scheduler to switch next thread.
 
void AuBlockThread (AA64Thread *thread)
 AuBlockThread – blocks a running thread.
 
void AuUnblockThread (AA64Thread *thread)
 AuUnblockThread – unblocks a thread and insert it to ready list.
 
void AuSleepThread (AA64Thread *thread, uint64_t ms)
 AuSleepThread – block a running thread and put it into sleep list.
 
AA64Thread * AuThreadFindByID (uint64_t id)
 AuThreadFindByID – finds a thread by its id from ready queue.
 
AA64Thread * AuThreadFindByIDBlockList (uint64_t id)
 AuThreadFindByIDBlockList – finds a thread by its id from the block queue.
 
void AuThreadMoveToTrash (AA64Thread *t)
 AuThreadMoveToTrash – move given thread to trash.
 
uint64_t AuGetSystemTimerTick ()
 AuGetSystemTimerTick – return the current system timer tick.
 
void AuSetIdleThread (AA64Thread *thr)
 AuSetIdleThread – change the idle thread pointer.
 

Variables

AA64Thread * thread_list_head
 
AA64Thread * thread_list_last
 
AA64Thread * blocked_thr_head
 
AA64Thread * blocked_thr_last
 
AA64Thread * trash_thr_head
 
AA64Thread * trash_thr_last
 
AA64Thread * sleep_thr_head
 
AA64Thread * sleep_thr_last
 
AA64Thread * current_thread
 
AA64Thread * _idle_thr
 
uint64_t thread_id
 
bool _scheduler_initialized
 
uint64_t scheduler_tick
 
bool debug = 0
 
uint64_t stack_index
 

Detailed Description

BSD 2-Clause License

Copyright (c) 2022-2025, Manas Kamal Choudhury All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ aa64_restore_context()

bool aa64_restore_context ( AA64Thread *  thr)
extern

◆ aa64_store_context()

void aa64_store_context ( AA64Thread *  thr)
extern

◆ AA64NextThread()

void AA64NextThread ( )

◆ AuBlockThread()

void AuBlockThread ( AA64Thread *  thread)

AuBlockThread – blocks a running thread.

Parameters
thread– Pointer to AA64 Thread

◆ AuCreateKernelStack()

uint64_t AuCreateKernelStack ( uint64_t pml)

AuCreateKernelStack – maps kernel stack and return the top of the stack, it only maps 4KiB of stack.

Parameters
pml– Pointer to page directory
Returns
kernel stack address

◆ AuCreateKthread()

AA64Thread * AuCreateKthread ( void(*)(uint64_t entry,
uint64_t pml,
char *  name 
)

AuCreateKthread – create kernel thread.

Parameters
entry– Pointer to entry point
pml– Pointer to Page directory
name– Name of the thread
Returns
Pointer to newly created thread

◆ AuForceScheduler()

void AuForceScheduler ( )

AuForceScheduler – force the scheduler to switch next thread.

◆ AuGetCurrentThread()

AA64Thread * AuGetCurrentThread ( )

◆ AuGetIdleThread()

AA64Thread * AuGetIdleThread ( )

◆ AuGetSystemTimerTick()

uint64_t AuGetSystemTimerTick ( )

AuGetSystemTimerTick – return the current system timer tick.

◆ AuHandleSleepThreads()

void AuHandleSleepThreads ( )

◆ AuIdleThread()

void AuIdleThread ( uint64_t  ctx)

◆ AuPrintStack()

void AuPrintStack ( uint64_t  st)
extern

◆ AuResumeUserThread()

void AuResumeUserThread ( )

◆ AuSchedulerInitialize()

void AuSchedulerInitialize ( )

AuSchedulerInitialize – initialize the scheduler.

◆ AuSchedulerStart()

void AuSchedulerStart ( )

AuSchedulerStart – start the scheduler.

◆ AuScheduleThread()

void AuScheduleThread ( AA64Registers regs)

AuScheduleThread – the core of multi-tasking. It schedules threads next to be runned.

Parameters
regs– Passed by Timer ISR

◆ AuSetIdleThread()

void AuSetIdleThread ( AA64Thread *  thr)

AuSetIdleThread – change the idle thread pointer.

Parameters
thr– Pointer to idle thread

◆ AuSleepThread()

void AuSleepThread ( AA64Thread *  thread,
uint64_t  ms 
)

AuSleepThread – block a running thread and put it into sleep list.

Parameters
thread– Pointer to AA64 Thread

◆ AuThreadDelete()

void AuThreadDelete ( AA64Thread *  thread)

AuThreadDelete – remove a thread from thread list.

Parameters
thread– thread address to remove

◆ AuThreadDeleteBlock()

void AuThreadDeleteBlock ( AA64Thread *  thread)

AuThreadDeleteBlock – remove a thread from thread list.

Parameters
thread– thread address to remove

◆ AuThreadDeleteSleep()

void AuThreadDeleteSleep ( AA64Thread *  thread)

AuThreadDeleteSleep – remove a thread from sleep list.

Parameters
thread– thread address to remove

◆ AuThreadDeleteTrash()

void AuThreadDeleteTrash ( AA64Thread *  thread)

AuThreadDeleteTrash – remove a thread from thread list.

Parameters
thread– thread address to remove

◆ AuThreadFindByID()

AA64Thread * AuThreadFindByID ( uint64_t  id)

AuThreadFindByID – finds a thread by its id from ready queue.

Parameters
id– id of the thread

◆ AuThreadFindByIDBlockList()

AA64Thread * AuThreadFindByIDBlockList ( uint64_t  id)

AuThreadFindByIDBlockList – finds a thread by its id from the block queue.

Parameters
id– id of the thread

◆ AuThreadInsert()

void AuThreadInsert ( AA64Thread *  new_task)

AuThreadInsert – insert a thread into thread list.

Parameters
new_task– pointer to thread that need to insert

◆ AuThreadInsertBlock()

void AuThreadInsertBlock ( AA64Thread *  new_task)

AuThreadInsertBlock – insert a thread to block thread list.

Parameters
new_task– Pointer to thread

◆ AuThreadInsertSleep()

void AuThreadInsertSleep ( AA64Thread *  new_task)

AuThreadInsertSleep – Insert a thread to sleep list.

Parameters
new_task– new thread address

◆ AuThreadInsertTrash()

void AuThreadInsertTrash ( AA64Thread *  new_task)

AuThreadInsertTrash – Insert a thread to trash list.

Parameters
new_task– new thread address

◆ AuThreadMoveToTrash()

void AuThreadMoveToTrash ( AA64Thread *  t)

AuThreadMoveToTrash – move given thread to trash.

Parameters
t– Thread to move to trash

◆ AuThreadSafeReturn()

void AuThreadSafeReturn ( uint64_t  rcx)

◆ AuUnblockThread()

void AuUnblockThread ( AA64Thread *  thread)

AuUnblockThread – unblocks a thread and insert it to ready list.

Parameters
t– pointer to thread

◆ enscheddebug()

void enscheddebug ( )

◆ first_time_sex()

void first_time_sex ( AA64Thread *  thr)
extern

◆ first_time_sex2()

void first_time_sex2 ( AA64Thread *  thr)
extern

◆ PrintThreadInfo()

void PrintThreadInfo ( )
extern

◆ PrintThrIn()

void PrintThrIn ( )

◆ read_sp()

uint64_t read_sp ( )
extern

◆ read_x30()

uint64_t read_x30 ( )
extern

◆ resume_user()

void resume_user ( AA64Thread *  thr,
void *  ksp 
)
extern

◆ ret_from_syscall()

void ret_from_syscall ( AA64Thread *  thr)
extern

◆ setStk()

bool setStk ( )

◆ settimerdebug()

void settimerdebug ( )
extern

◆ store_syscall()

void store_syscall ( AA64Thread *  thr)
extern

Variable Documentation

◆ _idle_thr

AA64Thread* _idle_thr

◆ _scheduler_initialized

bool _scheduler_initialized

◆ blocked_thr_head

AA64Thread* blocked_thr_head

◆ blocked_thr_last

AA64Thread* blocked_thr_last

◆ current_thread

AA64Thread* current_thread

◆ debug

bool debug = 0

◆ scheduler_tick

uint64_t scheduler_tick

◆ sleep_thr_head

AA64Thread* sleep_thr_head

◆ sleep_thr_last

AA64Thread* sleep_thr_last

◆ stack_index

uint64_t stack_index

◆ thread_id

uint64_t thread_id

◆ thread_list_head

AA64Thread* thread_list_head

◆ thread_list_last

AA64Thread* thread_list_last

◆ trash_thr_head

AA64Thread* trash_thr_head

◆ trash_thr_last

AA64Thread* trash_thr_last