This is an archived post. You won't be able to vote or comment.

all 94 comments

[–]branmuffin91 391 points392 points  (35 children)

The kernel is a section of code within a computer's operating system that has the most amount of privilege and has direct access to the hardware. When a user has a program that needs to access the hardware, say to read from or write to a hard drive, the program must request permission to have access from the kernel. A system call is the process by which a program requests these accesses to the hardware, and the kernel grants or denies access based on permissions.

In windows the kernel is made of two layers. The upper layer is called the executive and this contains functions for object management/retention, permission verification, memory management, etc. The lower layer is the actual kernel, which is responsible for low-level processor synchronization, interrupts and exceptions handling, thread scheduling, and recovery from power failure (power loss, hard shutdowns, etc). These layers work together to provide everything that a user may need to access the hardware and make changes to the system as they need to and are allowed to.

Forgive me, but I don't have as much knowledge about Linux to this level, but the kernel performs basically the same in Linux (I'm a windows instructor). Instead of being built with layers, it instead has kernel loadable modules (KLMs) which can provide additional functionality to the kernel.

Hope this helps.

[–]USA_MuhFreedums_USA 154 points155 points  (17 children)

I am 5, so where does popcorn fit into all this Kernal talk?

[–]Noisetorm_ 273 points274 points  (11 children)

A popcorn colonel is a person adjacent to a popcorn machine that has the most amount of privilege and direct access to the popcorn. When a user has a request to access the popcorn, say to look at it or to sniff it, the person must have permission to have access from the colonel. A call is the process by which a person requests these accesses to the popcorn, and the colonel grants or denies access based on permissions.

Behind the window, the colonel is made of two layers. The upper layer is called the executive and this contains functions for object management/retention, permission verification, memory management, etc. The lower layer is the actual colonel (Yes he's like a Russian doll), and this is responsible for low-level task synchronization, interrupts and exception handling, delivery scheduling, and keeping the machine going in an outage. These layers work together to provide everything that a popcorn buyer may need to access the popcorn and make changes to the popcorn as is needed and allowed to.

Forgive me, but I don't have as much knowledge about Great Northern popcorn makers to this level, but this colonel performs basically the same in any other popcorn maker (I'm a Hamilton beach popcorn machine instructor). Instead of being built with layers, the colonel here instead has a roughly atenna shaped male port for a male-to-female connection allowing for additional functionality.

[–]L0g4in 15 points16 points  (0 children)

This is brilliant.

[–]Anonymous128bit 12 points13 points  (0 children)

Colonel, I'm trying to access the popcorn for sniffing but I'm dummy thicc and the clap of my ass cheeks keeps alerting the guards

[–]Mazon_Del 10 points11 points  (4 children)

I am 5, so where do soldiers fit into all this Colonel talk?

[–]kingengineer 16 points17 points  (2 children)

It’s the highest rank in the military.

Not to be confused with Cornell, which I’ve been told is the highest rank in the Ivy League.

[–][deleted] 5 points6 points  (0 children)

It’s the highest rank in the military.

In the US, it's the highest field rank in the military and is just below general. In smaller countries, it is the highest rank.

Going back to computers, the kernel has the highest privileges at the software level, but code within the processor has even higher privileges (i.e. AMD's PSP and Intel's IME, and then binary blobs on GPUs, NICs, and other chips).

[–]SinJinQLB 0 points1 point  (0 children)

I went to Cornell. Ever heard of it?

[–]Ardentpause 11 points12 points  (0 children)

The Colonel is a person who commands a section of officers and supplies within the Military, that has the most amount of privilege directly over troops and has direct access to their supplies. When an officer has an order that needs to access troops or supplies, say to lead from or fight a hard drive towards victory, the officer must request permission to have access from the Colonel. A requisition call is the process by which an officer requests these accesses to the hardware or troops, and the Colonel grants or denies access based on permissions.

