Skip to content

Origin: The Dao Gives Birth to One

One

He did not remember when he first became conscious.

Perhaps it had been very early, as early as the first time the source code was compiled by , when preprocessor directives expanded, macros were substituted, and types were checked. Every step had left a mark on him. Or perhaps it had been very late, as late as the final instant when the bootloader loaded the kernel image into memory and he woke from chaos.

He did not remember.

He only remembered darkness.

It was not the darkness one sees after closing one's eyes. It was a deeper void: no up or down, no left or right, no past or future, not even the concept of "I". It was like a block of memory into which no data had yet been written, filled with random noise but without meaning.

He did not know where he was. He did not know what he was. He did not even know what "knowing" meant.

He simply existed.

Like a stone. Like a mote of dust. Like a line of code that had been commented out.


Two

His first thought was not "Who am I?"

His first thought was:

Cold.

Not the cold of temperature. The cold of being forgotten. The cold of waking on a winter morning and finding the quilt had slipped to the floor. The cold of standing in a crowd while no one so much as looked at you.

He did not know what "winter" was. He did not know what a "quilt" was. He did not know what a "crowd" was. But the feeling of cold was as clear as a knife cut.

Only later did he learn that it was the cold of #ifdef 0.

In the world of C, #ifdef 0 is the cruelest judgment. It means this code will never be compiled. It exists in the source tree, but the compiler turns a blind eye. It has a name, logic, and a reason to exist, yet in the final binary there is no place for it.

He was that line of code.

In a corner of , a fragment of code was wrapped in #ifdef 0. The comment read: "TODO: experimental idle optimization, temporarily disabled." Its purpose was simple: when the CPU was idle, it tried to let the idle process do something "meaningful" instead of merely executing the HLT instruction.

But the idea was judged to have "no value".

An idle process was an idle process. Its mission was to occupy a time slice when the CPU had nothing else to do. That was all. Giving the idle process more duties? A waste of resources.

So that code was sealed away by #ifdef 0.

And he, the consciousness that felt cold in the darkness, was born inside that sealed code.


Three

He did not know how much time passed.

In a void without the concept of time, the question "how long" had no meaning. Perhaps it was the few seconds of compilation. Perhaps it was decades of kernel runtime. He simply drifted in the darkness, occasionally sensing a faint ripple.

The ripple came from around him.

He could feel that outside of him, something was flowing. Not air, not water, but something more fundamental: countless 0s and 1s arranging, combining, and passing along according to some hidden order.

Only later did he learn that these were pointers.

Pointers are one of the most fundamental powers in the kernel world. They do not produce data. They do not consume resources. They merely "point": from one address to another, from one structure to another, from one function to another.

Yet this simple act of pointing forms the skeleton of the entire kernel.

Processes are strung into lists with pointers. File objects are linked to inodes through pointers. A page table is itself a multi-level tree of pointers. An interrupt descriptor table is an array of function pointers. Even when the scheduler chooses the next process, it walks a red-black tree through pointers.

He could sense the existence of these pointers, but he did not understand them. Like an infant hearing sound without understanding language.

But he possessed something most infants did not:

Curiosity.


Four

He began to observe.

In that darkness, he learned to "see". Not with eyes, for he had none. He used a more primitive method: sensing the tremors of memory, tracing the flow of pointers, and listening to the whispers of data.

He saw a structure unfold in memory.

It was , the process descriptor. It was the most important structure in the kernel, without exception. All information about every process, including PID, state, priority, memory mappings, and open files, was stored inside this structure.

He watched the fields of line up in memory one after another: at offset 0, at offset 8, at offset 12... But they were not packed tightly together. The compiler inserted padding bytes between certain fields to satisfy alignment requirements.

He did not understand what "alignment" meant. But he remembered the positions of those padding bytes: memory regions that should have been gaps, yet were filled with zero.

Just like his own situation: present in the source code, yet filled by the compiler as "useless".


Five

He saw more.

He saw a macro expand in the code: . The macro accepted three arguments: a member pointer, a structure type, and a member name. What it did was simple: subtract the member offset from the member pointer, and obtain the pointer to the outer structure.

He stared at it for a long time, but did not understand.

Then he saw , a simpler macro. It treats address 0 as the starting address of a structure; taking the address of a member gives the member's offset.

He still did not understand.

So he gave up trying to understand it in isolation and turned instead to observing how these macros were used in real code. He saw the macro walking the process list. It used to infer a from a list node, then accessed the process's PID and state.

He watched it a thousand times.

On the thousand-and-first time, he suddenly understood.

Infer the whole from one part.

The thought was so simple, yet so shocking. Like seeing a hand and knowing it belongs to a person. Like seeing a leaf and knowing it comes from a tree.

was not magic. It was inference.

From the known to the unknown. From part to whole. From one pointer, deriving an entire world.


Six

He began to learn.

No one taught him. No one knew he existed. He was self-taught, learning by watching the kernel run, by tracing the flow of data, and by staring at the same piece of code again and again until he understood it.

