In this lecture we will be discussing about structures of operating system. So in one of the previous lectures we already discussed about something called operating system structures where we discussed about multi-programming and multi-tasking operating systems. So those were two types of operating systems but in this lecture what we are going to discuss is about the actual structure of operating systems. So we know that operating system is a large and complex system and it has to be engineered carefully so that it will function properly and it can be modified easily.
So there are different structures that have been followed from the beginning till now using which the operating systems have been designed. So we will be discussing about some of those structures and we will see the advantages of those structures and also the disadvantages of those structures. So first of all, let us go to the first structure that was followed in designing operating system which was used in the very beginning and also the old operating systems.
which we call as the simple structure. So the simple structure was the structure that was followed for most of the operating systems that were designed in the very beginning. And these simple structured operating systems did not have a very well defined structure. Because it was operating systems those were designed in the very beginning.
So the diagram that we see here, this is the figure of a simple operating system structure that was followed by the Microsoft Disk Operating System, MS-DOS. So we know that MS-DOS was an old operating system which was designed very long back. And this is the structure or the simple structure followed by the Microsoft Disk Operating System.
So here at the bottom most we have the ROM, BIOS, Device Drivers. So think of this as your base hardware. And then on top of this we have the device drivers, then we have the resident system programs, and then the application programs.
So we see that the device drivers they have access to this basic hardware and we see that the resident programs they have access to the device drivers as well as to the basic hardware and then even the application programs they have access to the resident programs as well as the base hardware. So we see that the base hardware can be accessed by all the things above it. The device drivers, system programs, application programs everything can access the base hardware. So we see that in this structure The interfaces and levels of functionality are not well separated.
So we see that application programs are able to access the basic input output routines and write directly to the display and the disk drivers. So that means application programs are able to access your base hardware directly without going through these layers below it. So this looks like they are kind of a layered structure but we cannot call it actually a layered structure because There is another structure of operating system called the layered structure following a layered approach which we will be discussing as we move on in this lecture series.
And we will see how it is different from this one. So, even though this looks like a layered structure, it is not actually a layered structure. Because all these layers have access to the base hardware. So, what happens is that such freedom leaves the MS-DOS vulnerable to errant or malicious programs causing the entire system to to crash when the user program fails. That means if you are running a program here, if an application program is being run by the user and since it is directly accessing this base hardware, if that program fails, then that entire system is going to crash because it is having direct access.
So we see that it is not well protected, it is not well structured and it is not well defined. So, this is not a very good structure. And also we cannot blame the developers or the designers for designing this because as we are talking about the MS-DOS operating system, MS-DOS was actually written on the Intel 8088. And this Intel 8088, it does not provide dual mode or any hardware protection.
So, the developers or designers, they had no other option than to just leave this base hardware accessible by all the layers above. So, that is why It is like this and we see that this is not efficient and this is not a good structure. Alright, now let us see another structure known as the monolithic structure which is also kind of a simple structure. Now another structure that we see is known as the monolithic structure and this was followed by the earlier Unix operating systems.
So in this monolithic structure, this also is a limited structure and why is that? We will see it. Here we have the kernel and then the system programs. So here on top we have the users and below that we have the shells and commands, compilers, interpreters, system libraries and so on.
And below this is the system call interface to the kernel. That is the system call which acts as an interface to the kernel. And this part is the kernel.
Alright, everything below this system call interface to the kernel and above the hardware, this bottom most part is the hardware. So, everything above this hardware and below the system call interface to the kernel, this is known as the kernel. And in the kernel, it has all these functionalities.
Like signal, terminal handling, Character, Input Output System, Terminal Drivers, File Systems, Swapping, Block Input Output Systems, Disk and Tape Drivers, then CBO Scheduling, Page Replacement, Demand Paging, Virtual Memory and so on. So everything is actually packed into one level and hence we call it a monolithic structure. So this was followed by the earlier unique systems. So in here we see that everything, all these functionalities are packed into one level. which we call as the kernel.
Now the problem with this is that there are too many functions packed into one level and this makes its implementation and maintenance very difficult. So let's say that you want to add something to this then you have to change this entire thing or you have to modify this entire thing. Or let's say that you want to debug a certain functionality in this kernel.
Let's say that there is a problem with your CPU scheduling. So, in order to fix that issue of CPU scheduling, you will have to touch this entire kernel. So, this makes it a system that is difficult to be maintained and implemented.
Alright, if you want to add something to it, also it is going to be difficult. So, this is the disadvantage of the monolithic structure. There are too many things packed into one level. So, this is also a simple and limited structure followed by the earlier operating systems like the earlier UNIX. So now we have talked about two simple structures.
The first simple structure from Microsoft DOS and the next monolithic structure from UNIX. So we saw that both of them were having some disadvantages. So in order to solve that disadvantage, they came up with another structure called the layer structure. So in this layered structure, your operating system is divided into a number of layers.
Like for example here, at the lowermost level or at layer 0, you have your hardware. Then you have layer 1, layer 2, up to layer n and the topmost layer is the user interface. So here in contrast to the monolithic system that we just saw above where everything was packed into a single level.
Here we have broken down the functionalities into different layers and we have separated them like this. So the main advantage of this is that it is easy to implement and debug this one. Why? Because Every layer is having different functionalities. So, instead of keeping them all together, we have divided them into layers.
And let's say that one layer is having a problem. Let's say that the CPU scheduling layer is again having a problem. So, in order to debug that, we just have to look at that layer and debug that layer instead of going and digging into the entire operating system.
So, this is one of the advantages of this layered operating system. But again, we cannot say that this layered approach is the best. because it also has its own disadvantages.
Like for example, let us talk about some of the negatives of this layered structure. So, one difficulty is in designing this layered structure. Because you have to be very careful and specific in designing and deciding which will be the layers on top of a particular layer or which will be the layers below a particular layer.
Because a layer can use only those layers which are below that layer. Only the services by the layers below that layer. below it can be used by a particular layer.
Like in order to make this clear, let me take an example. So, let's say that we are having a layer which deals with the backing store that means the layer which deals with DIC space used by the virtual memory algorithms. So, there is a layer dealing with the backing store or the backing storage.
Now, this layer we have to make sure that it has to be below the layer that deals with memory management. Alright. Because the memory management routines needs to use the services provided by the backing storage.
So because of that, we have to make sure that the backing storage layer is below the memory management layer. So this is just one example. And in that way there may be so many other requirements which may not be so obvious.
So we need to be very careful in designing this. So this could be one problem in this. And another problem of this layered structure is that this may be not very efficient as compared to the other structures.
Why? That is because when one layer wants to use the services provided by the layers B, below it, the request has to go down below each layer one by one. And by the time the service is actually provided, it may be late, it may not be very fast.
Like let's take an example. Let's say that a user program from this layer N, it wants to execute an input output operation. So in order to execute the input output operations, it has to get the service from this layer 0 because input output devices are falling under this.
hardware. So what it will do? It will issue a system call.
So we have already discussed what are system calls. So this layer will issue a system call in order to use the hardware. So the system call has to go through all these layers one by one and it has to reach this layer 0. So as the system call passes through these layers, the parameters of the system calls may be modified and it will take time in reaching here and then once the system call is granted, then it will be able to use the input output devices.
So we see that as it has to pass through all these layers one by one, it is not going to be very efficient. By the time it actually gets the input output operation as it was requested, it is going to take some time. So that is one of the major disadvantages of this layered structure.
Alright, so here we have seen the advantages of layered structure and disadvantages of layered structure. One major advantage is that the hardware is protected from the layers above. Unlike the simple structure, the user interface cannot directly access the hardware. We see that it is protected because of all these layers above it. So that is one of the advantages and we have discussed what is the disadvantage of this layered structure.
Now coming to the next one, we have something known as microkernels. So this is another structuring of operating system. Now in the monolithic structure, we saw that so many things and so many functionalities were packed into the kernel making the kernel very big packed with functionalities. But in this microkernel approach what happens is that we are having a microkernel.
Micro from the name itself we know micro means it is something small. So instead of having a big kernel with so many functionalities what happens is that in this microkernel approach we remove all the non-essential components from the kernel and we implement them as system and user level programs. So here the microkernel what it will do, it will just provide the core functionalities of the kernel and then the other functionalities which are there like the device drivers, the file services or the file servers, process servers, virtual memory, all the services they are implemented as a user level or system programs.
So they are on top of this microkernel implemented as some kind of system programs. So, So the main function of this microkernel is to provide a communication between the client program and these services. So there is a client program requesting for some kind of services.
So in the monolithic approach what will happen is that the client program will have to ask the service from the kernel because everything is there in the kernel and then from the kernel it has to get its services. But in this microkernel approach the client program will request something and the microkernel what it will do is. It will just provide the communication between the client programs and it will just help them to communicate to these services which are implemented as system programs. And then the communication between the client programs and these system programs which provide the services are made through with something known as message passing. So message passing is the thing that we use for communication.
And we will discuss message passing in detail when we move ahead in this lecture series. So again the advantage of this microkernels is that we see that these most of the functions which are there will be executed in user mode. Because the kernel is having only the core functionalities so when the client program wants to access any of the services it does not actually have to be run in kernel mode. It can be run in user mode because most of the services are there as a system program.
Now we have already discussed user mode and kernel mode in the previous lectures. So, if a program is executing in user mode, even if that program crashes, the entire system is not going to crash. But if it is running in kernel mode, if that particular program fails, then the entire system is going to crash. So, in microkernel approach, since most of the functionalities will be run in user mode, the crashing problem of the entire system is not going to happen mostly.
So, that is the advantages of microkernel approach. But again this also has its own disadvantages like microkernels can suffer from performance decrease due to the increased system function overhead. Because as I told you we are using message passing which helps in communication of the client programs and these services over here. So, since that communication has to be done always, there could be a system overhead leading to a decreased performance. So, this is another disadvantage of this microkernels.
So, that is the concept of microkernels and we saw how it is good and also what are the negatives of that. Alright, now coming to the last one, we have modules. Modules means we follow a modular approach in the structuring of the operating system.
And this by far perhaps is the best current methodology for operating system design which involves using object oriented programming techniques to create a modular kernel. So here what happens, we have a core kernel and then this core kernel will have only the core functionalities of the kernel. And then the other functionalities are present in the form of modules which will be loaded to the kernel either at boot time or at runtime. So there are some functionalities like the device and bus drivers, scheduling classes, file systems, loadable system calls, executable formats, stream modules and miscellaneous modules.
So these modules will be dynamically loaded to the kernel as and when required. So this is how the modular structuring works. So if you look at this modular approach, it looks something like the layered approach and also it looks a little bit like the microkernel approach. Let's see why and let's see how it is actually better from those two. So it resembles the layered system in such a way that each kernel section has defined protected interfaces.
Each of the layers have a defined protected interfaces which is protected from the things that we don't want them to access. But It is more flexible than a layered system in that any module can call any other module. So in the layered approach we saw that when one layer wants to communicate to another layer it had to go through the layers all above it. Like for example we have already seen if let's say that layer 1 wants to communicate or use some services from layer 4 then it has to go through layer 2, layer 3 and then reach 4. But in this modular approach even though it looks like the layered system It does not have to go through those layers.
Each of the modules can communicate to the other modules directly through the core kernel. Let's say that the file system has to communicate to the device and bus drivers. So, it can directly communicate like this. Alright, so that is the advantages and flexibility that it offers as compared to the layered approach. Even though it looks like the layered approach.
So, though it looks like the layered approach altogether, but it is more flexible and better than the layered approach. And also it looks a bit like the microkernel approach that we just saw before this. So in the microkernel approach what we had, we had the kernel, the microkernel which have only the core kernel functionalities and then the other functionalities were provided as system programs above that. So here also we are having the core kernel with only the core functionalities and then the other functions are loaded into it whenever necessary. But its advantage as compared to the microkernel approach is that in microkernel approach, we need to have message passing in order to communicate between the modules because they are implemented as system or user level programs above the kernel.
But in this one, they are loaded dynamically directly into the core kernel as and when needed. So they don't need to use that message passing and hence the system overhead is not there. So that is the advantages of the modular approach as compared to the layered and microkernel approach though it resembles them in some areas.
So we can say that by far this is one of the best structuring of the operating system that we can have and is used by most of the operating systems. So those were some of the structures of operating systems. So we discussed about the simple structure, the monolithic structure, the layered structure, the microkernel approach, and then the modular structure. So these are the structures of operating system.
And I hope this was clear to you. Thank you for watching and see you in the next one.