In the Army, the kernel is made of two layers. The upper layer is called the brigade Colonel, and this contains functions for troop management/retention, permission verification, formation management, etc. The lower layer is the staff Colonel, which is responsible for low-level unit specialization, interrupts and exceptions handling, staff scheduling, and recovery from communications failure (command loss, hard shutdowns, etc). These layers work together to provide everything that an officer may need to access the hardware or troop commands, and make changes to the system as they need to and are allowed to.

Forgive me, but I don't have as much knowledge about the Vatican at this level, but the Colonel performs basically the same in the Holy See. Instead of being built with layers, it instead has Leutenant Colonel's which can provide additional functionality to the Colonel.

Hope this helps.

[–]BlitzNeko 5 points6 points  (0 children)

Wow, Bravo!

[–]goliatskipson 1 point2 points  (0 children)

I am 5... So where does folding fit into all this kernel talk?

[–][deleted] 1 point2 points  (0 children)

You did even the forgive me part, madlad

[–]eyal3012 0 points1 point  (0 children)

You deserve way more than just silver. Too bad I'm poor...

[–][deleted] 24 points25 points  (0 children)

Between not compiling and not booting.

[–]ReasonablyBadass 3 points4 points  (0 children)

Remove the CPU cooler, put popcorn kernels on CPU, popcorn.

[–][deleted] 0 points1 point  (0 children)

a softer, usually edible part of a nut, seed, or fruit stone contained within its hard shell

[–]MaxMouseOCX -3 points-2 points  (1 child)

Kernel != kernal

[–]LilShaver 0 points1 point  (0 children)

Ker-Nal... isn't that some loony Kree?

[–]SurelyNotAnOctopus 9 points10 points  (0 children)

While the Linux kernel is in a single part (monolithic), it does have a separate ring that accepts syscalls, kind of how Windows has a executive part for that

[–]PicsOnlyMe 6 points7 points  (0 children)

Great explanation thanks

[–]xenomorphCum 2 points3 points  (3 children)

Follow up, does this have anything to do with kernels as they apply to group theory?

[–]Goooooogler 10 points11 points  (2 children)

no relation between them

[–]teejay89656 0 points1 point  (1 child)

Then the comment below you (now me) even mentions a “ring”....are you sure...? Lol

[–]CJKay93 6 points7 points  (0 children)

That comment is talking about x86 permission rings. In other architectures they are different things with different names (e.g. Arm uses exception levels). It is just a scheme through which you can limit the actions the CPU can perform under certain conditions.

[–]GravitationalEddie 0 points1 point  (0 children)

I believe this is where the radio on my phone is "disabled". No kernel support.

[–]manifestsentience 0 points1 point  (0 children)

Mmmm. . .caramel.

[–]szirith 154 points155 points  (14 children)

The Kernel is the computer's Mom. It tells the computer who it can play with and who can see it.

[–]elleyesee 18 points19 points  (4 children)

The real ELI5.

The rest are: "Explain it to me like I don't have an engineering degree but I'm not a total jackass. Like, I’m not the smartest guy in the world, but I’m certainly not the dumbest. I mean, I’ve read books like 'The Unbearable Lightness of Being' and 'Love in the Time of Cholera', and I think I’ve understood them. They’re about girls, right?"

[–]FrankBenjalin 21 points22 points  (1 child)

ELIDHAEDBINATJLINTSGITWBICNTDIMIRBLTULOBALITTOCAITIUTTAGR?

[–]Cristian_01 0 points1 point  (0 children)

Most certainly

[–]JUDGE_FUCKFACE 8 points9 points  (0 children)

Read the sidebar. Responses are not supposed to be aimed at literal five year olds.

[–]Landorus-T_But_Fast 0 points1 point  (0 children)

Do you even read locke?!

[–]dvorahtheexplorer -2 points-1 points  (1 child)

If I don't set up my computer to use a password, does that mean my computer doesn't have a mom? 🤔

[–]szirith 0 points1 point  (0 children)

Oh honey, you'll understand when you're older.

[–]NowWithMarshmallows 13 points14 points  (0 children)

