How hardware devices work together

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! Let's see this.. So far we have seen, What is meant by Computer system. Right! Fine! Let us assume this. This is our computer system.. Which is having CPU, RAM and the Hard disk.. Now Any program if you take, in our computer .. It will be definitely present in the Hard disk.. Right! It will be definitely present inside the hard disk.. Let us assume,, We have a high level program.. We have a high level program. Right! We have a high level program.. See, high level program means.. The program which we write.. For example a C program or JAVA program or any software.. that we use like Photoshop or Google Chrome or whatever.! We say the most high level program. Right! Now this high level program cannot be directly placed inside the hard disk. Right! We cannot place it. The reason being.. See! Why do we write the programs? We write programs, Because those programs has to be executed by the CPU at some point in time. Right! Our CPU will fetch the program and it will execute it. That is the reason we write programs.. Now.. The problem here is! CPU will not be able to understand High level program.. Right! Which means.. The programs are written using C or JAVA or Python or whatever.. Ok! Such programs cannot be understood by CPU.. or CPU can understand only 1's and 0's. Right! They only understand binary numbers with just ones and zeros. So.. What we do is.. we convert our source program into something called Machine code.. Machine code is nothing but ones and zeroes. The complete program which you write will be converted into a code.. And this code will have only ones and zeroes. This is what we mean by machine code. We can also say this as .exe code or executable code or even low level program that is under various names we use in order to refer a machine code. So any problem you take.. It will be converted into machine code by using a program. called as Compiler. Right! Compiler is also a program/software which will convert a high level program into the machine code. Now once we have converted this.. What you will do is! You will place the machine code into the Hard disk of the computer. Right! That's why I told that.. Any program you take will be present in the hard disk and most importantly that program will be in machine code. Right! The program will be in machine code.. Fine! So.. we have placed the program into the hard disk. Now tell me, How CPU will access a program? Right! Lets say, Any program you write.. It has to be executed by the CPU at some point of time.. Now how CPU will execute the program? The most important point, you need to notice here is.. Our CPU cannot access the hard disk directly.. Right! Our CPU will never be able to access the hard disk directly.! Our CPU can only access the RAM directly. Right! This can always happen.. But this should never happen. So, what we do is.. Let us assume, Our CPU is requesting for a program say P1. Right! CPU is requesting for a program, P1. Now what we will do is? We will search for program P1 inside the RAM, Right! You search for the program inside the RAM.. See.. One more important point. You can even see in the diagram that, size of the RAM is very small compared to size of the hard disk.. Size of RAM is very small compared to the size of Hard disk. Even if you take today's computers The RAM's which we use are something around 4 GB at max it can be somewhere around 16GB.. Right! This is the size we use create it for right. This is the size we use today for RAM. Right! But If you take Hard disk.. It is something around 500GB, or 2TB these days.. Right! the size of Hard disk is very very large when compared to size of RAM, The reason being.. Hard disk is very cheap. For us RAM is very very costly, So.. This is the reason the size of Hard disk is very large compared to size of RAM in today's computers.. So one thing is for sure.. we cannot replace all the programs inside the RAM.. Right! we cannot place all the programs.. Why? Because the size of our Hard disk is very large. Now If we have, the hard disk full of programs.. How can you place all the programs inside the RAM? It is not possible.. Right! Since Size of RAM is very small, We cannot place all the program inside the RAM. Fine! Now lets come back to this. So, If CPU wants to execute the program P1, It will search in the RAM. In case if the program is present in the RAM. That's Fine! It will fetch the program from RAM. In case if P1 is present inside the RAM, It will fetch the program P1 and then execute it.. Ok! We fetch it line by line.. and then it will execute it.. It takes very less time. Why? Because, Our CPU is only accessing the RAM. Ok! In order to fetch the program P1.. whereas, In case if P1 is not present in the RAM.. CPU is searching for program P1, Right! Or in case of P1 is not present in the. RAM.. one thing is for sure! P1 is definitely present in the Hard disk.. Right! Now.. What we're really doing is..! We will copy the program P1 and then we will place it in the RAM Right! For example: P1 will be present in say.. the lamb.. inside the hard disk.. Now what we will of it.. in RAM, It will create a copy of P1, and the you will create in .. And then you will place P1 in the RAM.. Right! Now once this has been moved into the RAM, CPU will take the program from the RAM.. Right! This is how, our program is generally accessed by our CPU, In case if the program is present in the RAM, CPU will directly access it. In that case.. it takes very less time. Because it involves only RAM access.. time.. Right! we need to access only the RAM and we know that, RAM is very very fast.. Whereas In case, if the program is not present in the RAM.. In that case.. We need to access both hard disk, as well as RAM.. Why? Because we need to copy the program from the Hard disk.. So we are accessing the hard disk.. Now.. Once we placed the program into the RAM.. Our CPU will read the program from the RAM.. Right! So effectively.. We are accessing both the hard disk as well as the RAM.. Right! And we know that, Hard disk Hard disk is very very slow. It takes a lot of RAM in order to access the hard disk.. So In case, if a program in CPU is asking for.. Is present in the RAM.. It is going to take very less time.. time for the CPU to access the Program.. Whereas in case if the program is not present in the Program.. It is going to take lot of time for the CPU to access the program because we need to access both the hard disk as well less RAM and we know that Hard disk is very very slow. Fine! See these are important points.. RAM is costlier than Hard disk.. Right! This is the reason.. We have the size of RAM to be smaller than Hard disk. Also The RAM is very very fast, when compared to Hard disk.