[cs631apue] kernel vs process

Kashi Vishwanath Bondugula kbondugu at stevens.edu
Tue Dec 6 13:33:44 EST 2022


Hi Professor

I have gone through what you have said and the O'Reilly material, I have one small doubt for single processor systems where only one process can run at a time, as you have mentioned kernel once it boots up it doesn't really do anything but it has to run components like scheduling processes, handling interrupts etc. for which the kernel has to be running on the CPU right?
How are interrupts handled?? Maybe this is going a bit out of context, but I am trying to understand at a given moment on the CPU how can both kernel and process under execution are running because the kernel must shift the process to user mode and kernel mode based on the code right?? so, there must be some code / process that is keeping track of which code is getting executed and in which mode are we supposed to execute it which needs CPU cycles to make all of that, considering single processor how can this happen, maybe I am missing something. 😅

And what do you exactly mean by kernel runs on between user processes??

Just thinking top of mind do you mean CPU as a virtual resource provided to the process by kernel where the code / instructions of the process are just dumped in between some sort of kernel cycles or kernel code execution maybe?? And the kernel is the one who is running on the physical CPU

Get Outlook for Android<https://aka.ms/AAb9ysg>
________________________________
From: cs631apue-bounces at lists.stevens.edu <cs631apue-bounces at lists.stevens.edu> on behalf of Jan Schaumann <jschauma at stevens.edu>
Sent: Tuesday, December 6, 2022 12:08:05 PM
To: cs631apue at lists.stevens.edu <cs631apue at lists.stevens.edu>
Subject: [cs631apue] kernel vs process

Hello,

On my way home last night I was thinking about how to
better explain the difference between when a process
runs on the CPU versus what the kernel does.  One way
to get better clarity here is to understand that the
kernel itself is not process like any others:

When the kernel boots, it is running on the CPU in
kernel space (ring 0).  It bootstraps the system, and
as part of initiates the scheduler.  It then doesn't
really do much of anything until a suitable interrupt
causes kernel code to be executed (e.g., hardware
interrupt for I/O, preemption by the scheduler).

When a user process executes (e.g., explicit creation
of init(8) by the kernel or any of its child
processes), that will run in user space (ring 3).
When it makes system calls, the CPU switches to kernel
mode and the syscall completes.  At this point, the
kernel "has the CPU", so to speak. The user process
may be preempted (i.e., by an interrupt as above) or
terminate, and control returns to the kernel.

That is, rather than thinking of the kernel as a
process that runs and needs to be preempted to let a
user process run, think of the kernel as the larger
program that runs _in between user processes_, as the
kernel simply isn't a process itself and doesn't
behave like one.

Perhaps this chapter of O'Reilly's "Understanding the
Linux Kernel" can also help you clarify your
understanding:
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.oreilly.com%2Flibrary%2Fview%2Funderstanding-the-linux%2F0596002130%2Fch01s06.html&amp;data=05%7C01%7Ckbondugu%40stevens.edu%7Cbce2acf998e04d236ee608dad7ac7e16%7C8d1a69ec03b54345ae21dad112f5fb4f%7C0%7C0%7C638059433114408759%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;sdata=0qyWZZcTqbnt16p1YBVJPadqa45%2FTBxJOHiC23Dfu%2BM%3D&amp;reserved=0

Hope that helps,
-Jan
_______________________________________________
cs631apue mailing list
cs631apue at lists.stevens.edu
https://lists.stevens.edu/mailman/listinfo/cs631apue
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.stevens.edu/pipermail/cs631apue/attachments/20221206/2128fc83/attachment.html>


More information about the cs631apue mailing list