Operating system and hardware, how do they work together on a PC?

It does not matter if you use Windows, Linux, macOS or any other flavor of operating system. All of them fulfill the same function that is to communicate the software with the hardware, to carry out the management of routines and processes and many other tasks. What is the role of the operating system in your system and how is it related to the hardware?

Every PC is nothing more than an integrated hardware and software system where the operating system is what we could call the most important program by serving as a bridge between the programs and the hardware itself. Without the operating system, then the programs could not interact with the hardware, since we are talking about two different worlds: the first, which is basically intangible and which is that of programs or software, and the second, which is that of processors. and the memories.

Operating system and hardware, how do they work together on a PC

In reality, when any of us makes use of an application on the computer, we are not only using that application, the application uses the operating system, which in turn uses the hardware. So if for example you are now writing an email or reading this article, then you have to know that what you are seeing on the screen is the product of this relationship between the software, the operating system and the hardware.

The first operating systems were simple, but as the power of the hardware increased it became possible for them to do more and more things, while at the same time the operating system had to manage them. Nor can we forget the huge variety of hardware that exists for PC today. Most are generic products, but others require specific communication to function properly.

The Operating System decides what, where and when things run

Procesos Sistema Operativo

Programs are nothing more than a series of sequential instructions that the CPU has to execute, it is true that a program has jumps and loops, if we are strict a program is nothing more than that. Within each program there can be several subprograms that run in parallel or in series. Be that as it may, these have to be executed on the CPU and there are dozens of routines and processes that the operating system has to manage at all times.

The programs do not decide which process or routine is executed at each moment, neither where and much less when. This is the work of the kernel of the operating system that manages the different processes. Surely you have ever given the task manager, specifically to the background processes tab.

Well, all that is what the operating system has to manage and it has to do it in such a way that each of the programs receives the processing time from the CPU that it requires. When a program or the PC is slow, this is because the operating system does not have enough power (or optimization if necessary) from the CPU to carry out its day-to-day tasks.

VIP client on RAM and processor

Sistema Operativo Procesos Memoria

The operating system runs like the rest of the programs in RAM, but to prevent the rest of the programs from interfering with its operation and even modifying the data and instructions handled by the operating system, what is done is to reserve a RAM space exclusively for the operating system to which no other program can under any circumstances under normal conditions.

Because the operating system is the one that communicates with the hardware, it has a hierarchy that is above the rest of the programs, since when managing the execution of the routines, the operating system also has access to the RAM space of the programs . In other words, the operating system is like a housekeeper who has access to all the rooms in the mansion that would be memory, while the programs would have limited access. In the case that we are running a virtualized operating system, then the hypervisor of the operating system is the one that has direct access to the hardware.

However, nothing is perfect and there are times when security holes can be created that are exploited by certain programs to execute code in the operating system space. For example, computer viruses are so called because they manage to infect the part of memory assigned to the operating system with their code, allowing them to escape its control.

Communication between the operating system and hardware

sistema operativo driver

In the PC, access to the hardware is carried out by making use of certain memory addresses , which when sending data to them do not cause a reading or writing effect of the same in the RAM, but end up generating a specific action on the hardware associated with that memory address. Either automatically or failing that, the data serves as an input method for said function. Today, due to the enormous amount of routines and processes that are executed, drivers are used to communicate the programs with the hardware.

Therefore, when the OS requires access to certain hardware functions, it makes the drivers work. A driver is nothing more than an abstraction of how hardware works. In computing, we call abstraction a program that emulates an element as much as possible. In the specific case of the driver, it does not emulate the hardware in its entirety, but what it does is emulate its communication interface . The driver itself is then the one that transforms this into instructions that the hardware does understand so that the operating system can communicate with the different components and devices on the PC.

Despite the fact that in the x86 architecture the addressing of memory and I / O is unified at practical levels and today it is separated, since access in general although it is done through the MMU , it is the IOMMU that is in charge of communication with peripherals, which is subordinate to the first.

In short, hardware and operating system are essential among them, they do not work alone in any case and they need a third actor such as drivers, which complicates the entire framework even more in all its functions.