Let's talk about process management 
Before talking about process management 
let's see 

What a process is ?


what I really mean by process there are two words wish you wish you must be you know listening for a long time one is a program and other ways process so I'll just differentiate between what these two are so whenever you write any C program it will look like this for example if you are written the C program example dot C right and now this one will be given this program will be given to the compiler right and what will compiler to compiler we just convert this high-level language generally you see program will be the high level language to a low level language which is machine level language which can be eluted on the machine right so now see operating systems task is not to take a high level language program and exhibited on the machine before doing this you should convert it to the machine level language which operating system will understand and then it will directly run on the hardware right so now compiler is going to generate something like is in that a dot out so a dot out in the file which contains executable code.

What are Executable code ?


Executable code means the machine code right so either this one or this one these two are called programs only program right and now this program is going to reside in the hard disk off your memory hard disk of the computer right so hard disk means the secondary storage see I say that I generally use it terms primary memory which means the RAM and hard disk which means secondary memory so secondary memory generally the hard disk and everything else's comes out of primary memory so we are mainly using we even call it as main memory main memory secondary memory and second remembrance disk now this program will generate recite in the secondary memory right and now not executed operating system will take that program right and then put it in the main memory and then start executing it so when it puts in the main memory it will create some kind of structure some data structure so the data structure is going to look like this and that is what we called as a process.


The Process is something which is created by the operating system in order to execute a program so before you exhibit a program you are supposed to create the process right so the relationship between process and program means you can take of it like this a process is something which is the real and a program is something which is virtual right or if you want to if you want to see this a process is something which is like like this body and the program is the soul right so soul you cannot actually it is like a virtual concentrate but in body as it exists physically so a process is body and program is soul you can think of it that way ok and now see this so coming whenever we want to execute the process then the operating system will create something like this.
 
 
You create a structure like this this structure will be created in the main memory right and your dot exe code or executable code which ever you want it execute will be here a dot out that is dot exe per which you got right and above this in your program sometimes you have some variables which are called as static variable static variables means these variables will be created once y know and then they are going to remain forever throughout the lifetime of the process right so they are called static variables static variables and global variables global variables also kind of static variables which have to be given access to every everything in the process or global variables are talking about it later in some other subject but now understand that these two variables static as well as global are supposed to be created once and they are supposed to be existing forever so they are going to be there forever right and then and then the remaining space is actually you know not divided but then you can think of it like a not strict division right something like this where you could be good imagine it this way in any program will contain a need for dynamic allocation dynamic elevation means like heap right so ml log CL of all these calls the reason is we don't know what the requirement we might get therefore will not declare the data structures unless they are required.
 

What is Function Stack ?

 
Therefore,we have to have some space which will be used by the process later at some point of time whenever it is needed for that reason heap so heap will be here right and then every process is supposed to contain something called a stack so what is the what is the advantage of stack for the recursion calls right for the function calling we need stack therefore stack will be there it is also called as function stack 
 
 
stack will be there if will be there static variables global variables and then the executable code now know after creating this CPU will take one by one the lines available in executable code and then keep on executing them while executing them it might sometimes have to refer the static variables which are present in the same program that is where that will present in the same process this entire thing is called process boundaries.
 
 
So everything that is required by this process will be in this and operating system while executing this particular process should never cross the boundaries of this process which means anything that you write here should access only this part you should not write any access other part then you will get segmentation fault in case if you try to access some other part so this program is completely restricted in such a way that you are supposed to use only the elements present in this part you are never supposed to go outside under for something else right so now this is this party static variables and global variables and this part is hip and distant this part is tagged one important thing about heap and stack is heap will grow upwards and stack will grow downwards in the sense they both will not grow upwards the reason is if you grow both of them upwards.
 
 
I don't know where to start each one of them and I don't know you know some in some programs stack will take more space and in some programs he will take more space and I don't know which one is going to take how much space before executing it that is where I want to keep my options open so whichever takes more space will occupy more space in this and whichever needs the less space will actually string down right that is how it can be taken advantage it is like this you are having a book finish from one side you're writing the TOC another side you are writing the compiler design then you need not write you know TOC from half in the initial page and compiler from the midbass you actually write it from the opposite sets because you don't know which one is going to take more space and which one is going to you know occupy the complete loop after some time isn't it similarly we don't know which one therefore this is the kind of implementation we are using so this entire thing is called a process.
 
 
 So this is the program either this one or this one is a program which will generate a general reset in the hard disk and once we try to execute this then for this particular program this n type thing will be created by the operating system right and now this one will be given for execution to the CPU now CPU will take each length from here and then refer to the elements here or use the stop space and then try to finish the execution so that is how it is done so this is the body and this is his soul this is the soul right and if it does not have any soul see 
 
If you cannot execute it it is as good as dead man if we do not have any instructions to execute even if you use that entire structure to see for you what will keep you till right right now how can you identify pauses see given these many processes in the in the operating system like this we have so many people in the world right then how can you identify each one of them we are going to use something called as identification cards isn't it identification card is going to say see this is the ID number may be driving ID and then this is the name and then this is these and this is the status everything will be there right similarly when we have these many processes created in the memory randomly at any point of time we are supposed to keep track of which process is what and how many process are there and what what is the current state of the process what is happening with it is it running or is it blocked or what should I do.
 
 
So in order to identify everything we are supposed to you know have some bookkeeping work it is like this every process will now be given an identity card right now it is a newborn baby right need not be newborn it might have taken some time and now it might have grown up already anyway whenever anything is born any process is gone opera custom is going to give it some ID card right now that ID card is going to look like this that will contain all these attributes one attribute is process ID so process ID means every process will be given some number right that is called process ID why is it useful is we cannot obviously name a name a process right like how we name the people so that is when it is a unique number which will be given to a process in a computer every process will get a different number.
 
