<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
Hi Professor</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
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?</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
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. ðŸ˜…</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
And what do you exactly mean by kernel runs on between user processes??</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
<br>
</div>
<div style="color: rgb(33, 33, 33); background-color: rgb(255, 255, 255);" dir="auto">
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</div>
<div id="ms-outlook-mobile-signature" dir="auto">
<div><br>
</div>
Get <a href="https://aka.ms/AAb9ysg">Outlook for Android</a></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> cs631apue-bounces@lists.stevens.edu &lt;cs631apue-bounces@lists.stevens.edu&gt; on behalf of Jan Schaumann &lt;jschauma@stevens.edu&gt;<br>
<b>Sent:</b> Tuesday, December 6, 2022 12:08:05 PM<br>
<b>To:</b> cs631apue@lists.stevens.edu &lt;cs631apue@lists.stevens.edu&gt;<br>
<b>Subject:</b> [cs631apue] kernel vs process</font>
<div>&nbsp;</div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Hello,<br>
<br>
On my way home last night I was thinking about how to<br>
better explain the difference between when a process<br>
runs on the CPU versus what the kernel does.&nbsp; One way<br>
to get better clarity here is to understand that the<br>
kernel itself is not process like any others:<br>
<br>
When the kernel boots, it is running on the CPU in<br>
kernel space (ring 0).&nbsp; It bootstraps the system, and<br>
as part of initiates the scheduler.&nbsp; It then doesn't<br>
really do much of anything until a suitable interrupt<br>
causes kernel code to be executed (e.g., hardware<br>
interrupt for I/O, preemption by the scheduler).<br>
<br>
When a user process executes (e.g., explicit creation<br>
of init(8) by the kernel or any of its child<br>
processes), that will run in user space (ring 3).<br>
When it makes system calls, the CPU switches to kernel<br>
mode and the syscall completes.&nbsp; At this point, the<br>
kernel &quot;has the CPU&quot;, so to speak. The user process<br>
may be preempted (i.e., by an interrupt as above) or<br>
terminate, and control returns to the kernel.<br>
<br>
That is, rather than thinking of the kernel as a<br>
process that runs and needs to be preempted to let a<br>
user process run, think of the kernel as the larger<br>
program that runs _in between user processes_, as the<br>
kernel simply isn't a process itself and doesn't<br>
behave like one.<br>
<br>
Perhaps this chapter of O'Reilly's &quot;Understanding the<br>
Linux Kernel&quot; can also help you clarify your<br>
understanding:<br>
<a href="https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.oreilly.com%2Flibrary%2Fview%2Funderstanding-the-linux%2F0596002130%2Fch01s06.html&amp;amp;data=05%7C01%7Ckbondugu%40stevens.edu%7Cbce2acf998e04d236ee608dad7ac7e16%7C8d1a69ec03b54345ae21dad112f5fb4f%7C0%7C0%7C638059433114408759%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=0qyWZZcTqbnt16p1YBVJPadqa45%2FTBxJOHiC23Dfu%2BM%3D&amp;amp;reserved=0">https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.oreilly.com%2Flibrary%2Fview%2Funderstanding-the-linux%2F0596002130%2Fch01s06.html&amp;amp;data=05%7C01%7Ckbondugu%40stevens.edu%7Cbce2acf998e04d236ee608dad7ac7e16%7C8d1a69ec03b54345ae21dad112f5fb4f%7C0%7C0%7C638059433114408759%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=0qyWZZcTqbnt16p1YBVJPadqa45%2FTBxJOHiC23Dfu%2BM%3D&amp;amp;reserved=0</a><br>
<br>
Hope that helps,<br>
-Jan<br>
_______________________________________________<br>
cs631apue mailing list<br>
cs631apue@lists.stevens.edu<br>
<a href="https://lists.stevens.edu/mailman/listinfo/cs631apue">https://lists.stevens.edu/mailman/listinfo/cs631apue</a><br>
</div>
</span></font></div>
</body>
</html>