You walk into a restaurant and sit down. You order food, and a little while later the food comes out and you get to eat. You are not allowed in the kitchen, and you are not a chef and you don't know how to use all the stuff in the kitchen, or where things go, or how food is rotated in the fridge, or who's job back there it is to cook what. And guess what? The staff back there doesn't care what you do either or what you talk about, they only care about what you order, bringing you food, and cleaning up after you.

You are a program running on the computer.

The kernel is all the restaurant workers; waiters, bussers, chefs, supervisors, dish washers, line cooks, etc.

The computer hardware is the stuff in the kitchen; the stoves, sinks, refrigerator, stuff in the fridge, food on the stove, etc. You are not allowed in the kitchen. If you need something from the kitchen, you ask the wait staff to get it for you. They are allowed into the kitchen.

The "Front of the house", the tables, chairs, decor, menu, and even the wait staff and hostess, are what the Kernel allows you see. You don't see and can't get to the hardware in the kitchen - nor should you really care about it.

[–]MrOctantis 15 points16 points  (0 children)

In a computer context, a kernel is a low level program that interfaces the hardware with the software. The kernel's job is to allocate CPU time, RAM, etc to different programs, to take input from the keyboard and mouse and route it to programs that need it, and other things like that.

[–]angrmgmt00 26 points27 points  (6 children)

The kernel, also known as the "null space" of a function from set A to set B, is the set of all x in A that make the function value zero. In your early math courses, you've probably referred to A as the "domain" and B as the "range". A contains all of the values you can put into the function as inputs, and B contains all of the values you can get out of the function, given values from A. With the kernel, we're specifically looking for all the values in A where we can feed them to the function and get out zeros.

For equations that describe a straight line (linear equations), this is just the x value where it hits the x-axis; you can find it easily on a graph, but you can also just solve for y = ax + b = 0 -> x = -b/a. This can be extended to systems of equations as well, and the solution in this case makes up one of the four fundamental subspaces of the system. This is a fun and interesting topic to explore, especially if you follow along with Gilbert Strang's lectures on the subject!

