YOUR C LEARNING COMPANION

Find your next idea.

Learning path
Before CChapter 3 of 73

CPU, memory, storage, and the operating system

Build a practical model of the parts involved when an ordinary computer runs a program, without mistaking that model for C’s rules.

5 min readFoundationsComputing concepts
Offline reading
In this chapter9 sections
0% through this chapter

When you open an application, several parts of your computer work together. Let us separate the jobs of the processor, working memory, storage, and operating system. We will use a typical laptop as our example; other C environments can be different.

1. The processor carries out machine operations

The CPU is the central processing unit. It executes machine instructions for tasks such as arithmetic, comparison, and moving data. Small storage locations called registers hold information it is working with. Devices and other components can also do work, so the CPU is one part of the system.

The CPU does not inherently recognize a C variable name such as apples. A language implementation connects source-level concepts to operations supported by the target system. Source names may help debugging tools, but the language does not require every named object to occupy its own permanently visible physical location.

2. Working memory supports active computation

On a typical laptop, RAM supplies much of the working storage used by running programs. Ordinary RAM loses its contents when power is lost. The processor also uses registers and caches, so every operation need not read directly from RAM.

An address identifies a location in an address space. Common operating systems use virtual addresses and map them to resources. For now, use the idea of a location without imagining a universal physical RAM coordinate. Later we will add C’s rules for pointer types, valid targets, and lifetimes.

3. Persistent storage keeps files between sessions

An SSD or hard drive commonly stores files after an application closes. These can include source code, executable programs, and saved documents. To run a program, the system makes the needed code and data available. It does not necessarily copy every related file into RAM at once.

This distinction explains why saving matters. Editing a document changes the application’s current state; writing a file requests persistence outside that working state. The details of buffering, failures, and durable storage require further care. For now, “it is currently visible on screen” and “it has been saved successfully” should not be treated as the same fact.

PartUseful first question
CPU and registersWhich operations are being executed, and on what immediate information?
Working memoryWhat information is currently available to the running program?
Persistent storageWhat has been stored as a file or other persistent record?
Operating systemWho coordinates resources, permissions, devices, and processes?

4. The operating system coordinates access

The operating system manages facilities such as processes, memory, files, and devices. Applications request services through interfaces, often using libraries. A C output call may pass through several layers before text appears. It does not directly command the display electronics.

The OS also participates in isolation and permissions. Knowing C does not automatically grant permission to read another process’s memory or access every device. A language feature and a system privilege are different things. Programs can fail because a file is missing, access is denied, or a resource is exhausted, even when the relevant C syntax is correct.

5. A program file and a process are different

A program file stores code and related information. A process, on common systems, is a running instance with its own execution state and resources. Two instances can have different current values. Changing a value in a running instance does not automatically rewrite the program file.

The desk analogy can help: storage is like a filing cabinet and working memory like materials currently on a desk. Its limits are important. Information is encoded rather than moved as a physical sheet; mappings, caches, shared resources, and optimizations do not behave like one literal desk. Keep the roles, not every physical detail of the picture.

6. C does not require a desktop operating system

C distinguishes hosted and freestanding execution environments. In a hosted environment, the language specifies familiar startup forms involving main and the full hosted library requirements. Freestanding implementations, used in settings such as firmware, have different startup and library provisions. Do not turn a diagram of a laptop into a requirement for every C implementation.

Think it through

You change a counter in a running application and close it without a successful save operation. Must the executable file now contain that counter value?

Read the explanation

No. Execution state and a stored program file have different roles. Persistence needs an appropriate successful operation; changing a working value does not itself rewrite the executable.

Primary references and further reading

Before you move on

  • The processor, working memory, storage, and operating system have different roles.
  • A running process has state that differs from the stored executable file.
  • Saving data requires a suitable successful operation beyond changing a working value.
Keep these ideas separate
Working memory / Persistent storage
Working data can disappear when a program ends; persistence depends on the storage and successful save policy.
Explain it in your own words

Why can two running copies of the same program show different current values?

Optional: say it aloud or keep a note. You can continue whenever you are ready.

Check your understanding

Optional. Answers are not saved or sent, and reading stays unrestricted.

Which distinction helps explain why unsaved work can disappear?
Read the explanation for every choice
  1. RAM and persistent storage are interchangeable.

    Working memory and persistent storage have different roles and persistence properties.

  2. Working memory and persistent storage serve different roles.

    ✓ Correct reasoning. Saving normally writes data to persistent storage; keeping a value in working memory is a different operation.

  3. A CPU permanently saves every intermediate value.

    Executing operations does not automatically create a persistent copy of every value.

General

Ready for the next idea?

Mark this chapter as read whenever you feel ready.

CHAPTER 03 / 73

In this chapter

CPU, memory, storage, and the operating system

Search all 73 chapters in both languages.EN + HG

Try “pointer”, “why int”, or “undefined behavior”.

Concepts connect. Follow your curiosity.↑ ↓ to explore · Enter to open
MAKE YOURSELF COMFORTABLE

Your reading space

Appearance

A clear canvas with balanced contrast.

Text size

100%
AA

Reading tools

Your data stays in this browser

Export a backup before changing browsers or replacing an older version of the reader.

YOUR PERSONAL MARGINS

My notebook

Saved on this device
A LITTLE CLARITY

The glossary

A starting meaning, then a chapter to go deeper.

A QUICK DEFINITION

A little clarity

Read the full explanation →

A thought worth keeping