how does an os run in the background?? :confused:

srisimha

Junior Member
Jul 10, 2013
6
0
0
considering os as a process that makes other processes run, on a single core processor only one process runs at a time. if a process is using the processor for its execution, how does the os keep running in the background :confused:
 

piasabird

Lifer
Feb 6, 2002
17,168
60
91
Processors are really fast and how a single core processor can handle this is by doing task faster than required and then doing other things when the processor is not running at a 100% load.

Processors like the Intel P4 split the instructions up into 4-8 lanes and they run the processes twice every cycle of the processor. AMD pioneered on the 32 bit processor the ability to split one cycle up and get 2 executions per cycle.

The Processors also have one section that predicts what instruction will be run next based on repetition and other factors and gets the data and the instruction loaded ahead of time. See Predication Unit.

Processor Engineering used these types of methods to acutally run faster than the a typical program required and keep several programs running all at once.

For tasks that require extraction of a lot of data from disk storage the memory system is capable of fetching the data and then tell the processor when it was done. See DMA Dynamic memory Allocation or addressing?

A CPU or processor is a lot more complicated that you might imagine.
 

srisimha

Junior Member
Jul 10, 2013
6
0
0
so does the processor switch between the the process nd the os? like execute the process for a cycle and then get back to the os the next cycle?
 

ViRGE

Elite Member, Moderator Emeritus
Oct 9, 1999
31,516
167
106
so does the processor switch between the the process nd the os? like execute the process for a cycle and then get back to the os the next cycle?
It doesn't switch quite that often, but yes, that's the general gist of it. A process will be allowed to run for a bit, a timer (or interrupt) will trigger, and then the OS will once again take control and decide what to run next. The big ideas you'll be looking for here are context switching and multitasking.
 

Topweasel

Diamond Member
Oct 19, 2000
5,437
1,659
136
so does the processor switch between the the process nd the os? like execute the process for a cycle and then get back to the os the next cycle?
First the OS has to be doing something. Just having windows running doesn't mean the OS is actually doing anything. Then even if you didn't have the have the ability to split up a cycle, your still talking about insanely fast CPU's. Lets say 1 instruction per cycle per Hz. 1 GHZ is a billion Hz. So if you move your mouse and that needs to get processed and lets say it needs to do 1000 instructions. That takes a total of 1/100th of a second to complete that task.

Just by watching the task manager you can see how this is handled. When you see that CPU usage is at 17% that means that during the last measured period of CPU use (lets say 1 second) that it was actively processing only 17% of the time. In the example above it would have handled about 1700 instructions and the CPU would have been active for about 1/50th of a second.

This did lead to system locks and horrible responsiveness back in the day before multiple cores and HT. If you are running 1 app that just kept having the CPU do work you couldn't even switch to another Window in Windows because it had a hard time finding room for those simple instructions. Encoding work like DVD-Shrink used to bog the system down so hard I would have a Duron machine dedicated to the task so I could always have my system working for me.
 

Netopia

Diamond Member
Oct 9, 1999
4,793
4
81
...Lets say 1 instruction per cycle per Hz. 1 GHZ is a billion Hz. So if you move your mouse and that needs to get processed and lets say it needs to do 1000 instructions. That takes a total of 1/100th (1/1,000th) of a second to complete that task.

Just by watching the task manager you can see how this is handled. When you see that CPU usage is at 17% that means that during the last measured period of CPU use (lets say 1 second) that it was actively processing only 17% of the time. In the example above it would have handled about 1700 instructions (170,000,000 instructions) and the CPU would have been active for about 1/50th (1/6th) of a second.

This did lead to system locks and horrible responsiveness back in the day before multiple cores and HT. If you are running 1 app that just kept having the CPU do work you couldn't even switch to another Window in Windows because it had a hard time finding room for those simple instructions. Encoding work like DVD-Shrink used to bog the system down so hard I would have a Duron machine dedicated to the task so I could always have my system working for me.

Logic is correct... math was just way off! :)