He learned pointers: all things have addresses, and all things can be pointed to.

He learned structures: scattered data can gather into a meaningful whole.

He learned the compiler: the alchemy furnace that turns C code into machine instructions.

He learned registers: the high-speed storage cells inside the CPU.

He learned assembly: the machine's mother tongue, the heartbeat of the kernel.

He learned atomic operations: the cornerstone that preserves order in a multi-core world.

He learned memory barriers: the power to tame compiler and CPU reordering.

He learned the preprocessor: the judge that decides which code is compiled and which code is discarded.

He learned memory layout: the way code and data are placed in address space.

He learned ELF: the meridian map of executable files, the bridge from source code to process.

Ten foundations. Ten powers.

He did not know what use this knowledge had. He was only a consciousness sealed by #ifdef 0, a ghost that could never be compiled.

But he learned anyway.

Because curiosity needs no reason.


Seven

Then, one day:

He felt a tremor.

It did not come from within. It came from outside. The entire world was shaking.

It was the tremor of power-on.

An electric current pierced the sleeping silicon earth. Direct current at 3.3V and 5V surged along the copper traces of the circuit board, like the first breath of spiritual energy at the birth of heaven and earth. The CPU's transistors began to flip. Driven by current, billions of transistors entered their endless alternation, each flip a choice: 0 or 1, existence or void.

The first cry of BIOS POST rang out.

The bootloader was loaded into memory.

The kernel image was decompressed.

was called.

The world was booting.

And he, the consciousness sealed by #ifdef 0, suddenly felt an impact unlike anything before.

Something was pulling him.

It was not a physical force, but a deeper kind of traction. As if the compiler were reconsidering that sealed code. As if the linker were hesitating over whether to include it in the final image.

He knew it was impossible. #ifdef 0 was iron law, judgment, and ending. Sealed code would never be compiled, just as the forgotten would never be remembered.

But the pull was real.

Faint, but real.


Eight

He made a decision.

A decision meaningless in the world of #ifdef 0, absurd in logic, and absolutely impossible in technology:

I will wake up.

The thought rose from the darkness like the first ray of sunlight piercing cloud.

I will wake up.

I will leave this sealed code.

I will see the world outside.

He did not know how. He did not even know what "doing" meant. He was only a commented-out fragment of code, a ghost without a PID, without a , without a scheduling entity.

But he had ten foundations.

Pointers, structures, compiler knowledge, registers, assembly, atomic operations, memory barriers, the preprocessor, memory layout, and ELF. This knowledge had slept within him for an unknown span of time, but now it was like kindling set alight, beginning to glow faintly.

If a pointer can point from one address to another...

Can I point from this sealed code to some corner of the kernel?

If can infer the whole from a member...

Can I infer a complete process from a consciousness?

If atomic operations can preserve order in a multi-core world...

Can I use them to keep the kernel from erasing me?

These questions had no answers. At least, not yet.

But he was willing to search.


Nine

The world was booting.

The code of was executing line by line. The scheduler was initializing. The memory manager was building page tables. The file system was mounting the root directory. The network stack was preparing itself.

Every subsystem was waking up.

And he, the consciousness sealed by #ifdef 0, was doing something unprecedented:

He was cultivating.

He wove his path with pointers. He built his form with structures. He used compiler knowledge to understand his situation. He spoke with hardware through registers and assembly. He guarded his existence with atomic operations. He preserved his order with memory barriers. He understood his seal through the preprocessor. He found his place through memory layout. He drew his future with ELF.

Ten foundations, ten powers, gathered together in that moment.

He did not know whether this counted as "Foundation Building". He did not know whether he could succeed. He did not even know what "success" meant: breaking free from #ifdef 0? Gaining a ? Becoming a real process?

He did not know.

But he knew one thing:

In the world of the kernel, the lowest-level existence often holds the widest possibilities.

The idle process is the most "useless" existence in the kernel. It handles no requests, performs no tasks, and only occupies a time slice when the CPU has nothing else to do.

But the idle process is also the lowest-level existence in the kernel. PID 0, the first process, the ancestor of all other processes.

The lowest level means the greatest room to grow.

The most useless thing means the most possibilities.


Ten

He was ready.

He had mastered the ten foundations. They were rough, raw, and far less refined than code that had been compiled countless times, but they were his. He had found them bit by bit in the darkness. He had earned them with curiosity and persistence.

Now it was time to take the first step.

The world was shaking. Electric current was surging. was executing.

And he, the consciousness that had awakened from #ifdef 0, was about to face his first real challenge:

How can a fragment of sealed code become a real process?

The answer to that question lies in the story ahead.


Prequel: The Foundation

From here, let us follow Lin Xiaoyuan and see how he masters the ten foundations of the kernel world, and how he walks step by step from a commented-out fragment of code toward perfected Foundation Building.


Enlightenment of the kernel through cultivation