My question is:

When I press the "Shut down" button in Windows/Linux,the computer shuts down. How did the command "Shut down" actually make the computer Physically shutdown?

To make my point clear:

When we kick a ball,there is physical contact between the ball and our leg,for the ball to move.So how is the physical connection achieved between software and hardware?How does plain text of codes make the computer do what it does?

(Noob question,I know but it has been irritating me for quite sometime now)

+4  A: 

At the very basic level, plain text code eventually translates to 0's and 1's. These 0's and 1's represent low and high voltage levels. At this point, voltage levels control various circuits.

Think of a battery powered fan. Current provided by the battery is powers an electric motor, which inside, uses electricity to create a emag-field which causes a shaft to rotate, which drives the fan-blades to spin. This is an example of how voltage can become physical.

You could build a "switch" that given the proper voltage, will eventually get the power supply to stop pulling current from the wall.

Obviously it's a lot more complicated than that, but that's the gist of it.

To make things easier, computer's are comprised with layers of abstraction.

At the very lowest level is voltages, circuits, transistors, and silicon. The next layer above hardware is the operating system. Rather than re-writing code for every type of hardware access over and over again, the OS manages the hardware, and provides "hooks" to use it. These hooks, or "interfaces" allow your code to have a common method to access disparate hardware. So using the interfaces provided by the OS, you can write your Application.

In each of these layers, there are sub layers: hardware might have firmware--a sort of low-level instruction set that dictates how the hardware should run, stored in EEPROM, and loaded when the drive is powered up, or like the python compiler/interpreter which provides a way to write network software without having to program directly to the raw socket api provided by the OS.

The OS handles most hardware/software interaction. Hardware vendors write "plugins/modules/drivers" which allows the OS to control their specific hardware.

So you would write a software Application that takes advantage of these OS provided interfaces to hardware. For example if you wanted to power down the computer, windows provides an interface to shutdown the computer. Your software would call this interface, and upon compilation/interpretation, turned into code that will call an interface for the OS. This interface, in turn will execute a well known set of instructions to instruct the computer to shut down. These instructions are 0's and 1's, low and high volts, which access a specific part of the computer that is designed to handle powerup/shutdown/standby, and given the right signal, will do just that.


There're several interfaces between PC programs and the real world outside.

Some connect to CPU. Examples of these are Ports and hardware interrupts (IRQ). These allow sending small amounts of data (by host program request) and calling functions (interrupt handlers) based on hardware triggers (discrete line going from low to high).

There're faster interfaces for transferring massive amounts of data that bypass CPU. This is called DMA (direct memory access). These are used to transfer data to disk, network, display adapters, etc.

For port IO (opcodes IN and OUT) the software is the initiator. For IRQ, the hardware speaks up first to trigger software response.

Only device drivers are allowed to do all these. If you try doing it from the application, OS will smash it at instant. Applications connect to this world thru APIs presented by device drivers. Many of the APIs are standardalized, so you can replace actual device without having to interact differently (a printer, disk, keyboard, mouse, CRROM, ATX power supply switch in your example).

Pavel Radzivilovsky
+1  A: 

Well, the shutdown isn't actually physical, all circuits in the computer aren't totally off until you physically unplug the power.

The software uses the APM (Advanced Power Management) interface in BIOS to control the power circuits in the computer.

When the computer is off, it can still be turned on without physically pulling a switch, for example by a Wake on LAN signal from a network card in the computer.

the power question was just an example. I think the OP wanted to know how something as abstract like "text" could be used to control something physical like power, or ejecting the CD tray...
Yea thats exactly what I want to know.What alan mentioned
+1  A: 

Hi Aby,

Let's compare the physical and the software solutions.

When you push the button, you are actually sending a 5 volt signal to the power supply unit. This 5 volts of power never actually switches off (even when you think your computer is off). You need this 5 volts for when you push the button to turn the computer on - at which point another 5 volts is sent in to the power supply unit to tell it to switch back on.

So in actual fact, your physical button press is converted into an electronic signal in order for the power supply to do something.

When you think of things in these terms you suddenly realise that the computer doesn't need to turn its electronic signal into a physical button-push to turn off the power - that's something they've added to benefit humans (i.e. if you thought there was a tiny motor that pushed a secret internal "off" button - it doesn't exist).

So all the software needs to do is instruct an electronic signal, which triggers the power supply to enter 5 volt standby mode.


Actually, your plain text of codes does not make the computer shutdown directly. It calls a procedure of the underlying operating system. The operating system in turn invokes the ACPI/APM on your main board. This will then make the computer shut down.

How the little 1's and 0's interact with the circuits of your hardware is quite a complex subject which you could read at least one book about to completely understand it...


The leg kicking a ball is a good example. It's quite similar in a machine. The CPU is connected to all the other parts of the system, but unlike the nervous system which is a physical wiring, with all nerves being connected at once, the CPU's does not maintain a permanent connection to the rest of the system. It connects to the desired part on demand - similar to making a telephone call - all telephones have connections, but only a few are connected at any one time.

The cpu does work by running instructions - the software program. There are instruction codes that instruct the cpu to dial some part of the system. Each part has a number, and the cpu has an instruction to dial a number. Once the cpu dials that number, it sends a message to that part - the message is simply data - from one bit up to any arbitrary size block. The hardware at that location then acts on the message encoded.

In doing it like this, the cpu can control any piece of hardware using the same mechanism. The only thing that changes for each device is the number the cpu has to dial and the data the cpu sends to the device - details that are put into the software the cpu is running.

So, to turn the machine off, the cpu dials the number for the power management device, and sends it instructions to go into an appropriate power state. The hardware responds, and the PSU stops sending primary power to the motherboard.

When you write softare, you don't have to know all these details yourself. They are usually pre-packaged as ready to use code, so your software just has to say "shutdown" and the ready-made codes for this (usually in the BIOS) are executed to perform the shutdown, as outlined above.


If in case you are looking for how in general any device is made to perform its action, the device comes with firmwares stored in ROM / CHIP of the control board. The control board is used to control the device through electric signals.

Above the firmware, you will have drivers/service provider. The application will use these service providers/drivers to communicate or instruct the device to perform some action.

Click here to know more on how-firmwares-communicate-to-the-electronic-devices-to-perform-its-operations?