You know coming to this process ID it is not like port number port number is universal everyone maintains the same port number but here the process ID here the process ID is actually different in the sense it you know depending on the operating system some operating systems will use 16 bits some operations will use 32-bit like that ok and next one is program counter program counter means while you are executing it is a program here the process you suddenly stop the process and again you restarted it then from which point it should you actually start the execution which means assume that we have like ten instructions i1 i2 i3 so on i-10 and say you stopped the execution or Isaac's you exited i6 and then after this you stop the execution and then you remove this process and then you exhibited some other process and later again you started this process then after this instruction what is the next instruction you are supposed to execute right.
 

What is PCB ? and Their ATTRIBUTES

 
So that is what we wanted so for that reason we use something called as program counter program counter will contain what is the next instruction that has to be executed right so that you can keep on shooting it without any repetition that is that is just to maintain that okay next for this process state so what is process stages I'll tell you there are various states next I'll tell you what what the states we have but anyway like this already it states will be like this ready to run or running or blocked or waiting anything I'll show you this later and next priority priorities it shows importance so whenever any process is created by the operating system then it will generally assign something called as priority
 
A process which is having higher priority is supposed to execute our first compared to the process which are having lower priority for example if you have an operating system process then it should be given the highest priority because it is important compared to the user process right therefore depending on that we assign some number priority is nothing but a number which will be given to the process whenever it is having whenever it is you know created for example you like this now priority given now coming to this sub priority try it is a number you can compare it this way politicians politicians will have you know higher priority compared to normal people therefore they're going on road the road will be blocked for others similarly when a new process with higher priority enters the you know environment then that ones will be given higher priority and everyone will be blocked or everyone will wait until it finishes right so like that priority will be useful and now there is something called as general purpose registers.
 
So general purpose registers means when you are executing a program some prompt some program then what happens is the CPU will make use of the resistors right and now when you pull out that process now these resistors will contain some numbers and if you pull out that process and put the next one there okay now now we are all stronger which are both the resistors now general purpose registers are like this if you have a CPU so if you have a CPU now it will have some registers so register r1 erasure r2 resistor r3 like this okay and now if there is a process P 1 and if it is executing on this CPU.
 

CPU say you know implement acute in this process p1 during its execution it will be having some some numbers which are stored in registers for example here the number stored is one number storage two number stored is three right and now this process some let us say the next instruction which has to be executed is I for the instruction number 
 
Let us say r1 equal to r2 plus r3 this is the instruction there for a process will even refer to general general purpose registers during its execution it is not just that you know it is going to refer only on the elements which are present in the process it will even refer to the general purpose registers now if this is the next instruction that has to be executed assume that at this point of time p1 this particular process got preempted preempted means stopped for some reason it got stopped what are the reasons we shall see them later and then the other process p2 p2 it got to be now p2 has to be executed some other process it came for resolution now CPU is executing this therefore p2 will definitely change the status of this right so let us say it is changing the status from here 5 and here 6 right and after for some time this p2 left the CPU and again p1 not executed and therefore by looking at this program counter we know that the next instruction which has to be executed is I 4 so I am going to take I 4 and executed but then execute this one R 1 will be R 2 plus R 3 which means R 1 will be 5 message which is 11 right but then actually it has to be 2 plus revisions 5 so whenever you priam or whenever you stop any process and take the next process for execution it would even make sure that the this you know the general-purpose registers this state the what is what is present in the general-purpose registers they also should be stored at some point at some place.
 
So that when you again come back the entire state of the general purpose register should be restored right so that is why it is called as general purpose registers which are also which have to be stored right and next one is list of open files so list of open files means during the aleutian of the process some files are going to be opened and some files will be open for reading some files will be open for writing therefore you are supposed to remember what are the files which you have already opened.
 
So that later when you again I know come back variation of the preemption you should know you know how which one you have opened so that you will not again open it or you will at least close it right so why is this one is useful is when many many process are known using files you should make sure that the same plans the same file even if it is written by to process it should be consistent therefore sometimes you should know what are the process which are opening some files and for a given file what are the process which are opening it and for a given process what are the files it opened it because whatever modifications you do on the file system is now going to reflect on the processes right.
 
So later what happens is if a particular file is closed which is already being read by process then before closing it you will just go through all the list of courses which are opening this and again you inform them that we are going to you know delete this file or something like that next one is this top open devices so open to various means you can think of it like this that printers scanners and hardware devices and you know you should maintain a list of it production so production is like this you are not supposed to execute get into the other process workspace similarly other process are not supposed to get into your workspace right so operating system should protect you from others as well as you should stop you from accessing lis other's data 
 
 
So everything every information will be maintained in this right it is a kind of identification card like however identification cards work here also the same way it will work now where will all this information be present is it will create something called else for every process it will create something called else process control block in this process control block the entire information will be present so for every process we get one process control block.
 
Let us say this is it process control block for p1 and it is the process control block for p2 from this control block for p3 right so so on for all the process we have process control blocks and all this process control blocks will be will be present in a linked list right so you can know by looking at this list of process control blocks how many processes are executing I mean how many process are there in the system and then now which one is doing what by looking at this state of it and then you can know what are the files used by each one and many things various names everything you can it would get to get it from this information under this so this is the district PCBs which is going to indicate how many everything about the process a particular process can be identified using one PCB but the all the processes if you want to know about them information then you can look at this list right everything is maintained by the operating system in a linked list.