Questions about Kernel and Drivers?

I’d like to ask that what’s the difference between Kernel and Driver ??

I see you get no answer, so I start it with a laymans term explanation (according to my experience).
Others will correct me if I’m wrong.
I think of the kernel as the core of the whole system. A collection of software routines that interact with the user space programs, manages resources, and handles hardware via the drivers.
A driver is kind of a “plugin” for the kernel, which contains functions that make it possible for the kernel to handle that specific device.
Each device needs a driver.

Linux is kinda different to how MacOs and Windows do things - both use a kinda “abstracted” HAL (hardware abstraction layer) and a micro kernel, although Windows is pretty feckin’ obese for a micro kernel). MacOS’s is basically FreeBSD ontop of the Mach Kernel (and Microsoft based their NT kernel off Mach research too).

Due to Linux’s monolithic kernel, if you want “Driver X” to work - it needs to have “symbols” or suchlike (don’t ask me for more details than that) in the kernel at compile time…

If your driver isn’t supported in the kernel - you need to get the source code for the driver, plus the full kernel source code, and build your driver and kernel…

i.e. in MONOLITHIC kernels, there’s driver “hooks” in the kernel… if they’re not there, the driver won’t work…

It can be a REAL PITA at times… e.g. Google’s version of the Linux kernel for Android, eschews NFS support - so if you buy an SBC (single board computer) from a lazy vendor (e.g. Pine 64 people*), they just grab the Android kernel for that SoC (system on chip), and the android kernel doesn’t support NFS - so you can’t mount NFS shares on your NIX O/S running on an ARM board 'cause the SBC vendor is too lazy and just sponges off Google’s kernel efforts…

The thirty year old “Monolithic VS Micro kernels debate” was what helped inspire Linus Torvalds to develop the Linux kernel in the first place, he disagreed (sometimes publicly) with Andrew Tannebaum’s micro-kernel approach…

Note - I’m pretty sure most of the BIG UNIX vendors use/used monolithic kernels too - e.g. AIX and Solaris… I think the “OSF” (i.e. the body formed by Digital and HP and other UNIX vendors to compete with IBM and Sun Microsystems) foundation were pursuing micro / mach kernels for their RISC platforms. Note : HP-UX is pretty much “dead”, and Digital UNIX (AKA “Tru64”) is extinct, in the wild, damn shame too 'cause Tru64 on Alpha (64 bit in the 1990s!!!) was a thing of beauty. Did a fair amount of work on 64 bit IRIX on MIPS, but can’t remember what an IRIX kernel looked like, or DG-UX for that matter…

* better to use DietPi or Armbian than any work from the Pine64 people - IMHO…

2 Likes

Furthermore : I’m actually really surprised, the Linux kernel isn’t bigger - I mean vmlinuz for kernel 5.11 is just over 10 MB - which is positively tiny with Moore’s Law applied to storage cost… I’d a thunk it would be bigger anyway…

Back in the day ? Like my first foray into Linux - when I (and many other “dabblers”) wanted our kernel to fit onto a floppy disk (in most cases 1.44 MB), along with everything else needed for boot / root disk (I think they were separate weren’t they?) - we’d compile our kernel for ONLY what we needed, so - my kernel 1.2.13 would ONLY include drivers for Intel EtherExpress16 NIC (with IRQ and DMA “hard coded”), Soundblaster16 (with IRQ and DMA “hard coded”) and IDE / PATA storage - I vaguely remember it it, kicked off with something like “make zdisk” ? And then it (via the make file) would ask you a bunch of questions about what you wanted in your kernel… Can’t believe I used to enjoy doing that. These days? BUGGER OFF!

1 Like

:smiley:
Then you could set up your motherboard and cards with jumpers, and it wasn’t straightforward, which slot to use for a card…

These days we plug and p[l/r]ay. :laughing:

2 Likes

Me, an atheist, plugging in some new piece of hardware on one of my Linux boxes for the first time :

(replace “spooks” with “deities”)

And the wicked witch of the west (and remember kiddies, only bad witches are ugly) laughing, because my new piece of hardware DOES NOT HAVE KERNEL DRIVER SUPPORT!

Intel EtherExpressPro ISA cards had a DOS program you could run to set the IRQ and DMA in “eeprom” on the card itself, so you didn’t need tweezers or tiny fingers with long fingernails to set the IRQ and DMA address… Bliss!

And then we mostly did away with ANY of that rubbish with PCI… YAY PCI!

Anyone rember EISA? MCA? No? There’s a good reason for that - they were both HORRIBLE and those of us who used them suffer PTSD and we’ve erased those memories!

1 Like

So - amongst all that - you may not have picked out that I did actually answer your question, in a very roundabout way, but answered never-the-less…

A kernel and a driver are completely different things. I’m not going to explain the intricacies of the differences here, unless you’re going to pay me - there’s way better resources out there - probably even wikipedia…

RTFM :
Kernel

Driver (device)

On linux - your driver must have kernel support in your current kernel. This is not necessarily the case in Windows or Apple world. e.g. a 64 bit driver written for Windows 7, may, or may not, work on Windows 10’s “kernel”…

2 Likes

I remember using 3G Dongle when I lived in a caravan, for Internet dial up. Looking for drivers for Linux back then was like pulling the beak away from the hens teeth. Then I managed to find on a Forum a guy who had written from scratch code to go into the Kernel, he released the code, at least six or seven pages long if it was in a book. This was for Ubuntu 12.04 I was using Mint Maya the Mate version on a external 640GB drive. Used to take hard drive around with me to Internet cafes and the Library. This code took forever, as my poor machine only had 2GB of Ram, a dual core AMD processor. I don’t even think that USB 3 was even around then? Back then still relying on CDs to install Linux with. After half an hour the code installed rebooted and voila there it was, my 3G Dongle lit up blue, straight onto the Internet I went, then after a week I had run out of 3G, as looking at web pages used it up, those 3G people had you by the short and curly ones, so glad I moved to where I am now with Fibre Broadband.

3 Likes

Interesting :

on Windows 2016 (basically Win10 running as a server) kernel :

C:\Windows\System32 : 
"ntoskrnl.exe" : 7.24 MB

on MacOS 11.4 kernel :

/System/Library/Kernels : 

-rwxr-xr-x    1 root  wheel  17428264  1 Jan  2020 kernel
(that's 17 MB!)

on Ubuntu 20.04 on kernel 5.11 :

-rw------- 1 root root 10132256 Aug 27 15:48 /boot/vmlinuz-5.11.0-34-generic
(that's 10 MB) 

So - so much for “Mach” being a Micro Kernel architecture - that’s things MASSIVE (the MacOS kernel).

And - despite Linus’s kernel being a “monolith” (and allegedly bloated) - it aint that much bigger than Microsoft’s alleged “Micro Kernel Architecture” based on MACH kernel research, and implementing a HAL (hardware abstraction layer) - so drivers can’t mess up the kernel - HA HA HA that’s a sick joke! The BSOD is like 10,000,0000,0000 time more prevalent than a “kernel panic” in any NIX based O/S whether running a monolith or micro kernel!

I’d be interested to see how big the Minix kernel is in the firmware of EVERY single chip from Intel for the last couple of decades or so…

I might take a look a Minix in Virtual Box and check it out…

3 Likes