Unified-OS
  • #️Unified OS
  • 🚀Getting Started
    • Installation
    • Booting
  • Architecture
    • Overview
    • ACPI
    • APIC
    • Constructors
    • ELF - Executables
    • Higher Kernel
    • IDT (Interrupts)
    • IPC
    • Kernel Objects and Watchers
    • Memory Management
    • PCI
    • PIT
    • Scheduling
    • Serial
    • Signals
    • SMP
    • Spinlocks
    • Syscalls
    • UFEI Bootloader and Setup
  • Drivers
    • SATA
    • Video
  • Other
    • FAT-32
    • Filesystem
    • Heap
    • Page
  • Processes
    • Libraries
      • MLibc
      • Libunified
    • OS-Based Processes
      • Daemon
      • Window Manager
  • Contributing
    • Contributing
Powered by GitBook
On this page
  1. Architecture

PIT

Programmable Interval Timer

This is a small chip on every system that runs at a fixed frequency of 1193182Hz. This also then sends interrupts (0x20) to the kernel telling it that it has ticked.

Since 1193182Hz is a lot of interrupts, we set a divisor on the chip telling it to only send a interrupt at a frequency we can choose

This is used to create sleep functions and control the scheduling of processes.

Timer Events

A addon to the PIT is the timer events. Effectively this works using a call-back event defined with

using TimerCallback = void(*)(void*);

and so on the event call-back a simple address of data can be passed in.

The method of organising the events is by giving an event a time till finished and all events after is have the difference. So the shortest is at the front of the list (Fast list).

pendingTicks++;
if (!(acquireTestLock(&sleepQueueLock))) {
	while (sleeping.get_length() &&
		pendingTicks-- >
			0) {
		TimerEvent* cnt = sleeping.get_front();

		assert(cnt);
		cnt->ticks--;

		if (cnt->ticks <= 0) {
			sleeping.get_front()->Dispatch();

			while (sleeping.get_length() && sleeping.get_front()->ticks <= 0) {
				sleeping.get_front()->Dispatch();
			}
		}
	}
	pendingTicks = 0;

	releaseLock(&sleepQueueLock);
}
PreviousPCINextScheduling

Last updated 1 year ago