Need for Operating Systems from scratch

Vignesh Sekar
A free video tutorial from Vignesh Sekar
Software Engineer,Computer Science Instructor
4.6 instructor rating • 14 courses • 14,456 students

Learn more from the full course

Operating Systems from scratch - Part 1

Learn the concepts of Operating Systems from scratch as Operating System forms the core of Computer Science

08:18:41 of on-demand video • Updated October 2020

  • You will become very familiar with the core concepts of Operating Systems
  • You will be able to challenge the interviewer on questions related to Operating Systems
  • You will view Computer Science in a different dimension
  • You will be able to answer all questions of exams like GATE,PGEE,ISRO (after completing all parts of OS course
  • You will be able to get a top grade in your Operating systems course in your Bachelor's degree
  • Understand how Operating Systems work
  • Understand how a process is created
  • Understand how CPU scheduling is done in Operating Systems
  • Understand the various scheduling algorithms we have in Operating Systems
  • Understand how CPU , Memory and Disk work together
  • Understand Memory managment in Operating Systems
  • Understand how a process is moved from hard disk to RAM
  • understand memory allocation strategies used by operating systems
English Fine! So far, we have seen how a machine code is placed in the hard disk of a computer. Right! Fine! Now, Let's see what do we really mean by Operating system.. Let us assume that, our RAM can hold a maximum of 50 programs. Right! Let us assume, the capacity of RAM is in such a way that it can hold a maximum of 50 programs. Also assume that Hard disk can hold 500 programs. And as you know the size of Hard disk will be larger than the size of RAM. Fine! See, We have already seen that! Our CPU cannot access the Hard disk directly. Right! Any program our CPU wants to access, It can only access the RAM directly. Now, So definitely we need to move the Program from Hard disk to RAM. Right! Only then CPU can execute it. Now, My question is Since RAM can hold only 50 programs. Out of this 500 programs, which 50 programs are going to move to RAM. Right! Only 50 programs can be moved from Hard disk to RAM. Now out of these 500 programs in the Hard disk, which 50 programs are you going to move to RAM. Right! That is the question. See.. One answer might come up is .. We need to move the 50 programs which the CPU, will request next in the future.. Right! The 50 programs which CPU will be most likely to refer next. Why? Because, In case if the program that CPU is asking for is present in the RAM, it will take very less time for the CPU to execute.. Right! Whereas in case if it is not present in the RAM, We need to access the Hard disk So it is going to take lot of time. So, You might say that, We need to keep the 50 programs.. Which is most likely to be requested by the CPU next. Right! But there is a big problem here! The problem is we cannot tell the future exactly. Right! Our CPU can ask for any program. We don't know which 50 programs, will this CPU refer next. Right! We cannot exactly tell the future.. So for that, there is no other way other than going for prediction. Right! We go for prediction. Which means, we try to predict which 50 programs with the CPU is most likely to refer in the near future. Right! Only those 50 programs we need to move from hard disk to RAM.. Right! Those programs we need to move them hard disk to RAM.. Now there are various algorithms, We can come up with various algorithm, saying that.. This 50 programs has to be moved. That 50 programs has to be moved.. Right! It really depends on algorithm which we are implementing. That algorithm will be implemented by other Operating systems. Right! That algorithm will be implemented by our Operating system. See, This is how operating systems that look, like it is a big program which will have lots of functions.. Right! And every function will implement a particular functionality. Here are our operating systems need to choose 50 programs among these 500 programs. Right! This is one such functionality. Now, In this functionality will be implemented by one of the functions of Operating system. Right! One of the functions of Operating system will be implementing this functionality.. Not We can also say this functionality as Long term Scheduler, the part of the program which is selecting this 50 programs among the 500 programs. He's also got a Long Term Scheduler.. So, Our operating systems is a big code, Out of which Long term scheduler is a small function. Right!. Which is going to implement that. Which is going to implement the selection of processes from hard disk to RAM. So.. This one is very clear.. Right! Actually, what we are doing here ..? we are doing nothing but resource allocation. We are doing something called as resource allocation or allocation management.. Why? See, Any device we use in our Computer, We can also say them as a resource.. For example: CPU is a resource.. RAM is a resource.. Hard disk is a resource. Even our Printer is a resource.. Mouse is a resource, any device we use in our computer is called as a Resource. Right! It can be a device.. Fine! Here the device is nothing but a resource.. Here we mean the RAM, Because 500 programs are trying to access the RAM.. which is the resource. Now.. It is the operating system. which is deciding which 50 program should access the RAM.. Right! which 50 programs. Among those 500 programs.. which 50 program should access the RAM.. So.. Operating system, is clearly implementing Resource allocation. Right! Resource allocation or Resource management.. Here resource is nothing but RAM. So this RAM is the resource.. which is being exactly allocate by your using an Operating system. Similar way.. There are lot of resource allocation schemes.. Which are necessary in order to make our computer work. For example: Let me come to the another scenario.. Let us assume we have 2 processes.. Named P1 and P2 inside our RAM.. Right! We have 2 processes.. names P1 and P2 inside our RAM.. Now, Our CPU needs to fix the program and then needs to exit it.. Right! Our CPU needs to fix the program. I think it needs to get it. And needs to execute it.. Now.. Let us assume that, both these programs .. Which means.. Both these programs are ready to get picked by CPU. for execution.. Right! Now, among these two programs.. which program the CPU will select next. Right! Among these 2 programs.. Again There is a confusion here.. Right! Here, The Resource is nothing but CPU.. And more than one process is competing to access that resource.. Right! Now which program or process both P1 and P2 are one and the same.. Right! There's a minor difference. We will see that a bit later.. As of now, program and process both are same.. Fine! Now.. Out of these two programs.. which program should access the resource.. By resource I mean the CPU.. And that is again being decided by one of the functions of Operating system. Right! One of the functions of Operating system. Now this function will have the code, Which will clearly say which process among these two.. should access it.. Right! See, How this is done..? By using an algorithm. Why do need an algorithm here.? For example: This function might implement an algorithm saying that.. Among these are two processes, the process which is biggest in size should access the CPU first.. Right! Or you can implement a different algorithm saying that.. The process which is smallest in size should access the CPU first.. Right! That is one such algorithm.. We can you implement a lot of algorithms. Another example is the process which came into the RAM first.. from Hard disk should access the CPU first.. See one more important point.. Obviously every program or process will definitely get the resource. There is no doubt about that. Even here.. All the 500 programs but definitely more to RAM at some point in time.. Right! It'll be definitely moved.. Now.. Out of these 500, which 50 should be moved first.. That is important! Right! Though.. All 500 programs will get the source, which 50 should get good resource first.? That is important! Same is the case here. Out of these 2 processes.. Though both the processes will get the. CPU.. Now the question is which, process should get the CPU first! That is important.. Right! And that is being decided by our Operating system. Right! This functionality which decides.. which process should access the CPU first is called Short Term Scheduler.. This functionality is also called as Short Term Scheduler.. Right! We will see that later! We are not actually discussing advanced concept. I'm just giving you an idea. Among these 500 programs.. 50 program is being chosen by a functionality called as Long Term Scheduler.. Right! Long Term Scheduler.. And out of these many processes Which process should acquire the CPU first? Is being decided by our Short term Scheduler.. Right! So what is actually happening is again. Resource allocation is happening. Why? Because here resource is nothing but CPU.. Now.. more than one process. is trying to access the CPU and the Operating system is actually allocating the resource in the appropriate process. Right! So the main point we need to note is .. The main function of operating systems is Resource allocation or Resource management. Both are the same.. Right! Operating Systems is a code which will have lots of functions and the main functionality of operating system is nothing but Resource allocation or Resource management. Fine!