Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Geek Culture / How Does Windows Handle Processes??

Author
Message
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 3rd Jan 2011 18:45
I was wondering, how does windows handle a process, from the time you start the application, to the time you exit out? Does the exe ever make direct contact with the hardware? Thanks!

Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Jan 2011 20:15
It assigns enough memory for the process to run. Some of the memory is used by the machine code that represents the program, some is used for global data, and some is used as the heap (dynamic memory that's used while the program is running).

You could say it's directly interacting with the hardware because it's all stored in RAM. The machine code instructions are sent to the CPU for processing and it reads and writes memory values from the heap and global memory.

Your question is quite open-ended however, so it's hard to give you a specific answer.

"everyone forgets a semi-colon sometimes." - Phaelax
the_winch
22
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 3rd Jan 2011 20:51
http://en.wikipedia.org/wiki/Protected_mode
http://en.wikipedia.org/wiki/Memory_management_unit

Perhaps will give you an idea of what the hardware does to allow the OS to provide features like processes.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 3rd Jan 2011 21:59
Those are helpful... What i mean is, when you click on an exe, what does the os do to run it? I know there are things like Maximize() and similar, and those seem like they would be commands that need to be relayed to the os. How does the os know what the program wants it to do, like maximize window, move it, etc? I also know that when you click on the red x, the os sends a signal to the program telling it to close. How does the program know this? My guess is that there is a proportion of memory that the OS or program can write to, and the OS or program can read from to see what needs to happen? Hope that makes sense

the_winch
22
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 3rd Jan 2011 23:11
The OS provides an API that programs use.

A search engine will find lots of links about windows api programming.
This tutorial looks like it should give a good idea of how it works for windows at least.
http://www.winprog.org/tutorial/start.html

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Zotoaster
20
Years of Service
User Offline
Joined: 20th Dec 2004
Location: Scotland
Posted: 3rd Jan 2011 23:51
Dark basic dude79,

When you write a program, in a language such as C++ or DBP for instance, it is compiled into machine code instructions (the ones I talked about earlier), which are fed to the CPU and "interpreted".

So for example, then you press the X button to close the window: writing the program, you write a function that gets called when the button is clicked. The code that checks when it's clicked is provided by the OS. All this code is linked up when you compile. The code that checks for the clicking of the X button, and the code that is called when the X button is clicked, and all the rest, is all compiled into a single program - the EXE, which contains, amongst other things, the compiled machine code.

So when this is fed to the CPU, it doesn't differentiate between the code provided by the OS, and the code written by the user. It's all just machine code now. So when the user presses the red X, the piece of code provided by the OS is executed (simply just because it's told to - like an if-statement), and, since you told it to call your function, the CPU will blindly jump to that function, and do what it's told. As you might expect, the code you write in this function tells the process to free any memory it's got, any files it has open, etc.

Bottom line, all the code that makes up a Windows application gets turned into very simple instructions that the CPU will run without questioning it, or without knowing it's overall purpose.

Hope that explains it.

"everyone forgets a semi-colon sometimes." - Phaelax
Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 3rd Jan 2011 23:52
That's cool, and it serves multiple purposes as i have been needing to know that info as well, being that im learning C Thanks!

Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 3rd Jan 2011 23:55
@zotoaster Thanks, that is actually what i thought was going on, so that clears things up! Thanks

Neuro Fuzzy
17
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 4th Jan 2011 07:46
I know I said it before, but the book "The Elements of Computing Science" Is great to read through if you're really interested in how a computer works. It details the construction of a computer from basic boolean logic gates.

Dark Java Dude 64
Community Leader
14
Years of Service
User Offline
Joined: 21st Sep 2010
Location: Neither here nor there nor anywhere
Posted: 4th Jan 2011 18:48
Ill look into that, sounds interesting. I wake and go to bed talking to myself in my mind about computers

Indicium
16
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 6th Jan 2011 22:02
The cpu is sooo whipped :p

Login to post a reply

Server time is: 2025-05-22 15:38:47
Your offset time is: 2025-05-22 15:38:47