This section explains the overall architecture of LSE/OS:

System Overview
Context switcher (kernel)Schedule tasks: it relies on the 'timer' service if automatic context switch is wanted (non cooperative)
Tasks/drivers/servicesPrograms: Hardware drivers (PIC, timer, DMA, UART, Ethernet, etc), file systems, communication services, shells. All of these programs are tasks.
CoresrvThe Core Service: this is the main service (in kernel address space) that manages memory, GDT (tasks), IDT (Interrupt Tables)
LibareaThe memory management library that can be reused also for writing other programs (like file systems)
pgfltThe service that wraps page faults interrupts (SIGSEGV)
trapThe service that wraps various processor errors (SIGBUS)
strayThe service that wraps the stray interrupt (interrupts are not treated fast enough)
breakFor debugging kernel with GDB
NPXThe Floating Point Unit of the x86
MemoryThe physical memory of the system
GDTThe Global Descriptor Table that contains all the tasks of the system (x86)
IDTThe Interrupt Descriptor Table that contains all the interrupts (taskgates) of the system
InterruptsBoth NMI and External interrupts
NMINon Maskable Interrupts: interrupts that cannot be ignored (Division by Zero, page faults, etc)
PICProgrammable Interrupt Controller: The controller that allows external interrupts to wake up the processor
ioportsThe ISA ports that are used with the inb() and outb() assembly instructions
PeripheralsAll the hardware peripherals that could be accessed by ioports or memory and trigger external interrupts.

In lseos, a driver is a 'thread group' or a 'team' composed of many threads cooperating and sharing memory. Normally there are services (threads of class TCBC_SERVICE) for handling interrupts (not interruptible) and schedulable threads (threads of class TCBS_SCHED) for doing queued work.

When we launch the 'timer' driver, it creates the first process that create (implicitely) the process group:

Process View of the timer driver initting

Here, the timer drivers installs the timer interrupt handler (tick) and the system call entry point (timersrv):

Process View of the timer driver creating services
Note: because they are threads of the same address space, they need to spinlock critical sections (shared memory).

Generally the master thread (the 'first' thread) dies when it has finished to launch all the functional threads:

Process View of the timer driver exiting main thread
The driver is now ready to receive timer interrupts and syscalls. It can also perform some syscalls to other services.

In the following process view we see the sash process calling the delay(9) service, the timer interrupt handler "tick" receiving an hardware interrupt then directly sending a SIGALRM to the caller process.

Process View of the timer driver

In the following process view we see the same principle with the keyboard interrupts and Sash (Stand Alone Shell).

Process View of the sash driver

Process view of a minimal execution
In LSE/OS there aren't any drivers in the kernel address space except for some specific controllers like NPX (The floating point unit) that requires its registers to be saved and restored at each context switch.

The PIC (Programmable Interrupt Controller) does not need to be in the kernel address space any more! And not even the timer that drives the scheduler (see next sections).

Note that in the following view there is a specific task in kernel space called "Core". "Core" is the real kernel that manages memory and tasks through its dedicated services: coresrv0, coresrv1, ... (one for each cpu)

The only other services that need to be in the kernel address space are the fundamental NMI (Non Maskable Interrupts: "page faults", traps, breakpoints, etc), the idle threads (one for each cpu) and the main context switcher.

Process View of a minimal execution

Context Switching
LSE/OS relies on the x86 specific instructions for context switching. It especially uses task gates for achieving this purpose. Unlike classic interrupt handlers that could be interrupted by other interrupts, task gates are not interruptible at all. Beeing interrupted while in an interrupt handler is not absolutely necessary.

The context switcher (the kernel) gets the next task to run through the runq() system call, then call the assembly instruction lcall():


When a tick (HZ) occurs the task that is currently executing is preempted by the tick interrupt handler. The latter performs a kind of yield() (actually this is a variant system call reparent()) that gives hands back to context switcher:


Finally the kernel calls runq() again and elects the next task to run:


Detailed sequence of context switcher: TODO

Services and their roles in the system
LSE/OS distributions comes with a set of services. The following table show basic description of their functionalities and dependencies:

Services needed to make sash (Stand Alone Shell) working
NameDescriptionServiced byDependencyStatus
coresrvThe Core Service: Used for allocating memory and creating taskskernel-Mandatory
picThe Programmable Interrupt Controller driver: Used to enable/disable external interruptspic-Optional
timerThe 8253 Timer Controller driver: Used to generate the HZ tick interrupt but also for tasks to get current time and schedule eventstimernotify (if some tasks needs to register some timers)Optional

Here are the misceleanous hardware devices that are supported in LSE/OS:

Some Other Hardware related Services
NameDescriptionServiced byDependencyStatus
dmaThe 8237 DMA Controller driver: Used to transfer blocks of memorydma-Optional
ideThe IDE service: Used to access diskside-Optional
pciThe PCI service: Used to create drivers for PCI based devicespci-Optional
(See also network related services for supported ethernet drivers)

Other Services
NameDescriptionServiced byDependencyStatus
npxThe Floating Point Unit: needed if you want to do floated point mathskernel (because context switcher need to call it)-Optional
propThe Property Service (kind of a registry): A property is simply a key binded to a value. Tasks could store, update, fetch property values but can also attach and detach from properties.propnotifyOptional
notifyThe notification service: this service allow tasks to be notified with SIGNOTIFY when some another tasks die.notify-Optional
secThe Security Service: this service, when enabled, wraps ioacquire() and srvreg() calls (not finished)sec-Optional

LSE/OS has a standard API for manipulating file descriptor based operations. Here is a list of service that are compliant to it:

Some File Descriptor compatible services
NameDescriptionServiced byDependencyStatus
pipeThe Pipe Service: Used to create communication endpointspipenotifyOptional
vfsThe File System Super Service: Used as a frontend to File System Servicesvfsnotify, at least one file system, e.g. ramfsOptional
ramfsThe RAM File Systemramfsnotify, can work with or without vfsOptional
partThe Partition ServicepartideOptional
fatThe FAT (MSDOS) File SystemfatpartOptional
chicheThe Chiche File system: An example of filesystem using bpt (not yet finished)chichepartOptional
ttyThe Terminal Service: allows to create unix style ttys to PC console, serial ports but also ptys (Pseudo-Terminals)ttynotifyOptional

Here are the various drivers involved in the Network framework of LSE/OS:

Network Related Services
NameDescriptionServiced byDependencyStatus
rtl8139The Realtek 8139 Ethernet Driverrtl8138pci, inetOptional
inetThe Network Super Service: Used as frontend to network servicesinetnotifyOptional

The following services are involved in the SMP framework:

SMP Related Services
NameDescriptionServiced byDependencyStatus
smpThe SMP service: Used to transmit information to other processorssmp-Need to compile the kernel explicitely for n cpus.