How does hardware in a PC correlate to software?

637 views

How does ram and a cpu control an OS and vice versa?

In: Technology

4 Answers

Anonymous 0 Comments

The CPU executes commands. An operating system provides functions that programs need to work, that are so commonly required that no one wants to program them into every program – and which you would not want programmed into every program because of the severity of potential consequences if there are bugs.

So programs get to share resources, like the drives, network, display, etc, by asking the operating system for it. “Draw me an okay cancel dialog box and let me know what the user answers”. That sort of thing.

Ram is where programs are stored when they are being executed.

The CPU is constantly running commands from RAM – read command at memory location 1, then 2, then 5 – like that.

The OS even manages RAm – a user starts a program – the program says “hey OS, I am going to need 345 MB of ram” and the OS then allocated the Ram.

So – how does hardware correlate to software – all program access to hardware is mediated by the operating system.

Anonymous 0 Comments

It’s complicated when you get really into it, but:

The OS is just a bunch of instructions. The CPU follows those instructions.

Those instructions can include storing information on places like RAM, hard drive, usb stick.

Anonymous 0 Comments

How a computer works is a pretty huge topic. I’ll try to explain enough to answer your question at an ELI5 level.

The CPU runs instructions.

The RAM is what holds the instructions themselves, as well as the data the instructions operate on.

It’s convenient for us humans to think in terms of *programs*. A program is a list of instructions that accomplishes a single task.

Some old or simple computers only run one program at a time. But many computer systems today are intended to run multiple programs at once.

If you want to run multiple programs on the same computer, you might think about having a “master program” that gives the computer instructions about how to “split itself up” between the multiple running programs. People usually call that “master program” an OS.

One big example is what we call *cooperative multitasking*. The way this works is that the OS gives the CPU a special instruction which basically says: “Every 1/100 of a second, stop what you’re doing, save the address of the next instruction you would run, and instead run instructions starting at address 995640.” (An *address* is simply a numbered location in RAM, where instructions or data can go.) Well, address 995640 is part of the OS. The instructions there are a complicated subroutine that basically says “Find the next program that’s ready to run, and start executing instructions where it last left off.”

The net effect of this is that multiple programs can “share” the CPU. What if there’s some program that’s running a long calculation that will take many seconds, or has become stuck in an infinite loop? There’s no problem. The OS will take control from the program, and let other programs run, including the programs that respond to user input, and tell the screen how to update drawings of things like windows / buttons. So the system as a whole is still usable even though a particular program is “busy thinking.”

Tech folks often say things like “the OS will take control from the program,” using a kind of high-level metaphor to understand the big picture of what’s happening. The reality is more like this: The CPU is following the instructions the OS gave it ahead of time, to execute a certain piece of OS code every 1/100 of a second. And that piece of OS code is a bunch of instructions that tell the CPU to run instructions from another program.

Saying things like “the OS will X” or “the OS will Y” is a fictional anthropomorphic way of thinking that helps us humans understand the computer’s operation. In fact, the OS doesn’t *do* anything, it’s just a list of instructions. Only the CPU actually *does* something, by executing an instruction. The CPU itself doesn’t “understand” the big picture of what is accomplished by all the instructions of a program, or all the instructions of all the programs currently loaded into RAM. The CPU only needs to understand the instruction it’s currently running, and what RAM address is the next instruction.

Anonymous 0 Comments

I think you mean the interfaces between them?

For some components like I/O, there are designated chips on the motherboard that control IO operations for security reasons.

For stuff like resources (RAM etc), it gets a little more complex. It usually comes down to the OS, which has various sub systems to designate resources.

A big one in Windows is the Scheudler. The Scheduler decides which processes to execute and in which order. It dows this with various algorithms to determine the most efficient way to complete tasks based on available resources, time to complete a task etc.

The scheduler also has algorithms to prevent programs from demanding too much or too quicky, and to resolve “stuck” programs that both infinitely wait for the other program to run first, as well as complex systems to allow programs to utilise multiple threads and share resources.

It’s quite complex, but the tl;dr is the OS has programs that determine resource assignment and how they are used