CPU device driver in Microsoft Windows

518 views Asked by At

If we consider the language C. It directly compiles the code in the processor instructions. So, it doesn't matter on which processor the program is executed. But if we consider assembly language, it's specific to the processor it is being executed on. So, according to this if we make a program in C, & make it a bootable. There should be no problem of the processor being used, & the program should run right away, And it also does run without any issues. Then why is it so, Microsoft Windows requires drivers to use a CPU ( You can check it device manager, where driver for the CPU being used is installed ). If a simple bootable program , can be written, compiled, & executed, without requiring a driver. Then why is CPU driver installed in windows ?

3

There are 3 answers

9
mcleod_ideafix On BEST ANSWER

You might be able to do that, but only if your program doesn't do any I/O, i.e. not writting to the screen, no accessing the disk, etc.

To make a C program that actually does something it needs to perform some I/O (at least to send "Hello world" to a screen, or to a LED matrix, or to a serial port). I/O management can be either included in your program, as it's common with embedded devices, or available to it in form of shared libraries that your program loads and calls, managed by the OS.

That said, it's true that you can make, compile and run a simple program as boot program in many environments, provided that all the I/O routines it would need are included in the executable, and there's a tool chain that takes your C program and gives you a boot image executable for your desired platform.

On the other hand, Windows doesn't have a device driver in order for you to use the CPU. The device driver you have seen by the name "CPU" is for managing things like the IO APIC, to route interrupts; the Local APIC, to enable multicore processing, several features like virtualization, NX bit, etc. You see... it happens that the CPU has a few I/O devices inside it, so this device driver is for managing them.

0
PMF On

The driver for the CPU is not needed for code execution, it is merely a kind of place holder for where the Cpu acts like a device. For instance to support power management or to read out core temperatures. There the OS needs a device to communicate with. The driver reserves the resources for that and offers the correspinding interface to higher levels.

For historical reasons, you need to specify the Cpu type for the assembler. For a C compiler, this is implicitly given by the platform you run it on. You usually need a different compiler for a different Cpu familly.

10
nonsensickle On

If I'm reading your question correctly you have misunderstood the compilation process for the C language and its purpose.

C compiles to assembly language which is then converted into machine instructions. You need to read more about the ISA and assembly language before you will understand that a compiled C program is in-fact processor specific (in reference to the type of processor e.g. x86 or ARM).

If you have compiled a C program for an ARM processor it won't work on an x86 processor. This is to do with the ISA of that particular processor. Things like virtual machines (e.g. Java) and interpreters (e.g. Python) are popular ways of improving the portability of your code.