How does software / code really interact with hardware?

My question is:

When I click the Shut Down button on Windows / Linux, the computer shuts down. How did the Shut Down command actually cause the computer to physically shut down?

To make my point clear:

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

+53
operating system
Jun 15 '10 at 6:45
source share
11 answers

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

Think of battery powered fans. The current provided by the battery feeds the electric motor, which inside uses electricity to create an emag field, due to which the shaft rotates, which leads to the rotation of the fan blades. This is an example of how stress can become physical.

You can build a “switch” that, provided the voltage is correct, will eventually cause the power supply to stop pulling current from the wall.

Obviously, this is much more complicated than that, but its essence.

To make things easier, a computer consists of layers of abstraction.

At the lowest level are voltages, circuits, transistors and silicon. The next level above the hardware is the operating system. Instead of re-writing the code for each type of hardware access again and again, the OS manages the equipment and provides “hooks” for its use. These interceptors or “interfaces” allow your code to have a common method of accessing disparate equipment. Therefore, using the interfaces provided by the OS, you can write your application.

Each of these layers has sublayers, for example, the equipment can have firmware - a kind of low-level instruction set that determines how the hardware should work, stored in EEPROM and loaded when the drive is turned on. Another sublayer is how the language of a higher A level such as python provides libraries with the ability to write network software without having to directly access the source api socket provided by the OS.

The operating system handles most hardware and software interactions. Hardware vendors write "plugins / modules / drivers" that allow the OS to control their specific hardware.

So, you must write a software application that uses these OS for the interface. For example, if you want to turn off the computer, windows provide an interface for turning off the computer. Your software will call this interface, and after compilation / interpretation it will turn into code that will call the interface for the OS. This interface, in turn, will follow a well-known set of instructions to instruct the computer to shut down. These instructions are 0 and 1, low and high volts, which access a certain part of the computer that is designed to work with the on / off / standby mode and, given the correct signal, will do just that.

+35
Jun 15 '10 at 6:49
source share

Well, the stop is not really physical, all the circuits on the computer are not completely turned off until you physically turn off the power.

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

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

+4
Jun 15 '10 at 6:53
source share

If you think the software is a different creature from the hardware, no explanation will satisfy you. Think of software like a sequence of electric charges. All the code you write will be stored as a sequence of electrical charges on either RAM or disk. Thus, you are NOT writing text other than a sequence of electric charges. Your video card draws material on the monitor in English to help you understand what you are printing. In one case, it is possible, indeed, that everything you do on the computer is physical.

+4
Jun 25 '15 at 22:35
source share

A foot kicking a ball is a good example. It is very similar to a car. The CPU is connected to all other parts of the system, but unlike the nervous system, which is the physical wiring, while all the nerves are connected at the same time, the central processor does not support a constant connection with the rest of the system. It connects to the desired part on demand - like a phone call - all phones have connections, but only some of them are connected at any time.

The processor works by following instructions - a program. There are instruction codes that instruct the processor to dial any part of the system. Each part has a number, and the processor has instructions to dial the number. As soon as the processor dials this number, it sends a message to this part - the message is just data - from one bit to any arbitrary size. The hardware at this location then acts on the encoded message.

Thus, the processor can control any equipment using the same mechanism. The only thing that changes for each device is the number that the processor must dial, and the data that the processor sends to the device is the data that is placed in the software in which the processor runs.

So, to turn off the machine, the CPU dials the number for the power management device and sends instructions to enter the corresponding power state. The hardware responds and the power supply stops sending the main board 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 codes, so your software just needs to say “shutdown” and the ready-made codes for this (usually in the BIOS) are executed to shutdown, as described above.

+3
Jun 15 '10 at 7:07
source share

The software is stored in hardware as magnetic domains on a hard disk or floppy disk or in the form of low and high voltages in computer chips. When you enter the keyboard, each character is converted to an electrical series of 0 and 1, which are then stored as low and high voltages in computer chips called RAM. The low and high voltages in RAM are then converted into magnetic domains on the hard disk or diskette for subsequent reading by the voice of the disks into voltages or stored as low and high voltages in non-volatile computer circuits for later reading. Low and high voltages represent electrical 0 and 1, which were generated by keyboard characters.

+3
Jul 13 '14 at 17:54
source share

There are several interfaces between PC programs and the outside world.

Some connect to the processor. Examples are ports and hardware interrupts (IRQs). They allow you to send small amounts of data (at the request of the host program) and calling functions (interrupt handlers) based on hardware triggers (discrete line from low to high).

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

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

Only all device drivers are allowed. If you try to do this from an application, the OS will instantly break it. Applications connect to this world through the APIs provided by device drivers. Many of the APIs are standardized, so you can replace the actual device without having to interact in different ways (printer, disk, keyboard, mouse, CRROM, ATX power supply in your example).

+1
Jun 15. '10 at 6:50
source share

Compare physical and software solutions.

When you press the button, you are actually sending a 5-volt signal to the power supply. This 5 volt power never shuts off (even if you think your computer is turned off). You need this 5 volts, when you press the button to turn on the computer, at that moment another 5 volts is sent to the power supply to tell him to turn on again.

Thus, in fact, your physical press of a button is converted into an electronic signal so that the power supply can do something.

When you think about things in these terms, you suddenly realize that the computer does not need to turn its electronic signal into a physical button to turn off the power - something they added to benefit people (i.e. if you thought that there is a tiny motor that pushes the secret internal button "off" - it does not exist).

Thus, all software should point to an electronic signal that triggers the power source to enter standby mode at 5 V.

+1
Jun 15 '10 at 7:05
source share

Actually, your plain text codes do not turn off the computer directly. It calls the procedure of the underlying operating system. The operating system in turn calls ACPI / APM on your main board. After that, the computer will shut down.

How small 1 and 0 interact with the contours of your equipment is a rather complex subject that you could read at least one book to fully understand this ...

0
Jun 15 2018-10-15T00:
source share

If in case you are looking for how any device was made to perform its action, the device comes with firmware stored in the ROM / CHIP of the control board. The control panel is used to control the device using electrical signals.

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

Click here to learn more about how-firmware-communicate-to-electronic devices to carry out their operations?

0
Jun 15 '10 at 7:12
source share

I thought about the same question for a while and realized that in fact there is a connection with the software (fantasy) world with the hardware (real) world.

Think of something simple, like circuits and switches, and then think of something more abstract, like an adder or ALU. Over time, abstraction is built on itself and becomes complex in the next rum. Then comes the microcode, Opcodes, machine language, and then finally build and C. After that, the BIOS, OS, drivers and graphical interface appeared, and hold and see your favorite “Shut down” button.

0
Mar 29 '13 at 3:18
source share

Simple: The codes / software that we write are electrical signals represented by 0 (OFF) and 1 (ON) on the actual CPU. From this point we think about currents and motors.

0
Sep 09 '14 at 13:42 on
source share



All Articles