Is it possible to include allegro in a Kernel made in C?

1

Study for some time the construction of Operating Systems with bootloader in Assembly and kernel in C, and recently I started to study allegro. Theoretically it is possible to include allegro to the kernel made in C, but I want to know in practice ... is it possible?

    
asked by anonymous 10.09.2015 / 02:28

1 answer

1

Technically it is. Any library or application can be deployed or ported into the kernel.

But what's the advantage? If the Allegro API was inside the kernel and the application that uses it outside, every call to Allegro would involve a syscall and a context switch, which is "expensive" (takes much longer than a normal function call).

Performance may be much better with Allegro outside the kernel, in the same memory space as the game or application. Unless you play the game inside the kernel as well, it would actually be a regression to MS-DOS time where all code has direct access to hardware all the time.

And as you may know, any bug in the code that is on the inside of the kernel causes the computer to crash. Certainly Allegro has bugs ...

The kernel should only be code that needs full access to the hardware, and must have controlled access, either per user or per set of permissions.

It also ends up getting a lot of code in the kernel which, for pragmatic reasons, works faster if it's there. This is the case with most device drivers, file systems, etc. Even so, there are many drivers that work in user mode, and there are cases even where user-mode is faster (for example if a single application makes use of a network card, the set gets faster if the application itself contains the driver of that plate).

    
10.09.2015 / 03:39