How your computer runs programs

How your computer runs programs

Today, I will write about the things I understand and share them with you.

CPU - Think of the Central Processing Unit (CPU) as the brain of a computer. Just like your brain processes information to make decisions and perform tasks, a CPU processes data in a computer to execute programs and perform various operations.

The CPU's job is to take instructions from software (such as applications or games) and perform the necessary calculations and actions. It works really fast, handling tasks like performing calculations, moving data around in memory, and making decisions based on the information it receives.

The CPU always reads machine code directly from RAM.

RAM - RAM stands for Random Access Memory, and it's an essential part of your computer's memory system. Think of RAM as the computer's short-term memory or workspace.

When you open a program, like a web browser or a document editor, it gets loaded into RAM. This is because accessing data from RAM is much faster than accessing it from the computer's main storage, like the hard drive or SSD.

Here's a simple analogy: Imagine your computer's storage (hard drive or SSD) as a bookshelf where you keep all your books (data and programs). When you want to read a book, you take it off the shelf and start reading. RAM, on the other hand, is like the desk where you place the book you're currently reading. It's much faster to read the book from the desk than to keep getting up and fetching it from the shelf every time you need to read something.

RAM provides the working space for the programs you're using right now. If you have more RAM, you can keep more programs and data readily available, which helps your computer run smoothly when multitasking or using memory-intensive applications like video editing software or games.

The article also includes the concept of POINTERS (variables that store memory addresses as values).

The term "Kernel mode" refers to a privileged and protected operating system state in a computer's central processing unit (CPU). In this mode, the operating system's core components have direct access to hardware and memory, allowing them to manage system resources, run critical tasks, and maintain security. Applications run in a separate, less privileged mode called "user mode," which has limited access to hardware and requires the operating system's assistance to perform certain tasks. The separation between kernel mode and user mode helps ensure the stability, security, and efficient operation of the computer system.

Now, let's discuss what happens when a computer runs a program.

When a computer runs a program, it usually does so in a special mode called "user mode," which is like a safe sandbox. However, some tasks, such as using hardware or performing important system operations, require more power. Therefore, the operating system has a super-powerful mode called "kernel mode."

When a program starts, the operating system sets things up. If the program needs to perform powerful actions, it asks the operating system for help using a "system call." This is similar to sending a special request to the operating system.

The operating system then switches the CPU to the super-powerful "kernel mode," where it can perform important tasks directly. After the task is completed, the CPU returns to the safer "user mode."

So, think of "kernel mode" as the superhero mode that the operating system uses to help programs do really important and powerful things. And "system calls" are like the special requests these programs use to call on the superhero for assistance!

Β