01Double-Click Is First Just Input
When you double-click a program icon on the desktop, the mouse doesn't know "I want to start this program." It just reports actions like movement, press, release to the computer.
The graphical interface determines which icon you double-clicked based on mouse position, click count, and current interface state, then passes the "open it" request to the system for further processing.
Mouse Action
Click twice in succession
Graphical Interface Determines
Which icon you clicked
Issue Launch Request
Request the system to open the target program
02The System First Needs to Find the Actual Program
The icon on the desktop isn't necessarily the program itself. It might be a shortcut pointing to the actual executable file on disk.
Desktop Icon
The entry you see and click
Shortcut / Launch Information
Tells the system where the real target is
Program File
Actually stored on SSD / hard drive
03How Does a Program File Become a Running Process?
Program files on disk are just statically saved data. To actually run, the operating system needs to create a running instance for it.
This running instance is usually called a process.
Program File
Saved on disk
Not "running" yetOperating System Creates Running Environment
Creates process, prepares address space, etc.
Running Process
Has its own running state and resources
04How Does a Program Enter a Runnable State?
After creating a process, the system's loading mechanism prepares the program's code, data, and needed shared libraries according to the executable file format.
Read Executable File Information
Know how code and data should be arranged
Establish Virtual Address Space
Arrange the process's own memory view
Prepare Required Components
Map program code, data, and shared libraries, etc.
Prepare Initial Thread
Let the program have threads that can be scheduled by the CPU
05When Does the CPU Actually Start Executing?
When the process and threads are ready, the operating system's scheduler will let the threads get CPU time at an appropriate moment.
Thread Ready
Already able to run
OS Scheduling
Arranges for it to get processor time
CPU Starts Executing
Begins executing instructions from near the program entry point
From this moment, the CPU is truly executing this program's machine instructions. The program continues to initialize its own data, interface, and functionality.
06Why Do You See the Window Only After a While?
After the program starts executing, it may need to do a lot of preparation work, so you usually don't see a complete window the moment you double-click.
Program Initialization
Prepare configuration, data, and internal components
Read Required Resources
Fonts, images, configuration, or other files
Create Window
Request the graphics system to display the interface
Interface Appears
Window is composed and displayed on the screen
07Is the Entire Program Copied to Memory at Once?
A common saying for beginners is: "Before a program runs, it needs to be loaded from the hard drive to memory." This direction is correct, but if understood as "the entire program file is completely copied to RAM at once," it's not accurate.
Program on Disk
Pages in Physical Memory
Modern operating systems often use demand paging: Some program pages can wait until they're actually needed before being brought into physical memory from storage devices.
What You've Learned
- Double-clicking is first mouse input, which the graphical interface then interprets as a "open program" request.
- Desktop icons might just be shortcuts; the system first needs to find the actual program file.
- Program files on disk and running processes are not the same concept.
- The operating system creates processes, prepares virtual address space, and loads or maps the code and data needed by the program.
- The program needs at least one executable thread; after the thread gets CPU time, the CPU actually starts executing instructions.
- After startup, the program continues to initialize resources and create windows, so you usually wait a while after double-clicking before seeing the interface.
- Modern systems don't necessarily copy the entire program to RAM at once; much content can be brought into physical memory on demand.
Next Question: Since programs are originally stored in SSD / hard drives, why do their code and data need to enter the memory system when running? Next article: Why Do Programs Move from Hard Drive to Memory?