Commit Graph

28 Commits

Author SHA1 Message Date
539afb329a Kernel: All processors use LAPIC timer when running with APIC
This makes scheduler preemption much cleaner as bsb does not have to
send smp messages to notify other processes about timer interrupt.

Also PIT percision is now "full" 0.8 us instead of 1 ms that I was using
before.
2024-07-23 02:28:52 +03:00
f8261c60c0 Kernel: Rewrite the whole scheduler and re-architecture SMP handling
Change Semaphore -> ThreadBlocker
  This was not a semaphore, I just named it one because I didn't know
  what semaphore was. I have meant to change this sooner, but it was in
  no way urgent :D

Implement SMP events. Processors can now be sent SMP events through
IPIs. SMP events can be sent either to a single processor or broadcasted
to every processor.

PageTable::{map_page,map_range,unmap_page,unmap_range}() now send SMP
event to invalidate TLB caches for the changed pages.

Scheduler no longer uses a global run queue. Each processor has its own
scheduler that keeps track of the load on the processor. Once every
second schedulers do load balancing. Schedulers have no access to other
processors' schedulers, they just see approximate loads. If scheduler
decides that it has too much load, it will send a thread to another
processor through a SMP event.

Schedulers are currently run using the timer interrupt on BSB. This
should be not the case, and each processor should use its LAPIC timer
for interrupts. There is no reason to broadcast SMP event to all
processors when BSB gets timer interrupt.

Old scheduler only achieved 20% idle load on qemu. That was probably a
very inefficient implementation. This new scheduler seems to average
around 1% idle load. This is much closer to what I would expect. On my
own laptop idle load seems to be only around 0.5% on each processor.
2024-07-22 00:33:50 +03:00
8fe798de6d Kernel: Make PIT counter atomic with spinlock 2024-07-21 18:56:41 +03:00
318ce5dec8 All: Fix a lot of compiler warnings from header files
While reworking build system, header files started to report warnings.
2024-06-18 23:02:10 +03:00
87d52e5ebe Kernel: Fix timer early wake message
When printing early return message, current time was read twice. This
could lead to early return check failing, but when printing and reading
the time again subtraction overflow would happen.
2024-05-28 16:04:18 +03:00
34b10f61ce Kernel: Make PIT reserve its IRQ
PIT did not reserve IRQ leading to kernel panic if it was being
initialized.
2024-04-18 13:34:28 +03:00
e0011d22f2 Kernel: Move ACPI to its own directory and namespace 2024-04-04 15:00:13 +03:00
682de62c57 Kernel: Replace HPET CriticalScope with SpinLock 2024-02-29 19:15:33 +02:00
59abb5d344 Kernel: Make HPET read_main_counter() atomic with 32 bit main counter 2024-02-23 13:42:04 +02:00
7a4ec7f7a3 Kernel: Use static_cast instead of c-style cast in HPET 2024-02-22 14:44:39 +02:00
00662bad46 Kernel: Rewrite HPET code
Now the set timer frequency actually works... :D
2024-02-13 17:59:48 +02:00
dfe5a2d665 All: Cleanup all files
Add newline to end of files and remove whitespace from end of lines
2024-01-24 15:53:38 +02:00
c6130f33d7 Kernel: Implement MSI, MSI-X and interrupt reservation 2024-01-13 18:21:21 +02:00
888e44ce0b Kernel: Allow getting ACPI headers with same signature 2023-10-13 11:24:21 +03:00
75fdf4c3c6 Kernel: Add Timer::ns_since_boot() 2023-10-12 21:16:39 +03:00
27eb5af6f0 Kernel: Rework interrupt mechanism
All interruptrable classes now inherit from Interruptable which
has methdo handle_irq which is called on a interrupt.
2023-10-05 18:53:45 +03:00
Bananymous
921d95d18f All: Clear lines with only whitspace in them 2023-09-10 00:31:42 +03:00
Bananymous
5d0a6e7b08 Kernel: HPET is now used in legacy mode when PIC is forced 2023-08-10 22:01:30 +03:00
Bananymous
ebe0adb3b5 Kernel: HPET doesn't use the legacy mapping anymore 2023-08-10 21:08:32 +03:00
Bananymous
55ef793a74 Kernel: Validate HPET tick period 2023-08-09 09:50:38 +03:00
Bananymous
96c0ad0d3d Kernel: Remove get_unix_timestamp from SystemTimer
Kernel now uses the percise real_time() and time_since_boot()
2023-08-09 08:57:50 +03:00
Bananymous
3df97c36e6 Kerne: SystemTimer can now output the current real time 2023-08-04 16:06:47 +03:00
Bananymous
c732297623 Kernel: Rename TimerHandler to SystemTimer
I changed SystemTimer to only handle the "best" supported timer
it can initialize.
2023-08-04 16:06:47 +03:00
Bananymous
ca5a097ef5 Kernel: Add function to retrieve boot time as timespec 2023-08-04 16:06:47 +03:00
Bananymous
1fa7a1cac4 Kernel: Add basic HPET support to replace PIT if exists
This works same way as the PIT implementation; calls Scheduler every
milli second.
2023-08-04 15:22:51 +03:00
Bananymous
ea4a70c3b3 Kernel: Move sleep() implementation to TimerHandler 2023-08-04 15:15:00 +03:00
Bananymous
7eb2c140fe Kernel: Move RTC to Timer directory
PIT ms counter seems to be off by multiple seconds/minute. I will
be probably changing to HPET for system time
2023-08-04 11:12:16 +03:00
Bananymous
659adb89a6 Kernel: Start work on abstracting Timers 2023-08-04 10:29:42 +03:00