Operating System Components
Transcript
Hello ji , How are you all? this is Lakshay Welcome to the channel Code help. Today we have reached our lecture no-4 of OS In previous lecture we learned about multi tasking and multi threading 1st of all we studied about types of OS, now lets go in detail , lets studied about its components Components of OS , that OS is made from what If I break OS, there will be two components 1.User space , 2. kernel From user space we can get the idea , that here user apps are executed
The 1st work of OS is that it interact with OS 2. It provides the convenient space to developer so that he/she can run the apps two works Now these two works will be divided logically , user space is the area where user apps are ran Kernel has the access to underline hardware Actually kernel has the hardware access ,and apps will run in the user space So OS components are divided into user space and kernel What is user spacwe?
This video is sponsored by Crio , world leading project driven platform If you are targeting a good job If you want to master development , so Crio is the place for you Here you will get different programs , Full stack development program ,Backend development program The projects that you will make here are of internship level After every program you will have enough projects , your resume will become impress There is a fellowship program also where placement is guaranteed You will be placed in a product based company All program s are available with one week trail There is assured scholarship also If you are interested , I will put link in the description By using this you will get the maximum discount A coupon code is also being displayed on screen By using this also you can get the maximum discount, thankyou User space , it doesn't has the access to hardware space It just provides the convenient environment to user apps
For example , when you on your windows You see the desktop , here it is start , and some icons Whatever you are seeing we call it user space We also call it GUI The user space in Windows and Mac, we can also call it GUI/CLI Actually we call it user space in modern operating system That is GUI / CLI, what is GUI? GUI stands for graphical user interface On which you normally do the work , you have the mouse , you click on an app User directly interact with GUI So that area is GUI
When you run command line interface in windows , as Mac has the terminal and in linux So terminal is your CLI, we call it command line interface In windows there is power shell What is the difference between GUI and CLI? We write some commands in CLI and system takes it and executes it And this way it works The work which GUI do , we can also do it using CLI, lets take one exam If you have to create a new folder , in windows you do right click and then create a new folder
A new folder will be created , similarly you can run a command in CLI and can create more folders For you go to CLI in linux , you can use MKdir command to create a new folder In GUI also you will get the new folder button The new folder button in GUI is being run by MKdir command internally What is MKdir command? it basically internally calls the system, calls It directs file management system to create a directory We can do this through CLI and also through GUI
Where user interacts we call it user space What is the 2nd work of user space ? it interacts with the kernel Till now we have studied OS work is to interact with hardware User doesn't has the direct access to hardware The area where user works , it will go through kernel to access hardware See how much things are layered Its 3rd work is that interacts with kernel Bhaiya what is kernel? Kernel is the heart of OS ,, it is the most important thing It directly interacts with the hardware
User space gives it command , it reads the command , than directs hardware to do the tasks accordingly So in this way things work , user space doesn't has the direct space but kernel has So user space has to request kernel to implement the work So these are your kernel and user space Lets talk in terms of diagrams This is your user space , this is kernel This the hardware User space and kernel forms the OS Kernel will interact with hardware, and user space will interact with kernel
So this is the architecture , these are the main components of the OS Is this clear to you? lets move forward Lets take a example ,If I make a small script Hello world .sh ,.sh is the extension of shell script Here I will write Hello world When you will go to command line , and execute it ./HelloWorld .sh Then what will happen?, simply you will click , processing will happen And HelloWorld will be printed You run it in CLI, we are calling it shell You run it, we call it user space
When user space is printed , there some computation has been done For computation it goes to kernel , user want to print something like this Then has yo do some computation , so do it This kernel will request CPU for some computation cycles CPU will do the computation , and Hello world will be printed , so this is a example So this much is clear to us , write cleared in comments
Lets discuss the functions of Kernel, till now whatever we have studied , from that we can see that , kernel is doing the most important work Lets see what are the functions of kernel ? The basic functions are, 1. process management For now learn this , you will get the theory in notes in the description So process management is the 1st work , it will take 3-4 videos for process management Let me brief it, process creation ,termination, these are the part of process management
2.Process and threads scheduling User has made the processes , now how those will be executed which we have studied , with maximum utilization The high priority , there should be no process starvation That is the work of kernel , process management will do it Kernel also do context switching and time switching To synchronize the process And to communicate between the processes Many times , two processes need to communicate with each other
As we studied now , there are two processes P1 ,P2 are isolated Both are getting executed independently Many times we need to communicate them This is also done by kernel So process management is done by kernel 2. Memory management You have RAM, a2 GB RAM , how will you allocate memory in it ? Or to deallocate , free space management Whenever you allocate memory , you allocated much memory Some processes exists in the middle , that memory area gets free
Now OS should has the knowledge which areas are vacant Kernel's memory management do this work , manages the free spaces Now if execute a new job then you need space for it It keeps the track of free space , you studied memory management , process management We will study them in detail later ,this is the brief of kernel's work It can be asked in interview , so you have to brief them There is one more work file management It creates and deletes file Directory management
What is directory management ? The file management works in such way that our OS make a hierarchical structure on the disk Like tree ,if I tell you how structure is made in linux There is a root directory, root means dick 's zeroth position A sub directory comes out of it, there is a Lakshay named folder And a Ramesh named folder There is one more OS folder in Lakshay And 1 more folder ABCD , it may be possible there is a lakshay .txt file So in this way , it maintains a tree structure
After sometime Babbar bhaiya will teach you tree , so see the real life implementation here The tree which we study , you are unable to know why we study tree So this is the implementation here to maintain directory structure It is easy to maintain it as a tree because if you have to search a file , you will go here Then here , here and here Basically things are manageable here So in this way you saw the implementation of tree
And how file management stores the directory qin hierarchical structure , we saw it now I/O management is one more work I/O management is an important work, how? You are using laptop or PC , and you want to add game controller Or an USB , so you want to put USB port So this type of things is supported by kernel only If you connected a pen drive , it knows that you connected a pen drive , it notifies you It also provides the method to access the pen drive in my computer
So all these works of I/O management is done by kernel It is managing and operating all the I/O operations I have given you the example of management and controlling As you will plug it , it will notify you , this has been plugged , and it will also provide the method to access it After reading it kernel will send information to user space , there a device has been added You can access it from here , it will enable you to access through GUI
So these are somethings of I/O management ,3 most important works of I/O management are 1.Spooling , 2. Buffering ,3.caching These type of works are also done by it , we will discuss it in next video What is it? So these are the 4 works of kernel So we have understood the 4 functions of kernel , 1. process management , 2. Memory management , 3.I/O management , 4. File management Lets see the types of kernels, there are different types of kernels are available Types of kernel
It is of three types 1. Monolithic kernel What is monolithic kernel? Monolithic means all functions is done by kernel only This type of kernel is called monolithic kernel If I explain you with diagram , then I can say This is your user space , this is kernel , and this is hardware All the 4 works process/ file / memory / I/O management Are present in kernel , so we call it monolithic kernel This the oldest kernel type
All the four works of OS lies in it, we are calling it monolithic kernel Now what is its speciality ? The one advantage is that , all the 4 works are being present in the kernel So the communication between these works is very efficient How? if I take a small example There are two things , user mode and kernel mode These are basically two different parts of OS Kernel mode has the more hardware access , user mode interacts with the user
OS keeps them separated , whenever CPU is in user mode , then it only do user mode work When it goes to kernel mode , then it only do kernel mode work We do the switch between kernel and user mode by software interrupt Now what is software interrupt? Software interrupt Whenever you are working in OS , if you have to say something asynchronously to OS Till now your this work has been going on , now remove it and do this
You are studying , and your father comes and say leave all the work and go do this So this is an interrupt , so these types of interrupts are used in OS There is hardware interrupt also ,it will be like suddenly your RAM stopped working Then RAM will send an interrupt , this interrupt will tell the OS the problem So you have to stop the execution , so we call is interrupt To notify the process in the middle , this type of work is called interrupt So what is software interrupt ?
Interrupt generated by some software means It is not made by hardware , OS is generating it by itself So it is switched between user and kernel mode Basically switching is going on, sometimes it is working in user mode and sometime in kernel mode Lets see the example ,When you are writing command in CLI,MKdir This is a directory command , a folder is made by this When you are writing the command , then you are in user mode As soon as you will press the enter It will decode MKdir
Then it will see that a new folder is need to be created , making new folder is the work of file management department It will go to File management , it will switch to kernel mode It will basically go to file management part , and say to create a directory So you saw an example of switching between kernel mode and user mode As directory will be formed , a feedback will go , that directory has been made So to tell this it will return , basically it will switch to kernel mode
1st we were in user mode ,.,then switched to kernel mode Then kernel deed some work , then we again switched to user mode So this is called kernel and user mode switching , it is basically happening all the time As you give some command , if kernel has some work then you switch to kernel mode When it is completed you switch to user mode So basically in this way it works How it happens? it happens through software interrupt So we basically saw the biggest advantage of kernel
Because everything is here , so communication is more efficient So the 1st advantage is ,fast communication between different components of kernel things are centralized here , there is a big disadvantage also Kernel will be bulky One more disadvantage can be , it is less reliable Assume that memory management is not working because of some reason So the whole kernel will stop working because everything is interconnected So if any component stops working , then all will stop
So it ia less reliable One example is Linux and Unix , MS DOS All are the examples of monolithic kernel So we have understood monolithic kernel 2. Micro kernel Now what is micro kernel? Here we keep the major functions in the kernel , and rest functions are implemented in user space If I try to make it diagram , so it will be like this User space , this is kernel space The core functionality that kernel has are memory management and process management
I will put both here , this is related to RAM This is related to CPU, so we put only core functionalities in kernel The rest functionalities , file and I/O management are put here I put memory and process management in kernel , and in user space we put file and I/O management So in this way I deed some bifurcation What is the advantage of this? here it is bulky In advantage I can say , here it is less bulky and more reliable How? I have reduced the chances of failing of things ,how?
I put file and I/O management here , if there any crash comes in file / I/O management Then kernel will be still working , because main functionalities are here , so I have reduced the risk Now can say that things have become more reliable , so it will be more stable but there will an impact at its performance If I talk about disadvantage Performance will be less here How performance will reduce? because here things kept switching between kernel and user mode
lets take an example , if any process is going on It starts in user mode , 1st it will go to process management , we have to allocate it and provide resources Then we will send it to memory management , it also needs memory 1st process was in user space , then it switched to kernel mode now process is going on , it needed to do I/O , that it has to read something from USB Now again it will switch to user mode
Now your I/O is done , and it has to deallocate space from memory , so we again switched to memory management It will again come to kernel space Now it got the memory , in command it has given to write file somewhere Then it will go to file management , then again it will switch to user mode If you see carefully , I am switching between user mode and kernel mode again and again Here you have to switch again and again
Because of this your overhead is becoming bulky , both kernel mode and user mode are separated spaces , it takes time to switch Here also you have to do one type of context switching So because of this you increased the overhead , what is overhead? You have to switch again and again , there is a cost of every switching, and you are increasing it So performance will be reduced Basically in micro kernel your performance got reduced , here overhead occurred Between user and kernel mode
In starting it was looking less bulky , more reliable ,stable you want it to be You want it to be less bulky ,more reliable but would you want that performance reduces , no Till now everything was good We have studied micro kernel , but now we are unable to understand which is better monolithic or micro kernel So it has a next part also , but before reaching to that next part , lets see one example L4 Linux, Symbian OS, etc Have you used NOKIA mobile ? touch phone used to come
In which there were good games , so NOKIA had used Symbian OS at one time Symbian OS comes under micro OS , its performance was very bad , I remember it So in this way we have seen two examples Now one very interesting interview question is coming in my mind The two processes which are being going on in user and kernel mode , in user mode file management is going on In kernel memory management is going on , basically how they communicate?
There is one question, How communication is being done between user and kernel mode ? Now if there is need of communication , the file management process has to communicate with memory management process Then how communication will be stabilised between them? There is a method that OS provides , OS process management part provides it I call it IPC- > Interprocess-communication Now what is interprocess-communication ?
Till now we have studied that two processes are being executed independently in isolation So both have different resources , memories , so for each other they even don't exists But many times they have to communicate with each other , so how it will happen? There is a method IPC ,so it will be done by IPC What is IPC ? Interprocess-communication , here what happens This is P1 and this is P2 process , P1 is running in user mode and P2 in kernel mode And both want to communicate with each other
There is a method for interacting 1.Shared memory What is this? I will put a memory in the middle Assume that P1 has to communicate something from P2 , P1 is trying to write some data So P1 written the data in the memory space , 123 123 is required to P2 1st P1 will write then P2 will come and read it So by shared memory I passed the message , so I accomplished it So this is the shared memory method, 2nd method is 2.Message passing now what is massage passing ?
OS provides you a method /function , we also call them system calls , we will learn about them later in detail if you have to talk between two processes , we can do message passing What is this? we establish a direct pipe between them Basically we made a channel Through this we communicate them There are some proto calls to do this We use the system calls to pass , by message passing we can talk between two processes
If someone will ask you if process in running in user space and other is running in kernel space , so communication will be established through interprocess communication Interprocess communication can be done in two ways , shared memory and message passing Both methods are supported in different scenarios Lets continue , we have studied two types of kernel monolithic and micro And we are unable to decide which is better
Whenever happens that we have two extreme things , each has some qualities , someone advantages are not present in the other and vice versa Easiest way to solve this is to merge them , take the advantages of both And create a hybrid system 3rd type is Hybrid kernel , now what is this? It contains the advantages of both monolithic and micro kernels So in this way we will take a combined approach In Hybrid , we will put file management in user space
And rest in kernel process/memory/ I/O management Till now we have only put process and memory management in kernel, now we also put I/O management File management is still there , here we have taken a combined approach This is user space and this is kernel , so what is the benefit of it? Now there is only one part in file management , so the overhead which was coming due to switching will be reduced little bit So speed will increase
We kept the advantages of both , and made a hybrid approach , improved the design Stability also increased If I/O management fail ,then kernel will also fail So we kept the advantages of both , and made a hybrid approach here overhead will be reduced , lets see some examples Mac OS ,Windows NT, 7+ are called windows NT So we put the advantages of monolithic and micro kernels here And Mac and windows are using this approach There are two more kernels
Nano and Exo kernel ,these are not much important as interview point of view But still this is your H/W , read it in detail, try to take the understanding, if you not understand it then we will make a video on it So that's it for today , in next video , we will go more deep We will study about calls , how user space and kernel interacts We will study about it in next video That's it for today , tell me in the comment section , how was the video?
Lets see the notes , we have made the notes of lecture -4 1st we studied user space then kernel What comes in user space , CLI , GUI In user space your applications run , user is working in user space Kernel is the heart , very 1st part of OS to load on start-up Kernel is the 1st component of OS that starts Then we saw what is shell? This is a implementation of CLI Operating system that receives commands from the users and gets them executed
What are the functions of kernel? it is an important topic 1. process management , basically creating/deleting scheduling processes Synchronize it Then memory management , this is an important task , allocation/deallocation File management is also written her , you can read it Manges and controls I/O operations and I/O devices 3 things come under this , we will discuss it later Buffering is one part caching , spooling , what is spooling? We spool data between two jobs in advance ,
Its example is print spooling , when you command printer for 10 pdfs Printer basically spools them in an area , the 10 jobs because you provide it fast but printer works slowly That's why it uses spooling concept What is buffering ?within a job /process , we have to use a data in few minutes So we buffer it in advance eg. Youtube , then caching In this video I gave a brief about it Then types of kernel , its an important topic , you should know it
What are the examples which are available in market monolithic kernel , these are the disadvantages here we get high performance , but it is bulky eg. Linux ,Unix ,MS DOS Then micro kernel , major functionalities are kept in kernel rest in user space Size is small , it is reliable , stable but performance is low Overhead occurs eg. L4 Linux , Symbian OS , MINIX then the Hybrid , we combined both to make this Its advantages are , it is the best
We have put the advantages of monolithic and micro kernels in it, we are using the speed and design of monolithic kernel Modularity and stability of micro kernel Its eg. Mac OS , Windows NT/7/10 Then there comes these two kernels Study it , and tell me in the comments , what are these? Then we studied how communication happens between two processes Basically there will be some processes in component F and there are some in memory management Then how communication happens between them , it is done through IPC There are two ways to do it, shared memory and message passing . So this is the lecture no-4 , we will meet in next lecture ,Good Bye!!

Ask anything
We've read this whole study set, so questions about it get the best answers.