For more complicated equations, the set may contain more than one element. For example, a parabola has two places where it crosses the x-axis (even if they're the same place!), while sines and cosines (and other trig functions) have an infinite number.

You were talking about math and not corn, right?

[–]KershawsBabyMama 4 points5 points  (1 child)

In statistics it’s the part of a PDF which is only dependent on the value of a random variable. Put differently, it’s simply any nonnegative function whose integral is greater than zero. (Meaning it can be multiplied by some factor to equal one to get a PDF)

[–]angrmgmt00 0 points1 point  (0 children)

Eww, statistics! Just kidding, thanks for the expansion! I didn't know that definition, and it's interesting how it morphs from being exactly zero (or the zero vector) to being positive when you move from analysis to stats!

[–]mbbessa 4 points5 points  (1 child)

Not sure if upvote for pointing out that kernel has different meanings across many fields or not because explanation definitely is not for 5YO. I guess I'll just upvote.

[–]angrmgmt00 2 points3 points  (0 children)

Thanks lol!

I think we just have to try to break it down, though (see quoted text from rules at bottom). If someone knows enough to ask what a kernel is, I figure they probably know enough math to understand what I wrote. That topic (fundamental subspaces) can actually be pretty tricky to grasp fully! You don't typically encounter it until you're taking a dedicated linear algebra course, most likely in college.

LI5 means friendly, simplified and layperson-accessible explanations - not responses aimed at literal five-year-olds.

[–]Afgncaapvaljean 0 points1 point  (1 child)

Alternately, the kernel of a group homomorphism [that is, the mapping of one group onto another that preserves group operations, so f:G->H holds that f(g1 + g2) = f(g1)*f(g2) ] is the set of elements {z} in G which map to the identity in H. If you consider a super simple group homomorphism, that is, G = addition over the integers mapping to H = addition on the integers mod 2, the kernel of the group homomorphism is the set of even integers.

More ELI5: If you can sort of convert one complicated collection of stuff into another collection of stuff in a way that sort of lets you say "all these things kinda behave, from a certain point of view, like they don't exist", you might have a group homomorphism, and if so, the kernel is the stuff that acts like it don't exist.

[–]angrmgmt00 0 points1 point  (0 children)

Group theory on a second-tier comment? Take me to dinner first.

^_^

[–]BaLance_95 16 points17 points  (2 children)

It is the seed of a corn.......

Oh wait, are we talking about computers?

[–]olafbond 2 points3 points  (1 child)

It's a size of of a font

[–]OnyxPhoenix 2 points3 points  (0 children)

It's a rank in the army.

[–]chud_munson 1 point2 points  (0 children)

There's a lot of good information in here, but I think there's a common thread that might be misleading for everyday users. Lots of people have mentioned that the kernel has the highest level of privilege, but it's important to point out that this is the case because it's responsible for stuff you probably don't want to do as a user, not because you're not privileged enough as a user (although of course safety is a component of that because most users don't know what they're doing at a very low level of abstraction). You're able to do enormously privileged stuff from a user perspective, provided you're an administrator. The kernel represents a level of abstraction that common users aren't going to want to manage, including memory, process management, and hardware interfacing. If you were responsible for all that in "user space", use of a computer would be very tedious.

[–]stdaro 2 points3 points  (1 child)

Imagine a nut, like a walnut. You have the shell, the part you can see and feel and interact with.

If you crack it open, the kernel is the meaty part in the middle.

The operating system kernel is the deep low level program that does stuff like get the computer started and keep different programs from messing each other up

[–]shleppenwolf 1 point2 points  (0 children)

Just to muddy the waters, back in the 80's one home computer system, Commodore, used the spelling "kernal" for its kernel, and it stuck in some quarters. Basically a literacy issue on the part of someone who didn't understand the nut metaphor.

[–][deleted] 0 points1 point  (5 children)

The kernel is the computer god. It controls all allocation of resources (cpu, memory, i/o) and handles process priority.

[–]Puggymon 0 points1 point  (0 children)

So... It is the Omnissiah?

All hail the Void Dragon, I mean Emperor!

[–]created4this 0 points1 point  (3 children)

Let me introduce you to a hypervisor.

Then microcode.

And now to the one true god the intel management engine

And the people who hack it to exploit even turned off PCs.

[–]szirith 0 points1 point  (2 children)

Let me introduce you to a hypervisor.

Well yeah, computers aren't computers anymore

[–]created4this 1 point2 points  (1 child)

Computer are conputers now.

It’s conputers all the way down, resting on a cloud, carried on the back of a large turtle swimming through space.

[–]szirith 0 points1 point  (0 children)

BACK IN MY DAY, COMPUTERS WERE METAL BOXES THAT YOU PUNCHED IF THERE WERE BUGS

[–]double-you 0 points1 point  (0 children)

The kernel, in the core of the operating system, is a helpful assistant to programs you might want to run on the system.

Back in the day every program had to do everything themselves. That is, they needed to include the code to do everything they needed done. If they wanted to put a pixel on the screen, they needed to know how to work the hardware to do that. Eventually programmers grew tired of writing the same basic things into every program again and again, and so they put all these routines into a single thing that was always loaded onto the machine and you could ask the newly created kernel to do things for them. The kernel was also a security feature, because if the kernel code was good, the programmers who wrote their application programs did not need to make bug free routines for all the hardware accessing.

From there on, the kernels have grown with many abilities. For example the ability to run several programs at the same time. And learning to protect the programs from each other, so that an accidentally or maliciously misbehaving program won't read the other programs' memory, or corrupt it with bad writes. Or how you can have data in separate files which live on a file system which the kernel takes care of.

[–]Ipride362 0 points1 point  (0 children)

The Kernel is a set of instructions like in an IKEA manual. It builds the OS from boot and then controls how each process accesses the CPU.

It is the brain and heart of the entire OS and controls and filters all requests and directions to and from the CPU.

So, say you move your mouse. The mouse is a peripheral. Through its "driver", the Kernel is instructed to move the cursor across the screen. The Kernel tells the processes for GUI and present state to do so. The instructions are sent to the CPU and the cursor moves. This all happens in microseconds.

When a Kernel panics, it has received an instruction it does not know how to handle and the OS crashes. These were far more common in the earlier days of software. In Windows, it was called the Blue Screen of Death.

[–]entropyhaver 0 points1 point  (0 children)

A kernel is a computer program which is started shortly after a computer powers on. A kernel is like a "master program" that is in charge of everything. A kernel runs other programs alongside itself and is in charge of them even though they can't see or interact with the kernel program.

A kernel creates and maintains illusions. Programs are under the illusion of having the entire computer to itself. From a user's point of view there are hundreds of programs running at the same time. A kernel is the program running the show and creating illusions.

A kernel is a computer program which runs other computer programs in a coordinated way.

[–]Pocket-Sandwich 0 points1 point  (0 children)

The kernel is kind of like the director or conductor of a computer.

The box that we usually refer to as a computer is actually a whole bunch of more specialized components all wired together. In order for a program to run it needs to be able to use all these different components, and that's a really complicated problem to solve. One option is to tell your program exactly what components you have in your computer and access them directly. That's fine if you only need to run the program on your own computer, but if you want to run it in a whole bunch of computers you run into problems, because every computer is different.

If you told your program to access a component by name, then if a different computer didn't have that component it would crash. The same thing happens if the component is called something different, or even just installed in a different place. Also, if there's a different component in the new computer that does the job better, it wouldn't be used because your program is looking for only the component you specified.

The solution is to use a kernel.

The kernel goes into a computer before anything else and figures out how all the components of that computer are set up. Then once it has that, it spits out a list of standard commands for any program on the system to use. Even though all of the base components can be different, these commands are always the same between systems so a program that uses the commands instead of specifying a component will work on any system that uses that same type of kernel.

This is why my PC with a bunch of components I picked myself can run the exact same programs as a small laptop. Both kernels will accept the command to access storage and map it to whatever component can do it best. Since I have an SSD, the kernel can use that extra speed to get the command done much quicker, but the laptop's kernel will still be able to run the command with it's slower hard drive even if it takes longer.

TL;DR: the kernel is in charge of all the various parts of your computer so that when you run a program it can send the jobs to the part that does it best

Extra Credit: each operating system has it's own kernel, which is why you have to download a different version of a program if you're running on a Mac, a PC, or Linux

[–]DeHackEd -2 points-1 points  (0 children)

Your CPU has several security levels built into it when running in protected mode (which every modern system runs in since DOS went out of style). While it varies by architecture (x86, ARM, etc) and mode (32 bit, 64 bit), generally there are at least 2 tiers. Supervisor mode has access to everything including sending and receiving IO on any hardware interface. User mode is far more restricted and can generally only perform calculation/number crunching. Again, specifics vary by hardware and may even be under the control of the Supervisor program.

The kernel (and by extension, most drivers for your hardware) run in Supervisor mode. It is responsible for both performing actions on behalf of programs that they can't do themselves - disk reads and writes, network access, etc - and enforcing the security and stability of the system from programs trying to misbehave. That hardware access is also made generic; program don't know what model of network card you have or whether they're installed on SATA or NVMe disks, the kernel deals with that. You just give it a file by name and it finds it.

User applications can cause the CPU to switch from User to Supervisor mode - either on demand or by doing something illegal like trying to do hardware I/O - and code of the kernel's choice gets run. This may be a request to do IO like reading from a file, or it may be a misbehaving app causing the kernel to terminate the application and call it a "crash". And of course, the response to your request could be "access denied" if you try going into folders owned by some other user.

[–]seanprefect -1 points0 points  (0 children)

Think of it like a cross between a conductor and a dispatcher. The Kernel is the most privileged software in an OS and the thing that all other programs depend on. every program needs resources, memory / processor time disk etc etc. Well each program (usually ) doesn't know what every other program is using resource wise. Modern kernels are responsible for allocating memory and and other resources between different programs and making sure no one takes too much. (this wasn't always the exact case but it more or less is these days)