completely redesign how user mode memory is allocated, fix a few smp and scheduler bugs, terminating a process now terminates the process, telemetry, optimize text editor, new font, new color scheme
This commit is contained in:
1 parent
27b31f62b6
commit
325149006c
45 files changed
+2091
-760
No files matched your search
@@ -95,6 +95,7 @@ static void cmd_help() {
|
||||
print("Available commands:\n"
|
||||
" help - Show this list\n"
|
||||
" mem - Show memory usage\n"
|
||||
" stats - Show scheduler/CPU/PMM telemetry\n"
|
||||
" ps - List running process IDs\n"
|
||||
" dir [path] - List directory contents\n"
|
||||
" cd <path> - Change directory\n"
|
||||
@@ -110,6 +111,96 @@ static void printSizeKiB(uint64_t bytes) {
|
||||
print(" KiB");
|
||||
}
|
||||
|
||||
|
||||
static void printPagesKiB(uint64_t pages) {
|
||||
printUInt64(pages * 4u);
|
||||
print(" KiB");
|
||||
}
|
||||
|
||||
static void printCpuFlags(uint32_t flags) {
|
||||
if (flags & SYS_CPU_FLAG_BSP) print("bsp ");
|
||||
if (flags & SYS_CPU_FLAG_ONLINE) print("online ");
|
||||
if (flags & SYS_CPU_FLAG_PARKED) print("parked ");
|
||||
if (flags & SYS_CPU_FLAG_PRIMARY) print("primary ");
|
||||
if (flags & SYS_CPU_FLAG_STARTED) print("started ");
|
||||
if (flags & SYS_CPU_FLAG_PRESENT) print("present ");
|
||||
}
|
||||
|
||||
static void cmd_stats(void) {
|
||||
SYS_SCHEDULER_STATS sched;
|
||||
SYS_PMM_STATS pmm;
|
||||
SYS_CPU_STATS cpu;
|
||||
uint32_t status;
|
||||
|
||||
status = SysQueryKernelStats(SYS_KERNEL_STATS_SCHEDULER, &sched, sizeof(sched), NULL);
|
||||
if (status != 0) {
|
||||
print("stats: scheduler query failed: ");
|
||||
printUInt(status);
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
status = SysQueryKernelStats(SYS_KERNEL_STATS_PMM, &pmm, sizeof(pmm), NULL);
|
||||
if (status != 0) {
|
||||
print("stats: pmm query failed: ");
|
||||
printUInt(status);
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
status = SysQueryKernelStats(SYS_KERNEL_STATS_CPU, &cpu, sizeof(cpu), NULL);
|
||||
if (status != 0) {
|
||||
print("stats: cpu query failed: ");
|
||||
printUInt(status);
|
||||
print("\n");
|
||||
return;
|
||||
}
|
||||
|
||||
print("Scheduler:\n");
|
||||
print(" ticks: "); printUInt64(sched.Ticks); print("\n");
|
||||
print(" context switches: "); printUInt64(sched.ContextSwitches); print("\n");
|
||||
print(" quantum expires: "); printUInt64(sched.QuantumExpirations); print("\n");
|
||||
print(" priority preempts: "); printUInt64(sched.PriorityPreemptions); print("\n");
|
||||
print(" idle selections: "); printUInt64(sched.IdleSelections); print("\n");
|
||||
print(" keep-current: "); printUInt64(sched.KeepCurrentDecisions); print("\n");
|
||||
print(" demotions: "); printUInt64(sched.Demotions); print("\n");
|
||||
print(" aging promotions: "); printUInt64(sched.AgingPromotions); print("\n");
|
||||
print(" voluntary blocks: "); printUInt64(sched.VoluntaryBlocks); print("\n");
|
||||
print(" SMT deferrals: "); printUInt64(sched.SmtSiblingDeferrals); print("\n");
|
||||
print(" SMT primary pokes: "); printUInt64(sched.SmtPrimaryPokes); print("\n");
|
||||
|
||||
print("CPUs:\n");
|
||||
uint32_t n = cpu.CpuCount;
|
||||
if (n > SYS_KERNEL_STATS_MAX_CPUS)
|
||||
n = SYS_KERNEL_STATS_MAX_CPUS;
|
||||
for (uint32_t i = 0; i < n; i++) {
|
||||
SYS_CPU_STAT* c = &cpu.Cpu[i];
|
||||
print(" cpu"); printUInt(c->CpuIndex);
|
||||
print(" lapic="); printUInt(c->LapicId);
|
||||
print(" tid="); printUInt(c->CurrentTid);
|
||||
print(" ticks="); printUInt64(c->SchedulerTicks);
|
||||
print(" switches="); printUInt64(c->ContextSwitches);
|
||||
print(" flags="); printCpuFlags(c->Flags);
|
||||
print("\n");
|
||||
}
|
||||
|
||||
print("Physical memory:\n");
|
||||
print(" total: "); printPagesKiB(pmm.TotalFrames); print(" (frames="); printUInt64(pmm.TotalFrames); print(")\n");
|
||||
print(" used: "); printPagesKiB(pmm.UsedFrames); print(" (frames="); printUInt64(pmm.UsedFrames); print(")\n");
|
||||
print(" free: "); printPagesKiB(pmm.FreeFrames); print(" (frames="); printUInt64(pmm.FreeFrames); print(")\n");
|
||||
print(" largest free run: "); printPagesKiB(pmm.LargestFreeRun); print(" (frames="); printUInt64(pmm.LargestFreeRun); print(")\n");
|
||||
print(" free runs: "); printUInt64(pmm.FreeRunCount); print("\n");
|
||||
print(" run histogram:\n");
|
||||
print(" 1: "); printUInt64(pmm.FreeRunHistogram[0]); print("\n");
|
||||
print(" 2-3: "); printUInt64(pmm.FreeRunHistogram[1]); print("\n");
|
||||
print(" 4-7: "); printUInt64(pmm.FreeRunHistogram[2]); print("\n");
|
||||
print(" 8-15: "); printUInt64(pmm.FreeRunHistogram[3]); print("\n");
|
||||
print(" 16-63: "); printUInt64(pmm.FreeRunHistogram[4]); print("\n");
|
||||
print(" 64-255: "); printUInt64(pmm.FreeRunHistogram[5]); print("\n");
|
||||
print(" 256-1023: "); printUInt64(pmm.FreeRunHistogram[6]); print("\n");
|
||||
print(" 1024+: "); printUInt64(pmm.FreeRunHistogram[7]); print("\n");
|
||||
}
|
||||
|
||||
static void cmd_mem(void) {
|
||||
SYS_MEMORY_STATUS st;
|
||||
if (SysGetMemoryStatus(&st) != 0) {
|
||||
@@ -240,7 +331,7 @@ static int runCommand(const char* cmd) {
|
||||
if (!cmd || *cmd == '\0') return 0;
|
||||
if (strcmp(cmd, "exit") == 0) return 1;
|
||||
if (strcmp(cmd, "help") == 0) { cmd_help(); return 0; }
|
||||
if (strcmp(cmd, "clear") == 0) { SysScreenClear(0); return 0; }
|
||||
if (strcmp(cmd, "clear") == 0) { SysScreenClear(0x012456); return 0; }
|
||||
if (strncmp(cmd, "crash", 5) == 0) {
|
||||
// Check the sub-option trailing "crash " (offset 6)
|
||||
if (strcmp(cmd + 6, "void") == 0) {
|
||||
@@ -280,6 +371,7 @@ static int runCommand(const char* cmd) {
|
||||
}
|
||||
}
|
||||
if (strcmp(cmd, "mem") == 0) { cmd_mem(); return 0; }
|
||||
if (strcmp(cmd, "stats") == 0 || strcmp(cmd, "telemetry") == 0) { cmd_stats(); return 0; }
|
||||
if (strcmp(cmd, "ps") == 0) { cmd_ps(); return 0; }
|
||||
if (strcmp(cmd, "dir") == 0) { cmd_dir("."); return 0; }
|
||||
if (strncmp(cmd, "dir ", 4) == 0) { cmd_dir(cmd + 4); return 0; }
|
||||
|
||||
Reference in new issue
Block a user