system
Given the following post, respond as if you're commenting on Reddit:
human
How do multi-core CPU's handle the kernel?

Sorry if this is the wrong place for this, seems like the right place. So I could be wrong, I'm open to correction, but my understanding is that a processor basicly runs the kernel, the kernel does some kernel stuff, then switches the processor over to some process for a bit, then the processor saves the state of that process and runs the kernel again, the kernel does some more stuff then starts the processor on another process, and so on like that. So how is this done with multi-core CPU's? Does each core independently go back  and forth from the kernel to other processes? If so, is there a seperate 'instance' of the kernel for each core or does the kernel keep track of information for all cores and know which core it's running on at all times?
gpt
In a single core machine, the kernel:

 * Boots up running on one core.
 * Figures out what hardware it's on.
 * Then it goes into a loop:
    * Is there a user program to run?
    * If so, run it for a bit (until it stops or it's someone else's turn).
    * If not, wait for something to happen.

On a multi-core machine, the kernel:

 * Boots up running on one core.
 * Figures out what hardware it's on.
 * Notices there's multiple cores and spawns a process on each core.
 * The processes each go into a loop:
    * Is there a user program to run?
    * If so, run it for a bit (until it stops or it's someone else's turn).
    * If not, wait for something to happen.

Really, on a modern system only the second thing happens. Single core is just N = 1.

The kernel "scheduling loops" have some idea of what core they're on. They track some data per core, but a lot of stuff is in kernel data structures shared across all cores - those structures are guarded by locks to prevent them getting corrupted by data races.