[00:00:02] Okay, great, the screen is green now again. [00:00:10] Okay, so let's start fresh. [00:00:24] So we already know how a CPU executes instructions. [00:00:28] Also, we know how memory stores programs and data. [00:00:35] But here is the question. [00:00:38] When 10 different programs appear to be running on the machine, who creates those programs? [00:00:47] Who decides when they run? [00:00:50] Who isolates them? [00:00:53] And how does a user program ask the hardware [00:00:56] to perform privileged operations? [00:01:00] Even before understanding privileged operations, [00:01:04] how the program asks the hardware to perform operations? [00:01:10] That is where the operating system enters into the picture. [00:01:18] Cool. [00:01:20] So what is our objective here? [00:01:21] Our objective is basically slowly transition [00:01:24] from hardware architecture towards the operating system. [00:01:29] Then dive deep into understanding the operating system, [00:01:34] components, the privileges, [00:01:37] how the processes are handled, [00:01:40] how the context is switched. [00:01:45] These four are the pillars of operating system. [00:01:49] and these are all the foundation of operating system as well. [00:01:56] So before we get into the details of processes and other stuff, [00:02:04] it's good for us to understand the operating system mechanism [00:02:08] and that is the reason I'm bringing an operating system in session 4.5 itself [00:02:13] instead of session 9. [00:02:16] So, now, this is the complete chain, which we need to understand. [00:02:32] So, in this complete chain, where does it start? [00:02:36] It starts from hardware, goes to operating system, and then manages the process. [00:02:47] So in this entire thing, in case if you wanted to understand this chain, to treat an operating [00:03:01] system as a manager between applications and the physical computer, that is the easiest [00:03:08] way to understand this chain. [00:03:13] If you are thinking the university campus, and if you want to map, then hardware is your [00:03:22] physical campus and its facilities. Something like Hayatipatna. Then the kernel is the campus [00:03:32] administration. And the system calls is the formal request submitted to the kernel. That [00:03:44] is submitted to the campus administration. Anybody can. Then process is a student or [00:03:54] a team currently doing some work. It could be the teaching staff. It could be administrative [00:04:02] staff. It could be the student themselves. That is process. Then what that student or [00:04:12] team is currently doing, that is the process state. Okay. Scheduling is nothing but deciding [00:04:23] who gets access to shared facilities as a student sorry as a student what access you get [00:04:35] as a professor what access he or she gets as an administrative assistant what access [00:04:43] they get within the campus that is scheduling and context switch we can probably map it to [00:04:56] saving one person's work and giving the facility to another for example you have [00:05:04] a lecture a physical lecture in a classroom and then you have two lectures back to back [00:05:13] 90 minutes [00:05:14] for 3 hours you have lecture [00:05:17] there is a break [00:05:18] and after that the same facility [00:05:21] can be used to by another [00:05:22] stream of students [00:05:25] so closing [00:05:27] your work [00:05:28] saving your work [00:05:31] and giving the facility back to someone else [00:05:34] is the [00:05:36] context switching that [00:05:38] happens [00:05:38] and all these [00:05:41] commands, system calls [00:05:44] is basically creating work, replacing work, waiting for work, finishing the work. [00:05:54] Basically, the process lifecycle management, the work lifecycle management. [00:06:02] Now, let us walk through the chain. [00:06:08] And before we continue, the important thing is that these are not unrelated topics. [00:06:20] what eight we have, don't think it is unrelated topics, it is a continuous story, now a program [00:06:35] wants to do something, let us assume that it is the same PowerPoint, I have opened it, [00:06:40] I have maximized it and I am sharing it as well, so how many actions I have done, [00:06:47] I have opened the PowerPoint, I have [00:06:51] put it to the screen, I have shared it and I am using it [00:06:54] so if I want to do this [00:06:57] I need a program called PowerPoint [00:07:00] and if PowerPoint wants to do something [00:07:05] it needs operating system [00:07:08] suppose if I don't have a Windows operating system in my laptop [00:07:12] can I install Microsoft Office [00:07:16] will I be able to browse [00:07:19] Not about only Windows operating system. [00:07:21] I need at least one operating system. [00:07:25] It can be Windows, it can be Linux, it can be Macintosh. [00:07:31] One operating system is a must for me to run my presentation. [00:07:37] Now, if the operating system needs to run, then it needs hardware. [00:07:49] So that means there is some communication that is happening between the program and the operating system. [00:07:56] and the operating system and the hardware. [00:07:59] And that communication is established [00:08:04] through the components of the operating system. [00:08:13] So the OIS creates a process. [00:08:18] It tracks the process. [00:08:21] It schedules whenever it needs to run scheduling. [00:08:28] and the CPU or memory or disk [00:08:33] switches between the processes, [00:08:35] that is context switching. [00:08:39] The processes can create, replace, wait for [00:08:43] or terminate other processes. [00:08:47] So is this the only process that is running [00:08:49] as of now in my laptop? [00:08:50] That's the PowerPoint presentation. [00:08:52] No, I'm running a browser. [00:08:56] Through browser only, I connected to the call. [00:09:02] When I connected to the call, the browser called for the Microsoft Teams application. [00:09:09] So the Microsoft Teams application is also running at this point of time. [00:09:15] Apart from that, I also have other complementary applications that are running, [00:09:20] which is related to the training. [00:09:25] so now [00:09:27] I am running at least [00:09:29] 4 or 5 programs in parallel [00:09:31] so is all the programs [00:09:35] running [00:09:37] at any given point of time [00:09:38] the answer is no [00:09:39] now unless I click [00:09:44] either moving up or down [00:09:48] or coming out of the PowerPoint [00:09:50] presentation this PowerPoint [00:09:52] presentation does not [00:09:54] require anything to be [00:09:56] processed [00:09:57] it has completed processing to display this page and it is waiting what next but browser on the [00:10:05] other hand it's also is waiting at this point of time i also running a vmware application which is [00:10:12] also waiting but all these processes are active until it exists it is active so fork is something [00:10:24] that we say it is creating [00:10:26] a process, new process. [00:10:30] Exit is basically [00:10:31] replacing the current process [00:10:33] with a new process. [00:10:36] So the CPU [00:10:37] or RAM, whatever, [00:10:39] the current process which is running, [00:10:42] if it has completed, [00:10:43] then it will exit. [00:10:45] That will get replaced with a new [00:10:47] process that [00:10:49] was created, that is waiting [00:10:51] for processing [00:10:53] will be executed. [00:10:55] Once it is executed, then it will exit. [00:10:58] So it is a process. [00:11:01] Again, this itself is a process. [00:11:03] Creation, wait, replace, and exit. [00:11:11] So it's a complete chain. [00:11:13] None of this is independent. [00:11:17] And let us start at the bottom, that is the hardware. [00:11:23] In the slide, it is on the top. [00:11:25] But what I meant by bottom is the bottom-most layer, [00:11:31] physical layer. [00:11:34] Now, this hardware is a physical machinery. [00:11:39] For example, CPU executes instructions. [00:11:45] It could be, we have seen, add, subtract, compare, load, [00:11:50] store, jump. [00:11:52] This we have seen. [00:11:54] Then the memory. [00:11:57] Temporary holds programs, data, variables, instructions currently being used. [00:12:06] That's our hardware. We also understood the disk. [00:12:12] It stores information permanently. The difference between RAM and SSD drive is [00:12:20] it's a temporary storage, but this is a permanent storage. [00:12:22] it will store all your operating system, applications, documents, photographs, videos, [00:12:30] audios, anything and everything, hard disk is capable of storing it. Now as part of that, [00:12:38] I also have mouse, I also have keyboard that is input. As of now, I'm using my mouse to move [00:12:47] around this slide. Now, how is this getting converted into instructions and how is getting [00:12:57] processed? That we know. But how exactly it happens? Because mouse is also connected over a [00:13:05] Bluetooth. Bluetooth is a hardware. So did Bluetooth hardware connected it physically? No. [00:13:13] The Bluetooth hardware was enabled by a Bluetooth software and the Bluetooth software is connecting [00:13:19] my mouse to my laptop. [00:13:22] So it is an input device. [00:13:26] Now, whatever is the communication [00:13:28] that is coming out of my mouse [00:13:29] is captured by the Bluetooth software [00:13:33] and then communicated [00:13:35] back to the operating system. [00:13:39] My Bluetooth software is installed [00:13:41] on my operating system. [00:13:45] So like this, I have a keyboard [00:13:49] and also have a monitor [00:13:52] as an output. [00:13:54] So monitor also is connected over wireless. [00:13:59] So the hardware is powered up, the power has enabled the hardware, [00:14:08] and the operating system is making it as functioning. [00:14:14] Suppose if I'm not powering up my laptop, I'm not booting up my laptop, [00:14:18] or if my battery goes down, then nothing will work. [00:14:26] Even though I have operating system in my laptop, I have hardware, whatever we discussed, everything [00:14:32] is there. There is no power and battery ran out. Nothing will work. So power is the basis. Power [00:14:43] has to be supplied to the hardware and then the hardware will be enabled. Once the hardware is [00:14:48] enabled, the operating system will take over. Now there is a problem. Suppose instead of the power [00:14:59] point if i'm using a microsoft word and then i'm typing hello world [00:15:09] basically microsoft word as an application needs to receive the input from the keyboard [00:15:16] because i'm typing hello world now once i type it has to store that in the memory [00:15:26] because i have not saved my file yet so somewhere it has to store it so it is storing in the memory [00:15:32] temporarily and perhaps when i save the document to the disk it is going to remove it from the memory [00:15:45] but until then it has to display the characters on my screen otherwise how will i know as a user [00:15:52] what am i typing maybe i'm typing it wrong i want to correct it so now this communication between [00:16:02] the keyboard the mouse the monitor the microsoft word application the operating system how is it [00:16:10] happening it is strictly collaborated by the unit called kernel this is our hardware and from here [00:16:23] it starts the operating system this is the core of the operating system which one the kernel [00:16:31] imagine if every application could directly control the hardware i'm opening microsoft [00:16:38] powerpoint and assume that it has the ability to control the hardware directly then i am opening [00:16:45] microsoft word then i'm opening the browser then all these applications if they are going to [00:16:52] control the hardware functioning then one might say give me some memory and one application [00:17:05] might say save this to ssd5 oh it is already written i can't write over it remove that write [00:17:12] mine then powerpoint will say remove word i will write mine mine is important user is working on [00:17:20] my powerpoint presentation so then who is going to control this that control is happening by the [00:17:28] operating system and the core of the operating system that is the kernel is actually going to [00:17:35] Otherwise, it would be a chaos. [00:17:37] You have 16 GB RAM, [00:17:39] and as a user, you are greedy. [00:17:41] As long as it works, I will open. [00:17:44] That is any user's attitude. [00:17:48] Only the moment the CUS computer gives [00:17:52] an indication that it is running out of the resources, [00:17:55] I cannot be as fast or as smooth as possible, [00:18:00] and one or two application hangs, [00:18:05] We don't stop, we don't think, we don't think, oh, 32 GB RAM, it is there, let it manage. [00:18:12] What is that it? [00:18:14] That it is the kernel. [00:18:17] So we are not going to manage as a user. [00:18:20] Even our user applications are not going to have a direct communication with the hardware. [00:18:26] That communication is established by the operating system that is a kernel. [00:18:30] Now, this kernel is the manager that controls access to the computers, all resources. [00:18:42] None of the other component in the operating system can contact the hardware directly. [00:18:48] The request has to go through via kernel. [00:18:53] So conceptually, if you look at it, the applications are going to give request to the kernel. [00:19:00] The request from the application is going to come to the kernel. [00:19:04] Then the kernel is going to provide the hardware resources [00:19:08] that is required for that particular application. [00:19:11] Who is interfacing kernel and the application? [00:19:19] The interface for applications to request [00:19:24] the services from the kernel, [00:19:27] basically the system calls. [00:19:29] Suppose if the word wanted to open the file, [00:19:34] because you have asked to open the contract.doc, [00:19:40] You have double clicked on that Word document. [00:19:44] Now, will application give the request directly to kernel? No. [00:19:52] The request will go via system calls to the kernel. [00:20:00] It provides a controlled way to perform privileged operations. [00:20:06] Normal operations is basically temporary action. [00:20:11] Reading the memory, storing it temporarily, caching it and removing the caching after operations are over. [00:20:22] All these are normal operations. [00:20:23] But if you want to do a privileged operations, something like Microsoft wanted to save the file, that's a critical operation. [00:20:32] if you are not able to save it successfully [00:20:35] then all the effort of [00:20:37] tapping the document [00:20:39] and having the document formatted is fiddled [00:20:41] so now why should we waste our effort [00:20:46] so saving a document is a critical action [00:20:50] as far as kernel is concerned [00:20:52] reading a document is also critical [00:20:55] but less critical compared to writing a document [00:20:58] because the reading a document [00:21:01] is only read the available data. [00:21:05] But writing a document is basically [00:21:07] the data is coming from outside [00:21:09] into the system. [00:21:11] Tomorrow if the same user tries to open [00:21:14] the same Word document [00:21:15] and if it is not opening [00:21:17] saying that it is corrected [00:21:19] then what would be the OJANA? [00:21:24] So that's not the situation [00:21:26] one wish to be in. [00:21:29] So, that is totally controlled by the system calls. [00:21:36] Now, why can't application directly talk to hardware? [00:21:44] Let us imagine a railway station. [00:21:49] The passengers don't personally control anything, but the railway station is for the passengers. [00:21:57] The railway station won't exist if there are no passengers to travel from that station. [00:22:05] No trains will stop in that station if there is no entry exit of the passengers. [00:22:14] But still passengers won't control the railway. [00:22:19] Be it like signals or tracks or planning or switches or routing of the train, [00:22:26] delaying a train holding a train none of the decision is made by the passenger [00:22:33] but that entire system is working for the passenger so it is very similar to this [00:22:41] our entire system is running for you as a user but you don't have any control over it [00:22:49] maximum what you can do you can just plug [00:22:53] remove the plug that's all you can do but you cannot say okay my microsoft word will need to [00:23:03] have more resources and my powerpoint should directly work with the hardware [00:23:09] like how we have in our offices skip level reporting skip level meetings [00:23:17] definitely not with the computer it is you cannot skip operating system [00:23:25] You cannot have a skip level meeting with the hardware missing the operating system or overthrowing the operating system. [00:23:33] You cannot continue to access the hardware. [00:23:36] That is what is the agreement between the hardware and the software. [00:23:41] Even operating system is also a software. [00:23:45] So now it's a chain. [00:23:51] It's a very, very complete chain. [00:23:54] chain. The application request for resources, that's all it can do. It cannot identify, [00:24:02] it cannot execute, it cannot play, it cannot exit, it cannot create, nothing. It can only [00:24:09] request, like how you are requesting for a ticket in a train. If it is available, you [00:24:14] will get it. If it is not available, they'll say thank you, but still, train will be run [00:24:19] by them and not by you, you won't get any [00:24:23] benefit, you need to accommodate [00:24:28] very similar situation for the application [00:24:32] though we are running the entire hardware for the application [00:24:36] now we do not expect application to choke [00:24:40] just because there is, so now [00:24:53] the system calls is the next, now [00:25:00] So, the system call is essentially a controlled way for a program to ask. [00:25:07] So, everywhere if you look at it, it is for a program. [00:25:10] The entire system is working for the passenger, and the entire railway is running for the passenger. [00:25:18] Obviously, in addition to the passenger, it runs for goods as well. [00:25:23] But neither passenger nor good can control it. [00:25:27] you can only go ahead and request [00:25:30] I need a ticket to travel [00:25:32] I need a reservation to travel [00:25:35] I need cancellation of the ticket [00:25:37] you can request [00:25:40] so now the system call is an interface [00:25:44] for applications to request services [00:25:47] from the kernel [00:25:49] it provides a controlled way to perform [00:25:52] privileged operations whether it is reading files [00:25:55] or creating processes [00:25:57] whatever it is it says is the application their operating system please do this operation for me [00:26:06] then the system call is going to create the process so the system call will create a process [00:26:19] and it can also make the process wait it can also make the process execute [00:26:29] It can also exit the process if the action is completed. [00:26:34] So that control is through the system calls. [00:26:41] And a simple analogy for the system calls is [00:26:46] a guest wants something from the hotel's internal facilities. [00:26:51] The guest does not enter the kitchen and start operating the equipment. [00:26:55] Definitely not. [00:26:55] instead the guest is going to call the reception [00:27:00] the reception is going to inform the hotel staff [00:27:04] and hotel staff is going to inform the internal facilities [00:27:08] so the service request is very similar to a [00:27:12] system call [00:27:13] it has to go through this process [00:27:16] there is actually no other go [00:27:20] it has to go through [00:27:22] now for example please bring me a towel [00:27:26] the guest makes a request [00:27:29] The hotel decides how to fulfill it. [00:27:33] Similarly, here, the system call will decide how to fulfill it. [00:27:39] Now, what is a process? [00:27:43] A program is essentially a set of instructions stored somewhere. [00:27:48] For example, PowerPoint.ehd. [00:27:52] It is stored somewhere in my hard disk. [00:27:55] It is accessible to me. [00:27:56] I have ability to access it, and we are sitting together. [00:28:02] So that is how it is. [00:28:08] So the set of instructions showed somewhere. [00:28:12] But when you actually launch it, something changes. [00:28:16] What changes? [00:28:17] The operating system loads the program into the memory and starts executing it. [00:28:22] So the execution happens in the memory. [00:28:25] That executing instance is called as process. [00:28:32] This distinction is very, very extremely important. [00:28:36] A program is passive and the process is active. [00:28:43] The program that you are running is passive [00:28:45] and the process that is running is actually active. [00:28:53] Now, let us think of a recipe. [00:28:59] The process is an executing instance of that program. [00:29:03] So, somebody, someone actually cooking the recipe is what we can understand. [00:29:11] Program is Microsoft Word, action is launch, the technical stuff is process, okay, so now [00:29:30] the process is Microsoft Word currently running. [00:29:36] What is this currently running? [00:29:37] That is the process state. [00:29:40] call has created the process now the process is in a specific state it can be ready ready means it [00:29:47] is ready to process but waiting for the processor to be available for that i'm repeating ready means [00:29:53] it is ready to execute but waiting for the processor time so that it will get that processor time [00:30:01] Don't tell me that when it was there, the thing has been like, handled, but suddenly [00:30:12] now why? [00:30:13] Why we are having an extra people, extra process, suddenly we see that it is happening. [00:30:24] So now, one program can produce multiple processes, for Sundar, how is that possible? [00:30:46] Suppose three people open the same application. [00:30:50] Let us assume that the application is running in a server, and three of the people are running [00:30:58] the same application, so basically multi-user, multiple users can use the application at [00:31:05] a given point of time. [00:31:07] So then automatically for each one of us, there will be one processor that is running [00:31:12] behind. [00:31:13] So every instance that it is getting opened by a different user, then it becomes a different process. [00:31:27] And once you have the process, the process can have its own memory, every process. [00:31:34] Every process. [00:31:34] Suppose if you are running some 25 processes currently in your laptop, then every process will have its own ID provided by. [00:31:42] and then we'll have the execution state what is that execution state whether it got cpu allocated [00:31:56] or not if got allocated is it over or not if it has been that if the results are declared then [00:32:04] what is the state of it what are all the different users the cpu context the process identifier most [00:32:14] important so how are these processes are identified with the identifier we call it as process id [00:32:24] so if a microsoft word is opening and if you are seeing like three or four [00:32:31] processes getting opened then you will see that you will be able to see that [00:32:41] whenever it is running how we can identify it by its identifier that's basically process id now [00:32:58] when we have that each process having its own resources having its own state and who will assign [00:33:10] who will assign the resources for the process [00:33:13] basically the process will be scheduled by the scheduler the scheduling is also part of the [00:33:24] operating system this entire thing is operating system except for the hardware rest everything [00:33:30] in the chain is part of the operating system so now the process state will get a scheduling from [00:33:39] the scheduling to go ahead and process basically the authentication to utilize the services [00:33:50] for the ready process. [00:33:54] Now the scheduling is done. [00:33:57] Let us assume that three people are waiting for one doctor. [00:34:03] Now imagine patient A, B and C. Now there is a scheduler for the appointment. [00:34:12] Once you have the scheduled your appointment, you can just go back from the scheduler and you can definitely. [00:34:26] So now, this is a chain, a complete chain, and it cannot be broken. [00:34:33] If you break, the entire cycle is broken. [00:34:38] For example, if kernel is not functioning at this point of time, you will not be able to operate your laptop. [00:34:48] Just a very simple example. [00:34:51] So why do we need scheduling? [00:34:56] Say, for example, I have browser open, I have PowerPoint open, [00:35:00] I have Microsoft Word open, I have VMware open at this point of time. [00:35:05] Let's take four of the programs. [00:35:08] Now, who's going to control? [00:35:11] Browser requires how much? [00:35:14] Is it going to get a higher resource than what it is required? [00:35:18] No, it should not be. [00:35:19] currently browser it's doing nothing [00:35:23] so one or two communication [00:35:25] with the network [00:35:26] ok probably [00:35:29] that's fine [00:35:32] but it has to be in the wait [00:35:34] it can't be in the ready [00:35:37] ready means the next [00:35:39] available slot will be allocated to you [00:35:41] ready means basically [00:35:43] the process is ready to execute [00:35:44] who runs now [00:35:51] who runs next [00:35:53] how long should they run [00:35:55] All these things are going to be practical stuff for you. [00:36:08] So now, when we are going to assign more resources for browser, [00:36:14] when it is not required, then it is a waste of resource assignment. [00:36:19] That is also we need to keep in mind. [00:36:22] So that is why we require scheduling. [00:36:24] Scheduling is going to identify which processes are ready to get executed, [00:36:29] and it will give the resources for those processes [00:36:33] irrespective of the age. [00:36:41] So now, without scheduling, [00:36:44] we will not be able to run all the four, [00:36:47] Microsoft Word, Microsoft PowerPoint, [00:36:51] Microsoft Zone, and the system as well. [00:37:01] So now, if I'm going to break this chain, [00:37:06] then my system will hang or my program will hang. [00:37:11] The worst case, the current processing will be lost. [00:37:15] So that's the reason we should not be breaking this. [00:37:18] But when the scheduler gives a process, [00:37:21] CPU time, for example, [00:37:25] then that process will change its status from ready to running [00:37:31] or runnable, whatever status it works out for you. [00:37:37] You can go ahead and choose. [00:37:45] So now, what is next? [00:37:48] once it is running it has completed the process it has executed the instructions [00:37:54] now the cpu might not keep running process forever why because the another process needs the cpu time [00:38:04] this processes are in the queue so the ois may say process a pass process b gets the [00:38:12] you now. So now [00:38:19] browser required the process [00:38:22] and it is provided. Now [00:38:24] browser has fetched the data [00:38:25] displayed in the screen. Now [00:38:28] it has nothing else to do, so it is keeping [00:38:30] quiet, so that call will be [00:38:32] switched. [00:38:34] Maybe that connection, whatever [00:38:36] it was available, will be provided [00:38:38] by another [00:38:40] government. That [00:38:43] area as [00:38:45] well is [00:38:46] sort of cordoned. [00:38:49] Why do we do that? [00:38:50] It's the same thing that happens with the system also. [00:38:55] Can we carton off? [00:38:56] Yes, we can carton off. [00:38:57] We can not allow anyone anywhere. [00:39:04] So if that is the case, then we really need to look into. [00:39:24] So at this point of time, I would like to pass here. [00:39:27] I just gave us a little silent. [00:39:30] Any queries, any questions? [00:39:31] Let me stop sharing and look at if there are any queries in the chat. [00:39:37] um okay see transcript i tried energy last time itself i do not have access to enable the transcript [00:39:52] i don't have the permission to enable the transcript i do see the transcript option but [00:39:57] it is disabled in case of server with multiple requests are there then there is one process but [00:40:04] multiple threads okay see threads are basically from the software perspective [00:40:18] when when you are giving the instruction you can give using multiple [00:40:26] threads what is a thread thread is nothing but a connection from the application to the [00:40:30] kernel. Now, this application is so critical and there is going to be a high amount of [00:40:38] volume of data that is going to come. I want it to directly get connected so that there is [00:40:45] established communication and that is for the fast parallel. Parallel, obviously, it is going [00:40:58] to be fast. But for each thread, there would be a process ID. And if you have a process, [00:41:06] we can also break that process into multiple sub-processes. We call it as child processes. [00:41:12] A process can create process and those child processes will be active until the operation [00:41:22] is over, and then it will be disappearing and giving all the details back to the administrator. [00:41:33] So, are we really using the system for training, or are we using the system, when I say training, [00:41:46] basically the training-related activities using that particular term. [00:41:55] So now it goes, comes back, it goes, comes back. What is that? The instruction. From where to where? [00:42:03] From kernel to hardware, hardware to kernel. The response is received for all the requests [00:42:08] posted by except one that is basically not a request but was supposed to be treated as a request [00:42:26] so anyhow fair enough but still the communication happens over this channel only we call this as [00:42:35] channel because most of them do have okay well any other queries questions so let me take a look at it [00:42:52] okay so i do see sorrow sorrow i'm enabling your mic please let me know what is your query [00:43:01] good evening sir am i audible yeah you are yeah so the flow diagram that you have shown right now [00:43:09] can we uh can we jump to that because as as of me uh i could get the individuals uh understanding [00:43:17] correctly like what the process is all about what the kernel's responsibility is what is the process [00:43:24] state like this other thing I could get but I could not connect them all together in this [00:43:29] flowchart because suppose we open of application how is it going to go through all these processes [00:43:37] and so if you would describe that it would be quite helpful to get all of them together [00:43:41] okay let us assume that you are opening the microsoft word so you need resources now you [00:43:50] need ram to store temporarily the data you need processor to process and then have the application [00:43:57] opened up so the operating system is going to receive that request which component the kernel [00:44:05] will receive the request but you like to see this downwards actually this even if i put it [00:44:15] bottom up it will be a little confusing either because there is a crisscross so now [00:44:23] application gives the request the operating system receives the kernel receives [00:44:27] the kernel itself is running over and above the hardware. [00:44:33] So without hardware, [00:44:34] you cannot have the operating system also. [00:44:37] So the operating, [00:44:38] the hardware provides resources for the kernel itself to run. [00:44:42] And in turn, the kernel manages the entire hardware. [00:44:46] If that hardware is not there, [00:44:47] you cannot have the operating system or kernel also. [00:44:51] So that's why I have just gone, [00:44:54] you know, bottom down, sorry, top down. [00:44:57] So the hardware gives space for the kernel. [00:45:00] Now the kernel is running and the kernel is the one [00:45:02] which is going to control the hardware performance [00:45:05] or hardware availability. [00:45:08] Now when an application request comes, [00:45:12] it goes to the kernel. [00:45:14] Now the kernel, can it actually ask for the hardware directly? [00:45:20] No. [00:45:21] The kernel does via the system calls. [00:45:23] the system calls, how it is getting open. [00:45:28] For example, if you want to read the file, [00:45:30] Microsoft Word is opening your resume.doc. [00:45:34] Now that file is stored inside the hard disk. [00:45:39] Your application is running from the RAM. [00:45:42] Now your application needs to go to the hard disk, [00:45:46] get to know where exactly your profile.doc is stored. [00:45:51] It has to read the content and display on your screen. [00:45:55] So who is going to coordinate this [00:45:56] and who is going to provide resources to this? [00:46:01] The system calls are going to initiate. [00:46:03] The system call will initiate, [00:46:05] okay, open the file Fopen, for example. [00:46:08] Somebody is aware of C programming, [00:46:11] they'll be able to understand. [00:46:12] These are all system calls that we can make [00:46:14] using the C program. [00:46:16] So file open, Fopen. [00:46:18] So, that fopen is the system call made by the kernel. [00:46:24] So, the fopen, fopen where? [00:46:28] From the disk. [00:46:31] Okay. [00:46:32] So, someone has to monitor, someone has to track, someone has to ensure that this particular [00:46:38] read from the hard disk is completed and then it is getting shown on the screen. [00:46:44] Someone has to have the control over it, and that's what exactly the process. [00:46:50] So for example, fork is a system call which will create a process, [00:46:57] either from the current process or even outside of that. [00:47:03] So when it is opening the process, the process is opened, [00:47:07] now how are we going to treat it? [00:47:09] How are we going to track it? [00:47:11] How are we going to ensure that it is closed? [00:47:14] because more and more you keep these requests on, [00:47:18] the resources are going to be continuously consumed. [00:47:21] So at some point of time, you need to fill the request [00:47:25] or ensure that it comes out automatically so that we are good. [00:47:32] So now the system calls create resources [00:47:36] with the type of operations as an indication. [00:47:40] It is just an indication that it is an F open. [00:47:43] So it is execute. [00:47:44] it is a grid. [00:47:48] So that little flexibility you can have, [00:47:51] but you can also use that flexibility [00:47:54] for your advantage of not storing much, [00:47:57] storing only enough. [00:48:00] Even that is also not. [00:48:05] So system calls, [00:48:08] from the system calls, [00:48:09] a process will be created [00:48:10] and the process has to be identified, [00:48:13] monitored, [00:48:13] so the process ID will be created [00:48:16] and that process ID will hold the action [00:48:21] and it will get displayed once it uses the system resources. [00:48:27] For example, HHDD. [00:48:32] So probably we will have time trying to get, [00:48:41] but that's not sufficient. [00:48:43] The ID will get monitored. [00:48:46] but how did it get the resource? [00:48:52] One is monitoring, another one is obtaining, [00:48:55] third one is performing. [00:48:57] Who is going to monitor? [00:48:58] That's what exactly this scheduling and context switch [00:49:01] is going to help. [00:49:04] So when the request comes in, [00:49:05] it comes to the kernel from the application [00:49:08] and it flows down. [00:49:11] And why hardware is not down and why it is up? [00:49:13] Because the kernel itself is running in the hardware. [00:49:16] so now all these things will be operating in this hardware did it make sense okay so actually the [00:49:25] thing was this the hardware is was at the top so that was a bit confusing i thought that the [00:49:29] processes would be going from bottom to up as shown in the flow diagram but it was like top to [00:49:36] bottom so now now i could relate the application once open it would directly go to cardinal and [00:49:42] And then all the things would happen, [00:49:44] like system, code process, process, state situating, [00:49:46] and context retrieving. [00:49:47] Exactly. [00:49:49] OK, so thank you, sir. [00:49:50] That was a very good clarification. [00:49:53] Thank you. [00:49:55] OK, cool. [00:49:56] Thank you, Saurav. [00:49:56] So let me make a... [00:50:00] Varun, I'm enabling your mic. [00:50:07] Sir, one thing I would like to understand more on this thread versus process, that one. [00:50:13] And second thing is about, I heard this is called the priority process. [00:50:18] In operating system, you have a concept of priority process, correct? [00:50:21] Some of the processes are given more importance than other. [00:50:25] Or they also call sometimes OS process. [00:50:28] And third question is on schedulers. [00:50:31] Schedulers, can I say scheduler is also a process? [00:50:34] No, no. Scheduler is a component in the operating system like a kernel, which will monitor the utilization of the resources. [00:50:49] Whenever it is free, it will be giving the resources to the waiting process. [00:50:56] Because the moment the process is ready, that means it is waiting for the resource. [00:51:02] So whichever process is ready to be executed to those processes on priority, [00:51:08] it will allocate the resources. [00:51:11] So this is totally different. [00:51:14] We cannot consider scheduling as a process. [00:51:17] It is component of the operating system. [00:51:23] Did I answer your query? [00:51:24] Okay. [00:51:25] Now the second thing is you are speaking about process and thread. [00:51:31] Okay, let me take a minute to expand it. [00:51:35] See, a process is an independent program in execution [00:51:38] with its own dedicated memory space. [00:51:42] That is what we have seen in the process. [00:51:45] While a thread is a lightweight unit of the execution [00:51:48] that shares the memory and resources of its parent process. [00:51:54] So now the concept of parent and child comes in. [00:51:58] I wanted to touch upon a little later, but anyhow, I'll explain it right now. [00:52:03] So once you are creating a process, that process can create sub-processes. [00:52:12] And for example, when you are trying to open a file, [00:52:17] actually the application will do two or three things in parallel. [00:52:22] One is that it will open the file, [00:52:25] open the file it will put the content into the memory that is getting displayed on the screen [00:52:30] and it will also look for an input from your keyboard the moment you open a word file these [00:52:38] three always it will run in parallel but these three are not three independent processes the [00:52:47] file open process will create three different independent processes under it. [00:52:54] So now this process has created sub-processes and that sub-process also can create [00:53:01] two or three different processes inside it. It depends on the way the program is functioning. [00:53:08] The process is getting created, sub-processes. So the sub-processes which is getting created [00:53:15] under a single process. [00:53:17] It could be process, it could be sub-process, [00:53:18] which is creating other processes within itself. [00:53:22] Those are all called as threads. [00:53:26] So the cumulative processing of all the threads together [00:53:30] will be the output from the overall process. [00:53:42] That is how it is. [00:53:43] Key difference is processes have isolated memory spaces, [00:53:47] preventing one from interfering with another. [00:53:51] Two different processes cannot interfere to each other. [00:53:55] Suppose if you're opening a browser and you're opening a Microsoft Word, [00:53:59] these two processes are independent, and it will not share any resources. [00:54:04] It cannot override any resources. [00:54:06] It will be independent. [00:54:08] But threads will be within the same process share code. [00:54:13] So it will be the same data or the heap memory. [00:54:17] Whatever it is, it will be shared with the process. [00:54:19] Now, creation and termination, if you look at it, processes take more time and system resources to create and destroy. Processes will take comparatively more time. But threads are faster and cheaper to create and terminate. [00:54:37] terminate. So that is [00:54:39] the reason when a [00:54:42] developer writing a program, whether [00:54:43] it is a system program or an application [00:54:45] program, they will always [00:54:48] try to use thread [00:54:49] in their coding [00:54:51] because it is faster to [00:54:53] access the [00:54:54] resources to [00:54:57] terminate. All [00:54:59] those things are very fast. [00:55:01] So that's the reason. Instead of having different [00:55:03] processes, they will create threads [00:55:05] within a single process. [00:55:07] Context switching, switching between processes has a high overhead [00:55:13] because the system must swap out the entire memory context. [00:55:18] Suppose if I'm not doing anything with browser now. [00:55:23] So this entire browser content has to be swapped. [00:55:28] And if something else is active, [00:55:30] it has to bring it back into the memory. [00:55:32] The context switching is a little costly for processes, [00:55:36] But switching between threads is much faster because it is of the same process. [00:55:41] So the process is already in the memory, [00:55:44] no contact switching is required. [00:55:46] So these are all the major differences. [00:55:49] There is also a difference with communication. [00:55:53] But these are all the major differences between process and threads. [00:55:59] Generally threads are created by the software component with a request to [00:56:03] the kernel and to the [00:56:05] process to create sub-process. [00:56:07] That's how it goes. [00:56:09] Most of the request comes from the software [00:56:11] and operating system does not create [00:56:13] threads on its own. [00:56:15] Did I answer your query? [00:56:18] Yeah, sir. [00:56:19] Yeah, that's helpful. [00:56:21] Are you not sharing screen? [00:56:23] No, I'm not sharing the screen. [00:56:25] Do you want me to share? What is that you are looking [00:56:27] for? No, no, no, no. [00:56:28] I thought you were saying. And the last [00:56:31] parts are about this [00:56:32] there are some [00:56:36] specific processes which are called [00:56:38] OS process or priority process [00:56:40] if we can also give little light on that one [00:56:42] we are going to touch upon that [00:56:44] next Varun we will discuss in [00:56:46] detail [00:56:46] thank you [00:56:50] okay cool [00:56:51] Sanjeev I am enabling your [00:56:54] mic [00:56:54] hi sir so I wanted to ask [00:56:59] there are 100 process [00:57:02] running so how to [00:57:04] it decides like which process gets the CPU which process gets the CPU [00:57:14] so there are first thing is you need to map the CPU to the processes [00:57:25] CPU means I don't think you will have only one CPU you will have cores [00:57:31] we discussed that how cores is available within a CPU central processing unit [00:57:37] and each core will have its own capacity and each core can swap. [00:57:42] So now the mapping is happening between the cores and the processors. [00:57:48] That's what exactly will work at the hardware level. [00:57:54] It's not like, okay, I have two CPUs with 12 cores. [00:57:57] It's not assigned to the CPU, it is assigned to the core. [00:58:01] Core has its own capacity, its own ability. [00:58:04] now how the process the processes which are in the ready state will get the cpu codes [00:58:14] because the running processes doesn't need to give any attention if the process is completed [00:58:24] then it will exit the moment it exit all the resources will be refreshed and once it is [00:58:32] refreshing that will be allocated to [00:58:34] the ready status. This is at the first [00:58:36] step. [00:58:38] The second step, [00:58:40] there is a differentiation. [00:58:42] That's basically an [00:58:44] extension of what Varun asked. [00:58:48] Basically, the [00:58:50] processes are classified. [00:58:53] One is application [00:58:54] processes, second is system processes. [00:58:58] So the [00:58:58] system process will get [00:58:59] clarity over the application process. [00:59:02] because if system process dies, [00:59:05] even if application process get the resources, [00:59:09] then it won't be responsive to the user. [00:59:12] So to ensure availability, [00:59:14] the system processes are given priority. [00:59:18] Any of the system process which is in the ready state [00:59:21] will get reference over the application process [00:59:24] that is in the ready state. [00:59:26] This is between system and application. [00:59:30] Now, within system also, [00:59:32] there might be multiple processes that are running parallely, [00:59:35] which might be waiting for the CPU. [00:59:40] Now, how are we going to prioritize that? [00:59:44] That is prioritized by this type of system call. [00:59:49] The type of system call we will discuss as we move ahead. [00:59:54] You will understand there how exactly it is prioritized, [00:59:59] and based on that priority, [01:00:00] it will get the resources. [01:00:02] Now, there are not much of a system call that is happening. [01:00:05] That's where exactly you see CPU idle. [01:00:08] There are no application that is currently running CPU idle. [01:00:12] Certainly, if the application comes, [01:00:14] even within the application processes, [01:00:17] the process ID generally indicates the tenure of the process. [01:00:25] We can identify if somebody is having, not for the system, [01:00:29] only application processes, [01:00:31] where the ID starts from a specific number [01:00:34] and it goes for the application. [01:00:36] Until then, it is a system process. [01:00:38] I'm not trying to get that number, [01:00:40] but I'm not remembering right now. [01:00:42] I think if I'm right, it is 999. [01:00:45] Up to 999, it is system processes, [01:00:48] and after that, it is application processes. [01:00:52] Now, no, it is 999 and 49. [01:00:56] I'm really not sure. [01:00:57] So now, based on that, application and system is bifurcated. [01:01:03] And within system also the priority, the type of call gets the priority. [01:01:08] What will happen if there are multiple applications? [01:01:11] General scenario will be most of the application processes will be waiting for the resources in the queue. [01:01:19] because ideally speaking, application is the least priority [01:01:24] compared to system and application. [01:01:28] But within application also, you can see that criticality. [01:01:33] For those processes, there will be an identification for the criticality. [01:01:37] For example, your write request to the database [01:01:42] is more critical than the read request to the database. [01:01:50] So the type of request that is coming from the application [01:01:54] differentiates the priority. [01:01:58] All these are predefined. [01:01:59] We don't have to define. [01:02:01] All these are predefined in the kernel. [01:02:04] So the write operation gets a priority over a read operation. [01:02:09] For any resource, need not be disk. [01:02:11] It could be even memory. [01:02:12] It could be even CPU. [01:02:14] So write gets a preference over the read. [01:02:17] And that is where exactly the database administrators, [01:02:21] if you look at it, they will go for a strategy [01:02:23] of multiple databases in multiple spaces [01:02:26] and connect those databases and make one for each other. [01:02:32] They do that, database clusters. [01:02:35] Nothing but it is one for each other. [01:02:38] So in that case, a little difference in terms of operations, [01:02:43] but still, write gets a preference over the read. [01:02:46] So like that, there are definitions within the kernel [01:02:50] which differentiates and allocates the process to the, [01:02:54] sorry, allocates the resources to the process using the scheduler. [01:02:59] Did I answer your query? [01:03:04] Are we good? [01:03:07] Yes, sir, we are good. [01:03:08] Thank you. [01:03:09] Anything else from anyone before we move ahead? [01:03:17] Okay, cool. [01:03:19] Now let us go to the next. [01:03:23] So now, user mode versus kernel mode. [01:03:31] This is also a very, very important stuff. [01:03:39] Whenever a CPU executes instruction [01:03:46] and how memory stores program and data, [01:03:50] Same way, we also have the mode within the operating system. [01:04:04] This is within the operating system. [01:04:09] Now, after we having this layer built up, right from hardware to kernel to fork, exit, wait and exit, [01:04:20] What is the difference between the operating system and the kernel? [01:04:27] That is the answer we will get from this, user mode versus kernel mode. [01:04:33] So we have the kernel and we have the operating system. [01:04:36] What is the difference between them? [01:04:39] The kernel is the privileged core. [01:04:41] Which is the privileged core? [01:04:42] The kernel is the privileged core of the operating system, [01:04:47] And it manages CPU scheduling, memory devices, processes, file systems, networking, and other [01:04:58] protected resources, everything. That is what the kernel does. So is kernel the entire operating [01:05:13] system? Answer is no. It is only part of the operating system. And apart from kernel, you [01:05:23] have something called system utilities. For example, copying files from one folder to [01:05:31] another folder, you use a copy command or cp command or whatever command you use. That [01:05:37] is a utility. Suppose you are writing a script, it is an utility. You have bought a new hardware [01:05:46] and along with the hardware, there is a device driver that you need to install. That device [01:05:53] driver is not part of the kernel. It will never be part of the kernel. It is outside [01:05:58] of the kernel. But there is something called default drivers, detecting your keyboard and [01:06:06] detecting your pointing device. [01:06:10] This is default driver. [01:06:14] Any keyboard, any mouse, at least the basic functionality, [01:06:17] it has to identify and run. [01:06:21] But that is not utility. [01:06:24] But if you're getting an application [01:06:25] while buying an EMC storage, they say, [01:06:28] like, this driver needs to be present in your operating [01:06:31] system for you to access the EMC storage. [01:06:34] That small piece of software which [01:06:36] are trying to install in your operating system and access the storage unit that is a system utility [01:06:43] so system utility is different from the kernel kernel will have only the core functions [01:06:50] which need not be modified as simple as that so whatever is inside the kernel the functionalities [01:06:58] what we are using or what it is using on its own or something that we cannot modify it can [01:07:04] be modified only by upgrading the kernel. [01:07:07] When will we upgrade the kernel? [01:07:08] When you are upgrading the operating system. [01:07:11] But these utilities you can remove, you can install, [01:07:14] you can create a new utility, you can use it. [01:07:16] Still, it will run over the operating system. [01:07:20] And then you have something called libraries [01:07:22] to support other applications. [01:07:26] That is not part of the kernel. [01:07:28] The libraries are not part of the kernel. [01:07:30] and obviously our user space programs you have installed your HDFC bank app in your mobile [01:07:39] so that HDFC bank is a user program that app is a user program which is running on your mobile's [01:07:47] operating system and that mobiles without that mobile's operating system that mobile will not [01:07:53] be functional same concept here you install some application on your operating system [01:07:58] without operating system you cannot install yes certain applications require certain [01:08:04] operating system i don't deny but without application you cannot access sorry without [01:08:09] operating system you cannot access that application or implement an application [01:08:14] so in that case all those are user based programs so in broad category the operating system [01:08:22] will have ability to control using the kernel, [01:08:28] ability to facilitate using the utilities and libraries, [01:08:32] and ability to run the user space programs. [01:08:38] Now, in this category, if you look at it, [01:08:42] this is where the privilege boundary comes in. [01:08:48] So someone was asking about the privilege of society and other stuff. [01:08:52] Now, this is the privilege boundary. [01:08:56] What is this privilege boundary? [01:08:59] It is basically it separates the user mode and the kernel mode. [01:09:03] Crossing this boundary changes the CPU from user mode to kernel mode. [01:09:08] If you're crossing this boundary, [01:09:10] it will always be identified as a kernel mode. [01:09:14] But will kernel cross the boundary? [01:09:17] No, it will not. [01:09:19] kernel knows because it is already going to run only in the kernel mode it does not have [01:09:24] any requirement to change the mode so it will run in the kernel mode but only if the user mode [01:09:36] crosses the privilege boundary can it the answer is yes it is possible suppose if i have written a [01:09:46] shell script and if i'm attaining the privilege mode using the script itself [01:09:53] with the help of kernel only [01:09:55] I cannot go directly to the hardware [01:09:57] and take it [01:09:58] I will speak to kernel [01:10:01] I will request kernel to get it done [01:10:03] and I will ensure that [01:10:04] I have the authority to request the kernel [01:10:07] and kernel will give it back to me [01:10:09] and now I have crossed the [01:10:11] boundary so I will be running my application [01:10:13] in the kernel mode [01:10:15] but actually it will be run by kernel only [01:10:17] not by me [01:10:18] only thing is my application I am running in the kernel mode [01:10:23] It's very, very difficult stuff and it is also not a daily routine, but yes, it is possible. [01:10:33] So kernel mode is basically the kernel instructions, processes, everything. [01:10:41] Everything down the line is part of the kernel. [01:10:44] anything other than that [01:10:47] whatever is getting listed [01:10:50] everything else is user mode [01:10:53] so now the system call [01:10:58] when it is going to make a call to the [01:11:02] kernel and then get the [01:11:07] processes identified and [01:11:09] coming up with the plan [01:11:11] at that point of time the system call [01:11:18] will take the control. [01:11:20] It will not allow [01:11:22] user space to take the control [01:11:24] or the end program to take the control. [01:11:26] Generally, that control is given [01:11:28] to the system call. [01:11:30] And same thing, [01:11:33] a little different. [01:11:35] So now, [01:11:41] the system call, a controlled [01:11:42] request from the user mode [01:11:44] to the kernel. It triggers a [01:11:48] switch from user mode to the kernel mode. [01:11:50] Examples like read, write, [01:11:52] open fork execute all these are there are a lot of type of system calls that is available [01:11:59] which you will see that in detail pretty soon but this is what it is a normal application [01:12:08] should not be allowed to directly execute or arbitrate privileged cpu basically if you cross [01:12:18] this boundary then you become a privileged user then you get the resources at your will [01:12:26] for that also yes you need to request i agree but yes why should we not allow a user mode to run in [01:12:43] the kernel mode basically isolation because we wanted to secure why we wanted to secure because [01:12:53] there's nothing happened so that our stability is not in question and we want to fight [01:13:03] you know the protection to the resources so now this is not merely an operating system software [01:13:11] concept it's not merely an operating system software concept the cpu provides the mechanisms [01:13:17] that allow the operating system [01:13:19] to establish privilege. [01:13:22] But actually, it is not a privilege action, [01:13:26] but yes, it's a privilege. [01:13:32] So this is the difference [01:13:33] between the user mode and the kernel mode. [01:13:38] So just wanted to pass here [01:13:40] and check if there are any queries, [01:13:41] questions from anyone. [01:13:49] Okay, so I do see Mohit. [01:13:53] Okay, I'm allowing your mic, Mohit. [01:13:57] I'm just going a little slow today because this is the foundation. [01:14:01] With this foundation and whatever we have covered with until last session, [01:14:09] these need to be mapped and then progressed further so that you will understand. [01:14:14] So while progressing from here on, we will progress parallelly, [01:14:19] both hardware and operating system. [01:14:22] Yes, Mohit, go ahead. [01:14:23] Yeah, bravo. [01:14:23] Bravton, sir. [01:14:24] so the point is i mean the question is let's say you have shown in system called like [01:14:31] function like read write often forth and execute so are these functions of the operating systems [01:14:39] and using the applications this can you please repeat your question are this let's say i'm [01:14:48] writing an application [01:14:49] considering the C program [01:14:52] and I use this fork, execute, [01:14:55] wait, exit functions. [01:14:57] So are these functions [01:14:58] are the part of operating system [01:15:00] who use the device driver [01:15:02] or kernel related things [01:15:04] down the line? [01:15:07] Okay. [01:15:08] So the first and foremost [01:15:10] clarification is if you are using [01:15:12] fork, execute in your C function, [01:15:15] those are all C functions. [01:15:17] nothing to do with the operating systems fork fork you can have command in almost all the languages [01:15:26] so system also has a fork so this has nothing to do with any of the initiations you do at the [01:15:33] application level but in case if you are using fork in your c program actually it is referring [01:15:38] back to this fork only even if you're asking your microsoft windows to open a file [01:15:44] that is basically a read request read request to a storage which storage the storage so once you [01:15:54] have all these informations collated together then definitely someone can reach am i right [01:16:00] yes sir that is how it is did i answer your query or did i confuse you [01:16:08] yes sir i just i'll repeat what you said and then you can tell me whether i'm right [01:16:13] understood right or not so i mean yeah whatever the fork i'm talking that fork let's say i need [01:16:19] to open a you have given the example right i need to open a file itself again so the microsoft [01:16:24] itself only uses the some operating system functions right and then that functions uses [01:16:34] the below i mean down the line the somewhere kernel and that will access the hardware okay [01:16:42] So it is actually otherwise. [01:16:45] Once the application gives, for example, [01:16:47] even if you write a C application in C, [01:16:50] it is an application. [01:16:52] It's a user mode only when it is initiating. [01:16:55] Unless you have written a system driver, [01:16:57] which you are using along with the operating system [01:16:59] and registering with the system, [01:17:02] operating system, [01:17:03] everything else is only user environment. [01:17:07] So, until everyone in your devices completed their processing, [01:17:18] they will be waiting. [01:17:20] Now, why are they waiting? [01:17:23] Because the processes are waiting for the response from the kernel. [01:17:28] Now, the kernel is going to give a system call to the hardware. [01:17:32] Kernel can give instruction only through the system calls to the hardware. [01:17:36] The moment it gives a system call, its job is done. [01:17:40] Now the system call has to create resources for it. [01:17:43] So now the command has come from the kernel. [01:17:46] Now a kernel to basically the system call. [01:17:52] Now the system call will create a process. [01:17:55] Once it has created the process, the process requires the resources. [01:17:59] Once that process is created, file-opening process, file-open double bracket, [01:18:08] now once that executes, that is the system call. [01:18:12] And that system call only requires a resource. [01:18:16] When you see that the Microsoft Word is occupying like 3MB of memory, [01:18:23] basically it is the data that is stored in the memory. [01:18:27] But if you see that it is using 2% of the processor, then it's not the PPT process. [01:18:34] It is the process created by the kernel through the system call that is only consuming. [01:18:40] And that call is related to your PPT, so the consumption is against your PPT. [01:18:46] So PPT won't get any allocation. [01:18:48] The system call only will get an allocation. [01:18:50] Once that process is completed, you will see your PPT coming up and showing on the screen. [01:18:56] Once that is completed, the process will exit. [01:18:59] The moment it exits, all the resources will be removed from it. [01:19:03] So the resource allocation will go to the process and the process IDs [01:19:07] rather than application. [01:19:12] So it is the system call, [01:19:14] and that is totally different from all other system commands [01:19:17] in case if you are using in any other environment. [01:19:21] Those are different from these calls in the operating system. [01:19:24] thank you [01:19:29] okay anything else [01:19:32] from anyone [01:19:33] cool so [01:19:38] Brajesh [01:19:40] I'm allowing [01:19:45] Brajesh if you are there [01:19:57] you are talking then you are talking on mute [01:20:00] Brajesh Kumar [01:20:02] yes yes [01:20:03] may I have to [01:20:05] yeah you are audible now [01:20:07] sir my question is how the kernel [01:20:10] is bypassed [01:20:12] how the kernel [01:20:13] network device kernel is bypass you want to bypass the kernel to access the device [01:20:21] yes yes like some network card like solid for there they are claiming the bypass the kernel [01:20:29] how it happens okay see we can bypass the kernel and that for that also kernel only allocates the [01:20:41] resource instead of kernel creating the processes your application will create the process [01:20:48] but again the resources are allocated by kernel only [01:20:53] though they say it is bypassing bypassing means you cannot bypass it is only the control remains [01:21:01] with the application and not transferred to the system call that is what it means [01:21:07] generally where it will happen is only with the network interfaces [01:21:22] not with the application you cannot have the application bypassing the kernel and running [01:21:29] the process but kernel bypass networking allows applications to communicate directly with the [01:21:39] network interface card because network interface card is also one of the hardware resources within [01:21:46] the computer am i right yes so now the application can directly connect to the network interface card [01:21:52] and communicate for that process generally bypassing is allowed but other than that [01:22:01] i don't see any bypass happening in any of the other resources okay so you can if at all you [01:22:12] wanted to know like why we have to do this basically it will get a lower latency for [01:22:22] communication in case your application needs to receive the response and it has to be a low latency [01:22:29] then generally we will bypass the kernel and we will communicate directly with the interface card [01:22:35] if you want higher throughput okay not only lower latency higher throughput also [01:22:41] you can achieve for example if you are handling millions of packets per second [01:22:46] Yes, like DVT in the NSE, sir. Like DVT data in NSE. [01:22:51] Yeah, DPDK. That is Data Plane Development Kit you are referring to, I believe. [01:22:56] No, no, DVT data. Tick by tick data of NSE. [01:22:59] Oh, okay, okay, okay. Yeah, that is also, yeah, NSE data. That is also fine, but that also uses only [01:23:06] RDMA. Okay, it's basically remote direct memory access, transfers memory between computers without [01:23:13] invoking either host or kernel okay suppose if you want to transfer data from one cpu to another cpu [01:23:23] there also we can do that consistent performance you want then a predictable performance [01:23:31] then in that case also we can do this but very but you need to inform kernel that you are going [01:23:39] to bypass and it is not that kernel is not aware of that process kernel will have logging about [01:23:47] all those processes and it will also have data about what has happened because it needs to know [01:23:54] for the security it's only that it is not communicated through kernel but it is communicated [01:24:01] directly with the approval of the kernel thank you okay okay cool uh sorrow we have another [01:24:14] very yes sir uh so basically the one thing that i got very clear of now is that this system call [01:24:25] is the one that is using the resources like that is shown in the task manager as i have kept it [01:24:29] from there but in the next slide sir as you have shown that in the user mode and between the kernel [01:24:35] mode there is system call are these two system calls same or they are different yeah it is the [01:24:40] same it's the same system call so so basically what uh in the chain system what we have learned [01:24:50] is like that once the application is open it will directly move to the kernel and then from the [01:24:55] kernel the system call would be done but no no don't get confused that way see if an application [01:25:00] requires if you want an [01:25:02] entry into the campus [01:25:04] you are supposed to get an [01:25:06] approval if you are supposed to have an ID [01:25:08] where will I get this [01:25:10] ID it will be given by the administrative [01:25:12] team [01:25:13] but who is going to check it [01:25:16] it is the security who is going to check it [01:25:18] not the administrative team [01:25:20] so the resources for check [01:25:22] is allocated to the security [01:25:24] they will be standing in front of the gate [01:25:26] they will have their own resources [01:25:28] and [01:25:29] approved id card without approved id card securities cannot even check right [01:25:35] so it plays a dual role the system call plays a dual role up as well as below [01:25:42] from the application to the application it has to so the administrative team is to the security and [01:25:49] to the student so basically it is like uh from user mode system call to kernel mode and then [01:25:58] the kernel mode can again go to system call and the process and process state right yeah you [01:26:02] cannot bypass the system call between the user and kernel the system call has to be initiated [01:26:11] okay and then the kernel can again go back to system yeah yeah definitely normally it would [01:26:18] not happen the response will go back to the application generally if you look at it there [01:26:25] no need of a system call from kernel to application kernel to application is basically a response back [01:26:31] to the application that will be tracked by the application and received by the application itself [01:26:36] so the moment the system call opens the file file open and the response will go to that particular [01:26:42] process process will give it to the application directly system call won't come back into the [01:26:48] picture yes as it is seen like key functions of kernel you see here it is memory management like [01:26:56] allocate and protect right and if you go to the chain uh flow there is like system call has this [01:27:03] responsibility so basically i'm a bit confused on that sorry come back again uh so in this diagram [01:27:10] you can see the key kernel function is like memory management allocate and protect [01:27:15] okay kernel functions okay yeah and in the chain uh in the chain diagram that you uh that was in [01:27:24] the previous slide it is like the system call has this responsibility okay how do i clarify that [01:27:33] now okay so this kernel is okay let us speak about the kernel in the army so what is his or her [01:27:44] responsibility to protect that is not going to change whether you are a kernel or a major or a [01:27:50] whatever rank you are in but a kernel is going to give down the order order is going to pass [01:27:58] that's what is happening from this kernel to the system call system call creates the process now [01:28:05] if you are coming back to this the system call is coming towards the kernel kernel can use the [01:28:11] system call, and system call also can communicate with the kernel. [01:28:15] It's a two-way process. [01:28:17] Now, when it comes to the memory, for example, the memory can be accessed only by the system [01:28:24] call. [01:28:25] So if kernel wants, then it will put the system call, and system call will access the memory. [01:28:30] Kernel cannot access the memory directly. [01:28:33] Only system calls can create the process, and the process can get the resources. [01:28:38] If you can understand these three steps clearly, [01:28:43] then if kernel wants memory, [01:28:46] kernel's job is memory management. [01:28:49] But kernel also requires memory to function, [01:28:52] like how kernel also requires a hard disk to function. [01:28:56] Kernel also requires some memory to function. [01:28:58] So if kernel wants memory, [01:29:00] then it will go through system call. [01:29:02] System call will create a process. [01:29:03] Process will get the results. [01:29:05] And now, on the other hand, [01:29:07] hand, if it wants the status [01:29:09] of the memory, again, it goes [01:29:11] via system call only. [01:29:13] The kernel, it is not [01:29:15] that the kernel will have a direct access [01:29:16] to the hardware resource. [01:29:18] No, it cannot. [01:29:21] This is strict [01:29:23] from kernel to system. [01:29:25] If you want resource, you have to go through [01:29:27] kernel. Kernel will ask [01:29:29] system calls. System calls [01:29:31] will create processes. [01:29:33] Processes [01:29:34] will get the resource. [01:29:37] Once it gets the resource, the scheduling, when will you get it? [01:29:42] Now it is allowed to create. [01:29:44] The process state will be in ready. [01:29:46] And then the scheduling will happen. [01:29:48] Then the process will get executed. [01:29:51] Exit. [01:29:51] Then this response will go back to the process directly. [01:29:56] The status is just one of the steps while traveling forward. [01:30:02] But for exited processes, the response will go from process. [01:30:08] The process will give it to the application directly. [01:30:10] It need not have to go to system call. [01:30:12] Only if you require resource, it has to come to system call. [01:30:17] In the return path from the process to the application, it will go directly. [01:30:22] Because the process and the process ID and the application mapping will be there, [01:30:26] this process will respond back. [01:30:28] That's why you are getting your file open faster. [01:30:31] if it again goes via system call to kernel to application [01:30:35] then it will take even more longer [01:30:38] that's fine sir like this system code this flow diagram i was able to get it [01:30:43] but the system call when it comes again to the next slide in between the user [01:30:47] mode and the kernel mode that way it could get me confused again [01:30:50] the user is here on this side i have not represented the user up here [01:30:54] the user is somewhere here so system call [01:31:00] can call like how the process can call the user application directly system also system call also [01:31:06] can reach the application kernel also can reach the application application can reach only kernel [01:31:12] make sense okay makes sense okay anything else from anyone before we move ahead okay guys so [01:31:28] So it's going to be 3.40. [01:31:31] Let's have a break now. [01:31:36] But before taking the break, there are a couple of questions. [01:31:39] Satyendra, I'm giving you, I'm allowing your mic. [01:31:43] Yes, please go ahead. [01:31:46] I think it is answered sideways around the system call. [01:31:49] I am just narrating what I understood. [01:31:51] I think system call is an interface for application and kernel booth. [01:31:55] That's right. [01:31:58] Okay, great. [01:32:00] fine so that is i will lower your hand uh bikish bikish [01:32:16] okay if you are talking bikish then you are on mute sorry sir i was on mute [01:32:29] sir i have a question around this call between system calls and kernel so as you mentioned that [01:32:38] it's a one directional so we we have to have some resources if we need resources then we have to [01:32:45] make the system call and that system call will go to the kernel it will get the resources from [01:32:52] hardware and eventually it will start the process but isn't it a bi-directional let's say i opened [01:33:02] a process i mean i'm executing a program and that requires some more resources initially when i [01:33:09] started it uh it required lesser memory uh but down the line uh it it scaled up and it requires [01:33:17] more memory so in that case the call will go to kernel again in order to request more resources [01:33:25] from the hardware right okay this is a little tricky question thank you very much for asking [01:33:35] this okay so now you are running an application and the application got the memory and it is [01:33:41] executing now there is a scale up happening because of the traffic it requires more memory [01:33:48] your application requires more memory. [01:33:52] Now, there are already processes that are running. [01:34:01] Those processes have got the memory. [01:34:05] Now, as and when the processes are completed, [01:34:08] the memory will be released [01:34:09] and the new processes will get the memory. [01:34:13] When the traffic is more, [01:34:15] the moment we say we require more resources, [01:34:17] does that exactly means we have created more processes. [01:34:23] The moment we say that we need more memory, [01:34:26] or when we say that we are utilizing more memory than normal, [01:34:31] that means we have created more processes than normal. [01:34:36] Because resources are allocated only to the process, [01:34:41] not to your application. [01:34:43] but now if your application getting a request your application if you are a developer of that [01:34:52] application then in case if you are receiving 10 sorry 10 requests per second for that you [01:34:59] have written the application suddenly if there are 100 requests per second is coming [01:35:04] now the application also will go only for 10 requests per second the queues the request will [01:35:12] be queuing at the application end. [01:35:14] It's not about only the resources, [01:35:16] even the application design plays the role to [01:35:19] accept more requests and only if application requests, [01:35:24] process will be created and process is created, [01:35:27] the memory will be allocated to it. [01:35:30] The user request coming via the application, [01:35:33] application giving it to kernel, [01:35:35] kernel giving it a system call. [01:35:37] Now instead of asking kernel to create 10 processes, [01:35:42] that means 10 requests now the application is going to say 100 requests kernel will say okay [01:35:51] 100 000 what difference it makes if i have resource i will create the process and give it to you if i [01:35:58] don't have the resource i will create the process and i'll put the process in wait [01:36:01] whenever resource gets free this process will get that resource and it can process [01:36:07] so that is how the kernel works that's why it is all independent job but linked it together [01:36:15] okay so that is how it goes suppose if the request number of request has come down in the [01:36:23] application the request from the application to the kernel also will go down if that goes down [01:36:29] the number of processes will go down the number of processes are going down then the resource [01:36:34] utilization will also go down. [01:36:37] So all these processes are related to your application, [01:36:41] so the cumulative utilization only is coming to your application. [01:36:45] Suppose if your application creates some 155 processes, [01:36:48] if all the 155 processes is using around 25 percent of the memory, [01:36:53] that means your 155 processes is using that memory. [01:37:00] When that 155 comes down to 145, you will see the 25 coming to 23. [01:37:06] 145 comes to 100, the 23 will go down to... [01:37:10] Basically, it's the number of processes and number of threads. [01:37:14] Even threads also can be controlled from the application. [01:37:19] So that way it works. [01:37:21] So, sir, basically you're saying that let's say the process... [01:37:27] If we are adding more process to an application, [01:37:29] then we need more resources right and that interaction between the user applications [01:37:38] and the kernel will be bi-directional it's not one-way call so as and when the resource [01:37:45] requirement is getting increased then it will go go to kernel ask for more resources [01:37:53] and accordingly the kernel will allocate the resources to the user for running the application [01:37:59] right if okay in that in that perspective it is one way your application is requesting the kernel [01:38:06] kernel is initiating a system call system call will initiate a process process will get a process id [01:38:12] and the process will become ready once the process becomes ready if the research is available [01:38:18] immediately it will be allocated and the response will come back to the system call and system call [01:38:23] and we'll give it to user application directly. [01:38:26] Sorry, the process. [01:38:28] It will not even go to system call. [01:38:30] So the process will give it to the application directly. [01:38:35] Why there is a communication between user mode? [01:38:39] It is not user application. [01:38:41] If you look at the presentation, [01:38:43] it is kernel mode and user mode. [01:38:47] What is that user mode and kernel mode? [01:38:49] The request for the operations that is coming from the user application is the user mode. [01:38:55] It will still run as in the user mode only. [01:38:59] Suppose if I have logged in in my system as my name, that process will run in my name only. [01:39:07] It will not go into the kernel name. [01:39:10] But when the resource is getting allocated, it will be created by the kernel. [01:39:16] Then only the resource will get allocated. [01:39:18] So it will be accounted to me, but it will be allocated. [01:39:23] The process will get the resource only if it is run by the system call. [01:39:28] So at some point of time, my request needs to get converted into the kernel mode [01:39:35] because I need resource for my application. [01:39:38] I don't have access to memory, but my application needs memory. [01:39:43] So the user mode, until it reaches the system call, [01:39:48] how it gets converted into the kernel mode [01:39:50] so that it can get the memory through the system call. [01:39:56] Even user mode also cannot access kernel directly. [01:40:01] If you are a root user, [01:40:02] then probably you know how to access and read the kernel. [01:40:07] You can do that. [01:40:08] But otherwise, no access to kernel for any application. [01:40:14] One more doubt. [01:40:15] so when we say more resources uh means more processes right that's right okay so let's say [01:40:25] as you cited one example of opening the word document so let's say i have an existing word [01:40:31] document that contains some of some some data in it and i opened it so initially it started with [01:40:38] one process and later on i edited that document and i added more data to that word document [01:40:46] so does that mean it will require more processes because we we have added data in that document [01:40:53] that's what see the process is okay the word document process once it is completed it will [01:41:02] exit process won't continue to run except for your word executable file your data will be in the [01:41:10] memory in whatever is shown in the screen is the active memory now if you scroll down then it has [01:41:18] to fetch the data from the hard disk to the memory to your display it's not that the entire word [01:41:26] document is loaded into the memory that's not the way it works that's where this memory swap [01:41:33] works in that manner. [01:41:37] Probably it loads [01:41:38] like three pages or four pages. [01:41:40] You can scroll. And sometimes [01:41:42] if you look at it, the scroll down, scroll up [01:41:44] is going to be a little slower for you [01:41:46] because it is paging. [01:41:47] Paging means it is swapping [01:41:50] between the hard disk and the memory [01:41:51] to bring it onto your console. [01:41:54] So you will see it a little slower. [01:41:57] Now, [01:42:00] when it is [01:42:00] paging, [01:42:02] at that point of time it requires a process it requires resource because temporarily it has to [01:42:10] store it in the memory before displaying to the screen so your process will be created by the [01:42:16] system call it will get a process id it will go read from the disk put it in the ram and it will [01:42:22] close now winword.exe will pick it from the ram and then show it on your screen so that is the [01:42:31] process it goes through. The moment it [01:42:34] comes into the run, the process is [01:42:35] exact. It won't run [01:42:37] anymore. Continuously, you'll [01:42:39] see only winword.exe, that is the process [01:42:42] which will be running [01:42:42] continuously until you close the word file. [01:42:48] Right. [01:42:49] Okay. Thank you. [01:42:52] And sir, I have [01:42:53] one request. Maybe in the next [01:42:55] class, in [01:42:57] lab section, if [01:42:59] we could have a Python [01:43:01] program getting executed [01:43:02] and passing through [01:43:04] each of these component [01:43:06] if you could visually show us [01:43:09] so that we will get more clarity [01:43:11] that how each of these components [01:43:13] interact with each other [01:43:15] we will do that [01:43:17] okay okay thank you [01:43:19] cool [01:43:21] okay let's take a break [01:43:25] it's like 3.50 [01:43:26] at this point of time [01:43:28] no worries guys I'll come up and [01:43:30] take your queries before proceeding [01:43:32] further we might probably miss some demonstration which we can continue next Saturday so no worries [01:43:43] but you guys should not have any queries or questions for what we are covering here that [01:43:50] is more important I'll take up your queries I will do that assignment to Manish as I said [01:44:01] i'll get it done before tuesday and when will they open is basically it's up to the operations team [01:44:09] they will open it up and make it available for two weeks ppt slides and all i will do it yeah [01:44:16] last week i missed it we missed the class also sunday so i'll i'll upload it by end of the day [01:44:26] today everything so what do you mean by recordings are distorted that means the recording is not [01:44:35] happening properly or we are missing the recordings netish okay let's take like 15 minutes time [01:44:54] missing recording sir missing recording i'll just see what is i just tried to see what is missing [01:45:01] I'm not able to access the recording. [01:45:04] Before closing today's clash, [01:45:06] I want one of you to share the screen and show [01:45:08] if you are able to access the recording. [01:45:11] Well, I just wanted to see what is missing [01:45:13] so that I can record it offline and make it available. [01:45:16] That was my intention. [01:45:21] Any which way. [01:45:22] We'll catch up after 15 minutes. [01:45:24] I'll take a timer. [01:45:27] That is just an indicator. [01:45:29] Plus or minus, I'll be back. [01:45:31] hi guys i'm back am i audible can one of you confirm please okay great thank you i'll take [02:07:41] all your queries just keep your hands raised uh okay let me take the questions now itself before [02:07:48] moving krishna i have allowed your mic hi sir good evening [02:07:58] sir my query is here although as we know canal is the core component of the operating system [02:08:04] and it is we can say that uh kernel is the interface between the uh hardware and the [02:08:10] operating system so uh whatever the uh instructions will become from the system space [02:08:18] sorry user space to the system space so kernel will take it as a uh when it will [02:08:23] through the driver when it will come to the kernel kernel will interact with the former of the [02:08:28] hardware correct sir so uh through the system calls so whenever it will uh means uh uh any [02:08:37] systems calls will be happen so mostly what kind of what kind of instruction within the systems [02:08:44] calls it will be having okay type of calls am i right uh yes sir somehow exactly means the [02:08:53] we are going to see that next krishna we will discuss that and still if you have a query you [02:09:00] can raise it krishna are we good uh sure sir norris yeah it's okay sure uh pritam i'm enabling [02:09:09] your allah among your mic sir uh sometime before break you mentioned one uh thing the one you one [02:09:20] example you given that the uh there's a doc document which will get we are updating writing [02:09:27] in something on that so um the the process id will not written for entire duration once the [02:09:34] the memory or uh process get assigned uh by the uh sorry the system call the eruptor process id [02:09:43] get released so my question is if process actually get released then uh in between there is a contest [02:09:50] switch or something happened then how the uh this process id retain so that another process is in [02:09:57] the waiting waiting state cannot execute the critical section until unless that process [02:10:02] completely get over okay the process id will be released only if the process comes to the exit [02:10:08] state if it is in the waiting state still that process id will be retained only if the process [02:10:15] comes to the exit state that means the process is completed totally there is no swapping anymore [02:10:21] required switching anymore required then the process id will be released until then process [02:10:27] also will not get the exit state but sir if the process a primitive process where the [02:10:34] context switching happens very frequently so how the system care call knows that [02:10:41] the system has to and the process id should be in the waiting state [02:10:45] or it should be sustained like that or it should be get released okay you are taking the example of [02:10:52] a printing am i right yes sir for example okay so now my application allowed me to take a printout [02:10:59] of my bank statement let us take that as an example example now i have just asked the hdfc [02:11:07] bank website to give a printout of last three months statement so it is of some seven or eight [02:11:14] pages of pdf file which is supposed to be printed now the printing request will get a process id [02:11:23] that printing request once through the system call once it gets a process id [02:11:28] until the printing is completed, [02:11:31] all the seven pages of printing is completed, [02:11:34] this process ID will not get an exit state. [02:11:38] So now when the request has gone for the printing, [02:11:42] now the content needs to come to the printer. [02:11:44] The request itself is not the content. [02:11:47] Request is only a request of printing, [02:11:49] and now the content will be in the memory. [02:11:53] Now printing is initiated through the system call. [02:11:58] process ID, let us assume 5273. [02:12:01] Now, the content needs to be picked from [02:12:04] the memory to the printer memory. [02:12:07] For that, this process ID will create a child process, [02:12:11] which will move the content [02:12:13] from memory to the printer memory. [02:12:17] If it has to send the content five times or six times, [02:12:21] depending upon the buffer size, it will do that job. [02:12:26] So the parent ID will still be in the wait state. [02:12:29] It will not have any resources. [02:12:32] But the child process, let us assume that it got an ID of 5279. [02:12:37] Parent is 5273. [02:12:39] Child is 5279. [02:12:41] Now the 5279 is the actual process that is happening at this point of time. [02:12:46] 5273 will be in the wait state. [02:12:48] So the release, whatever resources assigned to 5273 will be released. [02:12:54] 5271 will get a fresh resource. [02:12:56] It will move the file from the memory to the printer memory. [02:13:00] Once it is printer, confirms back that it has taken the data and it will print. [02:13:06] Now 5279 will get an exit status. [02:13:09] Then the resources of 5279 will be released. [02:13:12] Once 5279 comes out of child process, once it exits, [02:13:17] exits means process ID also is released. [02:13:21] Now the 5273 process will see is there anything else for me to do. [02:13:25] If there is nothing else to do except for giving a confirmation to the user that your printing process is completed, [02:13:33] for that, the resource will be allocated to 5273. [02:13:36] Once that communication to the user has gone, that your content is printed, 5273 also comes to the exit state, [02:13:46] then the process will be released. [02:13:49] Process ID also will be released. [02:13:52] Does it clear? [02:13:53] Yes, sir. [02:13:55] Thank you, Professor. [02:13:55] except for [02:13:58] wait and ready [02:13:59] only the running processes [02:14:03] will get the resources [02:14:05] wait and ready all the resources [02:14:07] will be released moment it has [02:14:09] to resume either from ready [02:14:11] or wait again the resource [02:14:13] will get allocated to it [02:14:15] that is how it works [02:14:17] but sir whenever there is frequent [02:14:20] contest which happens [02:14:21] so this [02:14:23] it will be in the wait only [02:14:25] You know, see, suppose if the switch is happening, the contact switch happened between 5273 and 5279. [02:14:33] So the 5273 is in the waiting state only. [02:14:36] That has not attained the exit state yet. [02:14:39] It did not hand over the job to 5279. [02:14:42] It has just delegated the job to 5279. [02:14:45] Until 5279 is completed, 5273 also will be in the waiting state only. [02:14:51] But, sir, during this process, if suppose that whatever the memory or RAM is allocated to that particular process, is required RAM is more than whatever RAM is assigned to my virtual machine or whatever system I have, in that case, whether system will get crass or my process will completely get crass? [02:15:18] That's where the paging comes into the picture. [02:15:21] The paging will happen between memory and disk. [02:15:27] Okay, so whatever memory you have left out, [02:15:32] only that much content will be taken from the disk to the RAM [02:15:35] and then to the printer. [02:15:37] That's why I gave you an example of seven pages printout [02:15:40] of three months transaction. [02:15:42] It may not load all the seven pages at a time. [02:15:46] It may allocate a memory probably around like, you know, [02:15:49] 4 MB or 5 MB. [02:15:50] if that 4MB is only for 4 pages [02:15:53] it will load only 4 pages [02:15:54] once that 4 pages goes to the printer [02:15:57] another 3 pages will come to the memory [02:15:59] and it will go to the printer [02:16:00] that paging process will happen between [02:16:03] memory and hard disk [02:16:05] got it sir [02:16:08] thank you very much sir [02:16:10] ok cool [02:16:11] Varun [02:16:14] I have enabled your mic [02:16:20] Varun [02:16:21] sir I have only one question [02:16:26] can we see the process is in the user mode or a system mode by any chance by any log something [02:16:32] like that definitely yes we can see that uh we will see that in our lab session next week [02:16:38] and there was a request for the python also right program so i'll combine these two in a single [02:16:44] program and we will be able to see okay cool any other queries from anyone no okay everyone only [02:16:54] asked that question did i leave any questions unanswered i see python program execution from [02:17:00] narayan vitoba thank you very much uh current recordings oh okay i could see the current [02:17:10] recordings but it i'm not able to see this in my login i need to actually check with my coordinator [02:17:18] and uh okay assignment one fs fcs theory lab.xlx i will be removing please do not refer uh that is [02:17:29] only for them to share uh from my end to them i shared it i will be removing i was not aware that [02:17:37] i can directly put the assignments now that i am aware i will be putting the assignments directly [02:17:42] into the system okay fair enough anything else bias i think mohita's answered satya's query [02:17:51] okay cool now let me go back and share mine so system calls [02:18:04] there are different kinds of system calls that kernel can initiate one is the process control [02:18:16] What is the process control? [02:18:19] Whatever we were discussing until now. [02:18:23] That is, forking is nothing but creating. [02:18:26] We saw the example of 5473 and 5479. [02:18:31] So 5473 creating a new process of 5479, which is sub-process, that process is called as forking. [02:18:41] Forking means creating. [02:18:43] Now, once the process is created, the ID will be assigned to it, [02:18:48] and then it will be moved to the ready status. [02:18:53] Ready status is nothing but waiting for the resources. [02:18:56] Ready indicates the system, the resources, [02:19:03] that the process is ready to execute and waiting for resources. [02:19:09] So anything which is in the ready state or in the wait state. [02:19:14] Wait state is nothing but probably some processes completed, [02:19:18] but there is something more to do, but not at this point of time. [02:19:23] So the process will go into the wait. [02:19:25] So the wait and the fork that is ready is the one which will be looking for resources. [02:19:33] To them only the resources will get assigned to. [02:19:36] execution is nothing but a running status resources are assigned to the process and the [02:19:43] process is started and it is running once that running is completed there is nothing more to do [02:19:51] for that process it doesn't require any more resources then the process will exit this is [02:19:57] called process control this is one group of system calls the second group of system calls is file [02:20:05] management. Basically, interaction with the hard disk. So if your process requires the resource [02:20:15] hard disk, whether it is data reading, data writing, data opening, or data closure, for example, [02:20:24] database. Now, your application, the user has entered all the details and they say click on [02:20:31] the save now the moment they click on the save the application receives the acceptance from the [02:20:38] user the application is going to give that request to the kernel kernel will create a system call [02:20:44] now this system call is save that is write so it will create a write [02:20:51] control and that write process will get the id and then what is the resource it needs to get [02:20:59] It requires some RAM. [02:21:01] That RAM will have the data. [02:21:04] Now from the RAM to disk directly, this process will move the data. [02:21:09] While typing, that was kept in the RAM. [02:21:13] While clicking on the save, it is movement from the memory to the hard disk. [02:21:18] Now the system call will go for a write. [02:21:20] Write more from RAM to hard disk. [02:21:24] Once that is done, the application receives the confirmation that the database is updated. [02:21:30] Now the page refreshes, it gives a message. [02:21:34] Your data is saved. [02:21:36] Now, once that message comes back to the user, [02:21:39] then this loop will be given with a closure request. [02:21:44] What closure request? [02:21:46] The database will be closed [02:21:47] because the database has to be closed [02:21:50] upon confirmation about the user. [02:21:53] User confirmation we have given, [02:21:55] so it will close the database for that particular transaction. [02:21:59] Like this, there could be 1,000 threads that might be going to the database. [02:22:04] But this thread will be closed. [02:22:07] The moment another request comes, the same thread will be open. [02:22:11] Red, right, close. [02:22:13] That operation, that file management. [02:22:16] I gave an example of a database. [02:22:19] But it can be just a flat file. [02:22:20] Your application is trying to write logs. [02:22:24] Application logs, transaction logs, system logs. [02:22:28] all of them are written into the flat file, the text file, in text format or comma format, [02:22:35] whatever it is. For that, every time the file is getting opened, appended, closed. Open, [02:22:42] append, close. Open, append, close. Append is nothing but a writing. Writing, [02:22:47] no modifications, add. That's what it means, append. Append is also a write operation. [02:22:52] So it will open, write, close. Open, write, close. Every log, it will do that cycle. [02:22:58] To do this cycle, there are two things that will happen. [02:23:01] One is the process, process ID, resources, thread opening to the file, [02:23:06] because that's a hard disk request. [02:23:09] And then file management, it will open up the thread, read, write, close. [02:23:14] That cycle will happen. [02:23:16] The third type of system calls is only for the memory. [02:23:21] Break means basically it will break the resources and still wait. [02:23:26] The application will wait. [02:23:27] Maybe it has to wait for another input to actually do another operation. [02:23:34] So that break, M-MAP. [02:23:38] Another one is the communication. [02:23:40] Basically, the sockets, the pipes between the network interface to the internet. [02:23:49] Your laptop to the Wi-Fi. [02:23:52] Your Wi-Fi to the service provider. [02:23:56] Suppose if you are trying to access the AWS console, [02:24:02] the AWS console response has to come from the AWS cloud environment. [02:24:06] Now, in your browser, you are typing AWS sign-in. [02:24:11] Now, you are giving your credentials saying OK. [02:24:14] This OK is accepted in your laptop, in your browser. [02:24:19] Now, the browser will go via the network interface card, [02:24:23] so that socket will be opened. [02:24:25] This is another type of system calls. [02:24:29] And something related to information, it's only read only. [02:24:33] For example, you wanted to know the name of the Linux server [02:24:36] in which you have hosted the application. [02:24:40] You give a Unix command, uname-a. [02:24:44] This is also a system call. [02:24:47] Anything you do gets converted to the system call post-kernel. [02:24:51] and then that will give back [02:24:53] response to you as a user. [02:24:57] So that is [02:24:58] another group. This information [02:24:59] system calls are all maximum [02:25:02] read only. There is no [02:25:03] writing, there is no modification, there is no [02:25:06] removal. [02:25:08] Unless you give the system log [02:25:09] to be deleted, [02:25:11] that is file management call. [02:25:14] But it will go [02:25:16] via the communication only. [02:25:17] There will be a socket created [02:25:19] through that the communication will happen once that communication reaches the other end [02:25:24] then the file management will be opened by the kernel in the target host so that is how any [02:25:32] system the system calls these five categories if you are aware of then you have a very decent [02:25:41] understanding about the kernel functioning you if you are able to map okay for this is the request [02:25:48] I made as a user and this is what the kernel is going to make a system call. [02:25:53] If that mapping, if you are able to make it, [02:25:56] then you have a very decent understanding about the kernel. [02:26:00] To have the decent understanding, [02:26:02] these five categories is more than sufficient. [02:26:05] These five categories will cover almost like 40 percent of the kernel functioning. [02:26:10] As long as you are not a system administrator, [02:26:13] This 40%, if you are able to gain knowledge about, [02:26:18] that's more than sufficient for you. [02:26:21] But if you are a system admin, [02:26:23] then you need to understand more system calls, [02:26:26] type of system calls, [02:26:27] because you'll be administering the system. [02:26:30] For example, protocols. [02:26:32] Based on the protocols, the communication will be opened up. [02:26:36] If you have a VPN, [02:26:39] that's also through the sockets only, [02:26:41] but the type of socket is different. [02:26:43] Suppose if you are calling for your voice, the bandwidth that it needs to give for a voice call is more compared to a data call. [02:26:57] Now, the data call requires very less bandwidth. [02:27:00] Voice call requires more bandwidth. [02:27:03] So how is that handled? [02:27:05] And as an administrator, those type of system calls are something different. [02:27:10] that doesn't come under either any of these but those calls will come after [02:27:16] these calls. Suppose if I want to transfer data from my laptop to the AWS S3 [02:27:22] now it is a data transfer call. It may look like a file management but it is a [02:27:30] file management of the AWS EC2 or the S3 bucket but between me and the S3 [02:27:37] bucket, it is a data transfer socket. [02:27:41] A socket will be established between my laptop [02:27:43] onto the S3 data will be transferred. [02:27:45] After that, the file management system call will be [02:27:49] done by the AWS system where the S3 bucket is there. [02:27:55] If you're able to understand this flow very clearly, [02:28:00] then you have a very clear understanding [02:28:03] about how the kernel handles our user request. [02:28:07] between the kernel mode. [02:28:09] Kernel mode is different, kernel request is different. [02:28:13] Both are two different things. [02:28:16] Kernel mode means the action that is being taken [02:28:20] has the privilege of the kernel, [02:28:24] because kernel has full privilege, like a root user. [02:28:27] With kernel privilege, you can do the action. [02:28:31] Same action can be done with a user mode also. [02:28:35] Somewhere it gets collided or converted. [02:28:41] It will be only these two. [02:28:43] User mode is either converted as a kernel mode, [02:28:46] and it is happening at the hardware level, [02:28:49] or the user mode colliding with the kernel mode, [02:28:54] and it will act only as a user mode, [02:28:57] but performed by the kernel. [02:28:59] This is what is the exact difference. [02:29:02] All the actions are taken by kernel only, [02:29:05] but when kernel is acting, [02:29:07] whether it is acting as a root user or whether it is acting as a normal user, [02:29:12] that is what the difference between user mode and the kernel mode. [02:29:16] Between the user mode and the kernel mode, [02:29:18] if kernel has to do a user mode, [02:29:21] then it will create a system call. [02:29:23] It has to create a system call. [02:29:25] Without system call, nothing will happen. [02:29:28] So kernel will ask for a system call, [02:29:30] and system call will open it while opening it. [02:29:33] By default, system calls are open with kernel mode. [02:29:37] If it is to be done with the user mode, [02:29:39] kernel will say, I'm not the one who is executing. [02:29:42] User is the one who is executing. [02:29:44] So create the process in the username. [02:29:48] Now, if you go and see in the servers, [02:29:51] there are certain processes which will be in the root, [02:29:54] administrative, whoever it is. [02:29:56] and there are certain processes will be in the application name. [02:30:00] The application which has got [02:30:03] the application name as the mode is the user mode. [02:30:07] Kernel only is acting, [02:30:09] but it will not give its privilege to the application. [02:30:14] But if it is a kernel action, [02:30:17] those things will be done by the kernel mode. [02:30:20] That is the difference between the kernel mode and the user mode. [02:30:26] The user space restricted access, [02:30:30] and generally it will be any of these applications only, [02:30:34] and kernel mode will have full access over these. [02:30:39] User mode will not have access to any of these directly. [02:30:43] Then it goes via the kernel only through the system call. [02:30:47] Even user space to make a system call to get into the hardware. [02:30:51] That is what a little bit confusion hope it is clarified now. [02:31:00] If you understand this box, the privilege boundary, [02:31:05] it separates the user mode and kernel mode for sure. [02:31:09] Crossing this boundary changes [02:31:11] the CPU from user mode to kernel mode. [02:31:14] Your Chrome, your request coming back, [02:31:16] once it crosses this privilege, [02:31:19] gets into the kernel mode while [02:31:20] acting in the memory or process. [02:31:23] When it crossing this boundary, [02:31:25] the system call will change it to the user mode and give it to [02:31:27] the user space which is nothing but your chrome or python or shell program or c program whatever [02:31:35] it is so this this is where the system call plays a role between kernel and user system call also [02:31:45] plays a role from kernel to the hardware both ways it works now anatomy of the process [02:31:56] very very important [02:31:58] another 10 minutes [02:31:59] just [02:32:00] give a focus [02:32:02] I'll go [02:32:05] I'll try to go a little slow [02:32:06] but this is [02:32:07] very very important [02:32:09] just give me a minute [02:32:13] please [02:32:13] little [02:33:00] not [02:33:06] cooperating [02:33:11] maybe because too many [02:33:12] questions [02:33:15] possible [02:33:16] okay no problem [02:33:18] So now, let us look at this anatomy. [02:33:26] So now, let us say I open Chrome, Python, and a terminal on my computer, all the three. [02:33:39] And how does this operating system know these are three different processes? [02:33:50] Because they are different programs, could be one reason. [02:33:53] that is partially [02:33:56] correct, but that's [02:33:58] not enough. [02:34:00] What if I open Chrome [02:34:02] twice? [02:34:04] Will it get [02:34:05] the same? No. [02:34:10] Though they are based [02:34:11] on the same application, [02:34:13] how does the operating system [02:34:15] distinguish them? [02:34:17] In one of the tabs in the Chrome, [02:34:20] you have your email. [02:34:22] On the another, [02:34:23] you have your AI [02:34:25] tool. Now, whatever [02:34:27] you are putting into the AI tool [02:34:29] is supposed [02:34:31] to come back into the tab [02:34:33] where the AI tool is running. [02:34:35] Could be that GPT [02:34:37] or anything that you use. [02:34:40] And I don't want [02:34:41] that response to go back to the [02:34:43] main tab. [02:34:46] So how the operating system [02:34:47] gets it? [02:34:51] The operating system needs a [02:34:52] complete representation of [02:34:54] every running process. [02:34:57] It needs to know who the process is, [02:35:00] what it is executing, [02:35:02] where its memory is, [02:35:04] what resources it wants, [02:35:07] how it should be scheduled, [02:35:09] and how it is related to other processes. [02:35:14] That's where exactly this comes into the picture. [02:35:19] Now, think of this box as an operating systems [02:35:23] management view of a process. [02:35:26] It is a management view of a single process. [02:35:31] I am intentionally using this as a conceptual model. [02:35:35] In real operating system, this information is distributed across several kernel data structure. [02:35:42] Kernel has its own data structures, and it will be split in those data structures. [02:35:48] For example, the PCB contains process management information. [02:35:56] while memory management structures describe the process address space. [02:36:02] The memory is different, [02:36:04] process management is different, [02:36:06] it has its own data structure will store in different areas. [02:36:10] But conceptually, this is the information the operating system [02:36:14] needs in order to manage the process. [02:36:17] First is the process ID. [02:36:20] Suppose I have 200 processes running. [02:36:23] How does the operating system identify one particular process? [02:36:28] That is using a process ID. [02:36:31] Now, this process ID is unique. [02:36:35] The process ID for the Chrome can be 101. [02:36:39] For terminal, it could be 102. [02:36:42] And for the Python program that I am running, it could be 103. [02:36:47] Now, the PID is essentially the process's identity [02:36:50] from the operating system perspective. [02:36:53] It has no visibility to anything else [02:36:58] except for the operating system, the process ID. [02:37:01] So PID does not mean the program name. [02:37:05] For example, if you are running, [02:37:08] I said we have opened two tabs in the same Chrome. [02:37:13] One is Gmail and another one is your AI tool. [02:37:20] These two will have two different process IDs actually [02:37:22] in the background. [02:37:25] So, if you have opened another two tabs, then it will create four process IDs. [02:37:32] Now, it will be able to identify which process belongs to whom. [02:37:38] That is established with the process ID. [02:37:43] Now, the program counter. [02:37:46] This is the address of the next instruction. [02:37:50] So, this program counter will contain the process ID. [02:37:54] Basically, this process ID is in the queue [02:37:56] to be processed next. [02:37:59] That is what the program counter. [02:38:01] Now, suppose the CPU is executing a process currently. [02:38:05] The process has thousands or millions of instructions. [02:38:09] How does the CPU know which instruction to execute next? [02:38:14] The CPU has a program counter. [02:38:16] We saw this. [02:38:18] We discussed it in detail. [02:38:20] Now, this program counter will have the list of instructions [02:38:23] of that particular process. [02:38:26] The program counter identifies the location [02:38:28] of the next instruction to execute. [02:38:32] Subject to the architecture's exact execution semantics. [02:38:38] Keeping that away, it will have the address [02:38:40] of the next executable instruction. [02:38:45] Suppose if you are holding up an imaginary book, [02:38:49] imagine I'm reading a 500-page book. [02:38:52] I stop at 217. [02:38:55] If I come back tomorrow, how do I know where to continue? [02:39:01] Answer is bookmark. [02:39:03] So I will have a bookmark on page number 217, [02:39:06] which will tell me that I need to continue from there. [02:39:10] Now a process needs its execution bookmark. [02:39:15] And that bookmark is the program counter. [02:39:20] Now the CPU may temporarily hold values in register. [02:39:24] we have seen that in the addition process it held the value in the register it did not go to memory [02:39:35] the registers are extremely fast storage locations we saw we differentiated the [02:39:40] different types of storages and registers are the fastest because it is inside the cpu now [02:39:51] Now, there are different type of registers, general purpose registers, program counter [02:39:59] is also one of the register, tag pointer, status or flag, all those things we saw. [02:40:07] Now, imagine process A is running, now the operating system wants process B also to run. [02:40:18] The operating system simply start executing process B, answer is no. [02:40:25] Because when process A eventually runs again, it needs to continue with its previous execution [02:40:32] content or the context, both. [02:40:36] So process A, value is registered in the PC, that is program counter, plus other CPU states, [02:40:49] everything is stored. [02:40:51] Now the process B is running. [02:40:55] process B is running once it is completed it will save the B's context and in between if the [02:41:06] process A comes to the ready state from the wait state automatically it will give [02:41:13] some resources to the A also that is where you are seeing you are getting a response in all the tabs [02:41:22] in the browser window, the reason is this switching happening between the processes. [02:41:30] And that switching is nothing but the context switching. [02:41:35] And where does the temporary execution information live? [02:41:41] That actually lives in the stack. [02:41:43] It's temporary information. [02:41:47] Every process needs memory for function calls and temporary execution information. [02:41:53] For example, you have written a calculate program and it has a add function within it. [02:42:01] When a function calls another function, the system needs somewhere to maintain information [02:42:07] associated to those calls. [02:42:10] So the stack commonly contains these things, function call frames, local variables, not [02:42:20] global variables, only local variables, save the registers, return addresses. [02:42:26] Suppose if the request has come from outside, it has to be responded back to that address [02:42:32] only. [02:42:33] It will store it in the return address register and when the process is completed, the return [02:42:40] address register will give the target and then it will take the content to that then it goes [02:42:47] where the communication connects builds the pipe sends through somewhere we need to all these are [02:42:56] temporary it's not even milliseconds but still it has to be stored somewhere so that we can recover [02:43:02] it where it is stored it is stored in the stack or the stack of trees you can have a stack or you [02:43:09] can have a tray of stack. It will be stored there. Now, where does the dynamic memory come from? [02:43:20] The memory what you have RAM is a static memory. It's not dynamic. [02:43:25] Now, suppose a program does not know in advance how much memory it will need. You have written [02:43:31] a program it doesn't know how much memory it requires in advance so if you have not allocated [02:43:41] then how will it know so the program can request dynamically allocated memory this memory is [02:43:48] commonly described as coming from the heap you will hear this heap word among the developers [02:43:57] They'll say use the heap memory, stack memory. [02:44:01] Purpose is basically that. [02:44:03] If the program knows how much it needs, it will come from the static memory. [02:44:09] If it has to be allocated dynamically, going to the RAM and coming back is a costly transaction. [02:44:16] So it will provide it from the heap memory. [02:44:21] So how does it know? [02:44:22] So, basically, this m alloc, if you know the C program, or new Python, or suppose if you [02:44:34] are defining a variable as new variable, which is not defined, it's a local variable, then [02:44:40] we expect it to be provided either from the stack or the heap, one of that. [02:44:46] Okay, cool. [02:44:48] The heap is not a hardware component. [02:44:50] it is a region of the process virtual address is virtual like your virtual machine this is also [02:44:59] virtual it is not a actual hardware now program will have the executable instructions right where [02:45:10] the executable instructions come from it is coming from the code now if you say that if x is greater [02:45:17] than 10 display x is more than 10 else display x is less than 10 small program you return [02:45:29] now how will this get translated into the machine instruction because [02:45:35] machine will be able to access only through the machine instruction so it gets translated the [02:45:44] function will get translated which function the calculate function or the display function [02:45:49] the cpu ultimately executes the instruction from this code or the text this is also part of the [02:45:57] process now the data data region contains program data you have allocated a constant variable [02:46:08] and the value for the variable is 10. variable name and the value also is going to get [02:46:17] allocated into the data area is very very internal this is also process is also virtual [02:46:26] not physical will not be able to feel or touch the process you can only [02:46:31] see the process but hard disk memory and all you can touch and feel depending upon how the [02:46:38] variable is declared it may either reside in different parts of the processes address space [02:46:45] The key distinction is that program instructions and program data are different conceptual regions. [02:46:53] Program instructions go to the heap or stack, and the program data come to the code, text or data. [02:47:01] So now, this stack, heap, code, and data are actually together. [02:47:10] The CPU register program counter is actually together. [02:47:14] and process id is an independent this is independent and it is unique all are getting [02:47:20] actually inter related or coordinated between them but all are independent now we have seen [02:47:28] data code text basically program data keep and stack instruction registered in the cpu registry [02:47:39] goes to the program counter and gets into the resources and gets executed now [02:47:46] comes the scheduling credentials and parent child now suppose what happens when a program opens a [02:48:01] file you are given file is equal to open in bracket a report dot txt it's a python line [02:48:08] so the operating system needs to track that the process has opened a file now say a process does [02:48:18] not just consist of cpu instructions and memory it also uses operating system resources so in that [02:48:27] case opening a file is a file management system call and it is on unix or linux the process [02:48:35] typically accesses these through file descriptors. For example, zero is standard in. [02:48:45] That is standard in is nothing but the keyboard or mouse. [02:48:49] Standard out is basically the monitors or printers. If it is an error, [02:48:55] STD error number two, then we have files, [02:49:00] files, folders, those are all denoted by numerical value 3. [02:49:08] And if it is a network related, network sockets pipeline, then it is denoted by 4. [02:49:16] So with this numerical value, we will typically, these are all the file descriptors. [02:49:22] If it says zero, keyboard or memory, sorry, mouse, it will wait for the input. [02:49:30] Two, sorry, one, output to the monitor or printer. [02:49:35] Two, it is standard error. [02:49:37] If something has gone wrong, it wants to write the error message to a file. [02:49:43] Actual user files to be opened. [02:49:45] Something like report.txt or profile.pdf, whatever it is. [02:49:50] So, the number is a handle through which the process refers to an open resource. [02:49:57] If an open resource is there, for example, if your log file is open, and there is a standard [02:50:03] error, then that file will be associated with this descriptor called 2, and until it is [02:50:10] open, it will be described with the type 2. [02:50:14] Now think of the process as a hotel guest. [02:50:18] The hotel gives the guest keys or access card to the resources. [02:50:24] The operating system needs to know which resources the guest currently has access to. [02:50:33] That is where you need to map whatever it is. [02:50:39] There is a room number. [02:50:40] I have got a card. [02:50:41] That card is mapped to the room number, but that card is handed over to me. [02:50:47] Just because it is in my hand, can it open the room? [02:50:50] It has to be configured for that physical room's virtual identity. [02:50:56] Maybe room number is 304. [02:50:59] So that information has to go inside the card. [02:51:03] So there is a chip in the card which will store the number. [02:51:08] And there will be a unique number of the lock that will be stored here. [02:51:12] It has to match. [02:51:14] Then only the lock will open through this card. [02:51:17] And how many times I have opened, how many times I have closed, [02:51:21] That data needs to be stored. [02:51:24] It goes to the central system, but it will go via the network, [02:51:27] wireless, wired network, whichever it is. [02:51:32] So they have all the records. [02:51:36] So if you just try to map that analogy to the different parts of the process, [02:51:44] you'll be able to differentiate what type of process is written in which area [02:51:49] and what type of data is written in which area. [02:51:54] Mostly it will be dynamic. [02:51:56] No static information will be available in any of these resources. [02:52:04] No scheduling. [02:52:04] Swapping is happening. [02:52:06] Scheduling is happening. [02:52:07] Switching is happening. [02:52:10] Where will we store all this information? [02:52:13] This information will be stored by the CPU scheduler [02:52:17] with the priority, scheduling policy, time, slice, state. [02:52:25] Now, when the process is getting created, [02:52:28] all this information will be available to it. [02:52:31] The scheduling policy will give the priority. [02:52:35] The priority will decide the line in the queue, [02:52:40] and it will decide the state of the process also. [02:52:45] And all this information, process, state, priority, scheduling class, [02:52:50] CPU affinity, we can always send a particular process [02:52:56] to a specific core in the CPU. [02:53:00] It is possible. [02:53:01] Any request coming from this application [02:53:04] should be scheduled in the first three cores of the CPU. [02:53:10] Scheduling policy will enable you that. [02:53:13] So more or less, it is sort of a mapping. [02:53:16] If you start mapping, then you will map it [02:53:19] for all the cores, for all the processes. [02:53:22] Generally, whatever we want to assign, we will assign. [02:53:24] Rest, we will keep it as open so that it can take any core. [02:53:31] So that information also is going to help the operating system decide [02:53:35] when and where the process should run. [02:53:39] So there are so many internal policies, internal information, [02:53:46] internal data that needs to be made available to the process. [02:53:50] All this information is going to be attached to the process. [02:53:57] Now, suppose one application is creating three processes. [02:54:02] If you have mapped that application to a specific processor, [02:54:08] a specific CPU itself, [02:54:11] then whichever process getting created from that particular application [02:54:15] will go to that particular CPU core only. [02:54:20] We can make it happen. [02:54:22] For critical applications, for system of calls, it will be by default. [02:54:29] System calls under by default is allocated to a specific CPU core. [02:54:34] That is the reason even if your application hangs, the system is working. [02:54:37] Because your system calls has its own resources allocated within the system. [02:54:44] Though you see that 64 MB RAM is free as of now, it doesn't mean that all 64 MB is free. [02:54:51] Suppose if a system call occupies another 32 MB suddenly, [02:54:55] only 32 MB will be free. [02:54:57] And that 32 MB free also, [02:54:59] if we would have said in the schedule policy, [02:55:01] at any given point of time, [02:55:03] maintain 32 MB free memory. [02:55:06] Now, even though you have 32 MB RAM, [02:55:08] memory free, [02:55:10] your processors will wait for the resource. [02:55:14] Because underlining policy says that [02:55:17] this 32 MB has to be free always. [02:55:20] so that in case if any emergency system calls requires, [02:55:24] it can allocate. [02:55:25] If it allocates all the memory to all the processes, [02:55:28] then system calls will suffer. [02:55:30] If system calls suffer, [02:55:31] then application call also will suffer. [02:55:34] Sometimes you feel that the application is hung. [02:55:39] You press Control-Alt-Delt. [02:55:41] If it is a Windows laptop, [02:55:43] go to the particular process, [02:55:44] end the process, and then you do that, right? [02:55:47] As a user, we used to do that. [02:55:50] What is happening when you are killing the process? [02:55:53] When you're killing the process, it is taken out of the queue. [02:55:56] ID is returned back. [02:55:58] Resources are handed over. [02:56:00] Maybe the process has hung. [02:56:01] It has not released the resources. [02:56:04] You go ahead and you manually release the resources, [02:56:07] release the process ID, [02:56:09] and bring the process into the exit state. [02:56:12] That's all you are trying to do by killing a process [02:56:15] using the task manager. [02:56:21] Finally, credentials. [02:56:24] credentials suppose two processes try to access the same file should both automatically be allowed [02:56:35] if it is reading access by both as we can but the os needs to know otherwise it won't allow [02:56:47] who is the process acting on behalf of and what permissions does it have [02:56:52] That's where exactly these credentials are represented. [02:56:58] It is not stored. [02:56:58] It is a represent information saying that user identity, group identity, privileges, [02:57:06] security context, all those things will be available in this credential layer. [02:57:13] And finally, the parent child information. [02:57:20] We took the example of printing with the 5273 process ID, [02:57:25] creating a sub-process 5 to 7.9. [02:57:28] But how do we know that these two are connected to each other [02:57:31] or related to each other? [02:57:34] That will be available in this parent-child information [02:57:37] of the processes. [02:57:40] Just because I have put along in the same diagram in the rack [02:57:44] doesn't mean that it's a single component. [02:57:48] It is independent components connected to each other. [02:57:53] Now the kernel is going to manage this. [02:57:57] All this will be in the kernel mode, not in the user mode. [02:58:01] User mode cannot access any of this information, [02:58:06] cannot modify any of this information. [02:58:09] So this is the anatomy of the process. [02:58:15] So basically, what we have understood today, [02:58:20] we have understood the complete chain right from [02:58:23] the hardware to the application. [02:58:26] We understood two modes, user mode and the kernel mode. [02:58:31] different types of system calls that a kernel can make, [02:58:35] and the anatomy of the process. [02:58:37] We have just opened up and see the process naked. [02:58:46] This is how it works. [02:58:50] Now, we have understood the kernel, how it works. [02:58:55] Kernel is the core of operating system. [02:58:57] Apart from that, there are other components [02:59:01] in the operating system, but the core is kernel. [02:59:03] You have libraries supporting, for example, you've got a new device. [02:59:11] The device driver is an additional one to the kernel for the operating system. [02:59:17] Like that you can have, but kernel is the heart of the operating system. [02:59:22] Now the kernel with your application and the hardware. [02:59:27] so between the application and the hardware [02:59:30] funnel manages [02:59:32] everything so if we [02:59:36] have understood these three steps [02:59:38] or the three statements [02:59:40] that I made now [02:59:41] we are good [02:59:43] any queries any questions guys [02:59:46] let me stop sharing [02:59:49] okay [02:59:57] deadline for the assignment will be [03:00:04] displayed there only [03:00:05] Ashish [03:00:08] I have allowed your mic [03:00:13] doing sir uh thanks for detailed information regarding the kernels actually my queries with [03:00:22] respect to the gpu kernels um and addressed to the distributed training that we do so uh kind [03:00:29] of trying to understand how the process could be aligned in the back end secondly uh we also know [03:00:36] that there are a couple of ways to actually execute and optimize the we can say kernel programming [03:00:42] in the sense that you can actually optimize the training itself so if you can give the highlights [03:00:48] at two two different questions so that will help okay first let me take the gpu kernel alignment [03:00:57] basically what it refers is optimizing memory access and execution structure the normal cpus [03:01:07] has a structure in which it will execute. [03:01:11] But in terms of GPU kernel alignment, [03:01:13] now the kernel needs to know GPU has a different execution [03:01:18] structure compared to the CPU. [03:01:22] And that is optimized, not only CPU, but also memory, [03:01:29] so that the GPU can read, write, and process data [03:01:32] at maximum speed. [03:01:33] The difference between CPU and GPU [03:01:36] is only the processing speed. [03:01:38] But how the operating system is going to understand that? [03:01:42] Because GPUs rely heavily on massive parallel throughput. [03:01:47] How it is able to achieve the speed? [03:01:49] Instead of 500 threads, it may do 50,000 threads. [03:01:54] The throughput is massive. [03:01:58] And it may have misaligned data or execution paths. [03:02:04] and it will severely bottleneck the performance. [03:02:08] So kernel alignment generally falls in three main categories. [03:02:13] One is memory alignment, [03:02:16] execution alignment, [03:02:19] and track layout, that is data structure layout. [03:02:24] These three, generally, [03:02:27] these three main categories it will fall into. [03:02:30] And this information will be available to be made available to the kernel so that the processing is aligned. [03:02:40] So that is what we mean by GPU kernel alignment. [03:02:44] What was your next question? [03:02:47] So when we say that there is an alignment of a GPU kernel in this sense, [03:02:53] how we can optimize the distributed training while we do with the GPU environment itself? [03:03:00] So, because it happens that when you do this with respect to the CPUs, it has a, you can say, longer amount of duration to do the training itself, where else when you can do the distributed training with the GPU kernels or the GPU environment per se, it refers to have a better or a faster way of the training itself. [03:03:21] so to achieve that there will be also some of the activities that they can do with the kernel [03:03:26] programming so my second question was that if there is a possibility that we can give some light [03:03:31] how we can achieve the better way of distributed training with the gpu kernels and the kernel [03:03:37] programming okay that's a big subject uh anuji you are speaking about how to modify the kernel [03:03:46] Am I right? [03:03:47] Yeah. [03:03:48] I mean, for an initial thing, how the kernel programming is worked upon with respect to [03:03:55] the GPU trainings, the same side. [03:03:58] So kernel programming is also one of the languages. [03:04:02] So if you are a system programmer, then depending upon the kernel, you should know only the [03:04:10] instructions. [03:04:11] Because end of the day, kernel involves an instructions. [03:04:14] The format in which it gives the instruction, that needs to be aligned to the GPU capability. [03:04:22] Now, if it is a CPU, it might create some 22 process for your application. [03:04:30] But if it is a GPU, kernel needs to know, GPU has a major capability upgrade. [03:04:39] So instead of 22 process, I can create 222 processes. [03:04:45] That is all kernel needs to know. [03:04:46] Apart from this, there is nothing to do with the kernel. [03:04:49] It is all with the hardware that we refer as a GPU. [03:04:54] So it's a processing unit. [03:04:56] It will process, but it has to be fed. [03:04:59] That feeding will be done by the kernel. [03:05:01] But generally, kernel will feed based on the CPU data structure. [03:05:06] But if you have a GPU, generally it will get detected. [03:05:09] But if you really want to ensure that it is happening to its capacity, [03:05:13] At that point of time, we will give instruction to the kernel that anything that is going into this GPU can go in this data structure, so many threads and parallelism. [03:05:25] Only that much of information, we will give it to kernel. [03:05:28] We don't give anything more than that. [03:05:30] Once it has that information, while submitting processes to the GPU, it will submit a higher number of processes parallel. [03:05:40] That's all it will do. [03:05:41] but while receiving also [03:05:44] it has to keep itself [03:05:46] you know available [03:05:48] to receive the response [03:05:49] of the process [03:05:51] so that is all it needs to know nothing beyond [03:05:54] that [03:05:55] because while binding [03:05:56] sorry to interrupt you because while binding [03:06:00] when we load any model [03:06:01] that is like even right now I am doing [03:06:03] so when we do something like [03:06:05] something like that which is loaded [03:06:07] between the GPU data [03:06:09] structures it has to go back [03:06:11] with the optimization state as well. [03:06:14] So trying to understand [03:06:15] where and how we can do [03:06:17] that part of optimizations [03:06:19] and what kind of data structure [03:06:21] updates we can work on. [03:06:25] That requires a different session altogether. [03:06:28] Okay, no problem. [03:06:29] I will just drop the question. [03:06:31] No, don't drop the question. You hold it. [03:06:34] I will take it up [03:06:35] sometime. [03:06:37] Okay, thanks. [03:06:40] Anything else from anyone? [03:06:45] Okay, guys, sorry, I just taken 15 minutes. [03:06:47] more thank you very much have a great evening have a great week as well see you again next saturday [03:06:55] take care bye