1,034 views
1 votes
1 votes
We generally say that the scheduler picks a process from the ready queue and then brings it to CPU for execution but in general ready queue is actually a linked list of PCB's and a process is actually a different section of memory so then how come we are able to pick up a process for execution from a queue .

 

Also a process has a set of executable instructions so then when CPU fetches an instruction from it , so then is it that the size of the process in the memory changes because I saw the task manager and saw that the memory occupied by the processes was changing nearly increasing and decreasing as the process as allocated to CPU , so I couldn't get the logic for this that how come the memory occupied by the process changing when CPU is allocated to it ?

1 Answer

Best answer
1 votes
1 votes

Ready queue is a linked list of PCBs- so the scheduler gets a PCB. Now, PCB will have all information about a process. 

https://en.wikipedia.org/wiki/Process_control_block

As part of this data will be the code location of the process. When a process is created, it is assigned memory for the code, data, stack and heap section. Now, the CPU will start executing instructions from the code section from the PC pointed value. 

How process "memory usage" changes during execution? Because the process is using dynamic memory allocation. Write a C code with no dynamic memory allocation- that is no function calls and simply running a nested loop a million or more times. There won't be a change in memory usage. Memory usage changes during function calls- dynamic memory allocation on stack (in languages like C) and on dynamic memory allocation on heap. 

Related questions

0 votes
0 votes
1 answer
4