mirror of
https://github.com/EnderIce2/Fennix.git
synced 2025-05-28 15:34:31 +00:00
feat(kernel): add hot and cold attributes to optimize function performance
Signed-off-by: EnderIce2 <enderice2@protonmail.com>
This commit is contained in:
parent
f9476d8c57
commit
d06b6d3270
@ -264,7 +264,7 @@ namespace Interrupts
|
|||||||
warn("IRQ%d not found.", InterruptNumber);
|
warn("IRQ%d not found.", InterruptNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa inline void ReturnFromInterrupt()
|
nsa hot inline void ReturnFromInterrupt()
|
||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
CPUData *CoreData = GetCurrentCPU();
|
CPUData *CoreData = GetCurrentCPU();
|
||||||
@ -309,7 +309,7 @@ namespace Interrupts
|
|||||||
CPU::Stop();
|
CPU::Stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" nsa void MainInterruptHandler(void *Data)
|
extern "C" nsa hot void MainInterruptHandler(void *Data)
|
||||||
{
|
{
|
||||||
class AutoSwitchPageTable
|
class AutoSwitchPageTable
|
||||||
{
|
{
|
||||||
@ -384,7 +384,7 @@ namespace Interrupts
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
extern "C" nsa void SchedulerInterruptHandler(void *Data)
|
extern "C" nsa hot void SchedulerInterruptHandler(void *Data)
|
||||||
{
|
{
|
||||||
#if defined(__amd64__) || defined(__i386__)
|
#if defined(__amd64__) || defined(__i386__)
|
||||||
KernelPageTable->Update();
|
KernelPageTable->Update();
|
||||||
|
@ -458,6 +458,9 @@ typedef uint48_t uint_fast48_t;
|
|||||||
#define likely(x) __builtin_expect(!!(x), 1)
|
#define likely(x) __builtin_expect(!!(x), 1)
|
||||||
#define unlikely(x) __builtin_expect(!!(x), 0)
|
#define unlikely(x) __builtin_expect(!!(x), 0)
|
||||||
|
|
||||||
|
#define hot __attribute__((hot))
|
||||||
|
#define cold __attribute__((cold))
|
||||||
|
|
||||||
#define NoSecurityAnalysis __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_sanitize_thread
|
#define NoSecurityAnalysis __no_stack_protector __no_sanitize_address __no_sanitize_undefined __no_sanitize_thread
|
||||||
#define nsa NoSecurityAnalysis
|
#define nsa NoSecurityAnalysis
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ EXTERNC void KPrint(const char *Format, ...)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
EXTERNC NIF void Main()
|
EXTERNC NIF cold void Main()
|
||||||
{
|
{
|
||||||
Display = new Video::Display(bInfo.Framebuffer[0]);
|
Display = new Video::Display(bInfo.Framebuffer[0]);
|
||||||
KernelConsole::EarlyInit();
|
KernelConsole::EarlyInit();
|
||||||
@ -265,7 +265,7 @@ typedef void (*CallPtr)(void);
|
|||||||
extern CallPtr __init_array_start[0], __init_array_end[0];
|
extern CallPtr __init_array_start[0], __init_array_end[0];
|
||||||
extern CallPtr __fini_array_start[0], __fini_array_end[0];
|
extern CallPtr __fini_array_start[0], __fini_array_end[0];
|
||||||
|
|
||||||
EXTERNC __no_stack_protector NIF void Entry(BootInfo *Info)
|
EXTERNC __no_stack_protector NIF cold void Entry(BootInfo *Info)
|
||||||
{
|
{
|
||||||
trace("Hello, World!");
|
trace("Hello, World!");
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@
|
|||||||
#include <vm.hpp>
|
#include <vm.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
int SpawnInit()
|
cold int SpawnInit()
|
||||||
{
|
{
|
||||||
const char *envp[6] = {
|
const char *envp[6] = {
|
||||||
"PATH=/bin:/usr/bin",
|
"PATH=/bin:/usr/bin",
|
||||||
@ -54,7 +54,7 @@ int SpawnInit()
|
|||||||
nullptr, false, compat, true);
|
nullptr, false, compat, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void KernelMainThread()
|
cold void KernelMainThread()
|
||||||
{
|
{
|
||||||
thisThread->SetPriority(Tasking::Critical);
|
thisThread->SetPriority(Tasking::Critical);
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ Exit:
|
|||||||
}
|
}
|
||||||
|
|
||||||
NewLock(ShutdownLock);
|
NewLock(ShutdownLock);
|
||||||
void __no_stack_protector KernelShutdownThread(bool Reboot)
|
cold void __no_stack_protector KernelShutdownThread(bool Reboot)
|
||||||
{
|
{
|
||||||
SmartLock(ShutdownLock);
|
SmartLock(ShutdownLock);
|
||||||
debug("KernelShutdownThread(%s)", Reboot ? "true" : "false");
|
debug("KernelShutdownThread(%s)", Reboot ? "true" : "false");
|
||||||
|
@ -234,7 +234,7 @@ namespace Tasking::Scheduler
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Custom::Yield()
|
hot void Custom::Yield()
|
||||||
{
|
{
|
||||||
/* This will trigger the IRQ16
|
/* This will trigger the IRQ16
|
||||||
instantly so we won't execute
|
instantly so we won't execute
|
||||||
@ -272,7 +272,7 @@ namespace Tasking::Scheduler
|
|||||||
|
|
||||||
/* --------------------------------------------------------------- */
|
/* --------------------------------------------------------------- */
|
||||||
|
|
||||||
nsa void Custom::OneShot(int TimeSlice)
|
hot nsa void Custom::OneShot(int TimeSlice)
|
||||||
{
|
{
|
||||||
if (TimeSlice == 0)
|
if (TimeSlice == 0)
|
||||||
TimeSlice = Tasking::TaskPriority::Normal;
|
TimeSlice = Tasking::TaskPriority::Normal;
|
||||||
@ -288,7 +288,7 @@ namespace Tasking::Scheduler
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa void Custom::UpdateUsage(TaskInfo *Info, TaskExecutionMode Mode, int Core)
|
hot nsa void Custom::UpdateUsage(TaskInfo *Info, TaskExecutionMode Mode, int Core)
|
||||||
{
|
{
|
||||||
UNUSED(Core);
|
UNUSED(Core);
|
||||||
uint64_t CurrentTime = TimeManager->GetCounter();
|
uint64_t CurrentTime = TimeManager->GetCounter();
|
||||||
@ -301,7 +301,7 @@ namespace Tasking::Scheduler
|
|||||||
Info->KernelTime += TimePassed;
|
Info->KernelTime += TimePassed;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF bool Custom::FindNewProcess(void *CPUDataPointer)
|
hot nsa NIF bool Custom::FindNewProcess(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
||||||
fnp_schedbg("%d processes", ProcessList.size());
|
fnp_schedbg("%d processes", ProcessList.size());
|
||||||
@ -348,7 +348,7 @@ namespace Tasking::Scheduler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF bool Custom::GetNextAvailableThread(void *CPUDataPointer)
|
hot nsa NIF bool Custom::GetNextAvailableThread(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
||||||
|
|
||||||
@ -397,7 +397,7 @@ namespace Tasking::Scheduler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF bool Custom::GetNextAvailableProcess(void *CPUDataPointer)
|
hot nsa NIF bool Custom::GetNextAvailableProcess(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
||||||
|
|
||||||
@ -445,7 +445,7 @@ namespace Tasking::Scheduler
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF bool Custom::SchedulerSearchProcessThread(void *CPUDataPointer)
|
hot nsa NIF bool Custom::SchedulerSearchProcessThread(void *CPUDataPointer)
|
||||||
{
|
{
|
||||||
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
CPUData *CurrentCPU = (CPUData *)CPUDataPointer;
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ namespace Tasking::Scheduler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF void Custom::Schedule(CPU::SchedulerFrame *Frame)
|
hot nsa NIF void Custom::Schedule(CPU::SchedulerFrame *Frame)
|
||||||
{
|
{
|
||||||
if (unlikely(StopScheduler))
|
if (unlikely(StopScheduler))
|
||||||
{
|
{
|
||||||
@ -721,7 +721,7 @@ namespace Tasking::Scheduler
|
|||||||
this->SchedulerTicks.store(size_t(TimeManager->GetCounter() - SchedTmpTicks));
|
this->SchedulerTicks.store(size_t(TimeManager->GetCounter() - SchedTmpTicks));
|
||||||
}
|
}
|
||||||
|
|
||||||
nsa NIF void Custom::OnInterruptReceived(CPU::SchedulerFrame *Frame)
|
hot nsa NIF void Custom::OnInterruptReceived(CPU::SchedulerFrame *Frame)
|
||||||
{
|
{
|
||||||
SmartCriticalSection(SchedulerLock);
|
SmartCriticalSection(SchedulerLock);
|
||||||
this->Schedule(Frame);
|
this->Schedule(Frame);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user