The "SPL" Split Instruction and OS Multitasking: fork() and the Parallelism Trade-Off
How spawning multiple execution pointers grants near-immortality while dividing per-thread execution speed by 1/N
Until now, your program had only one glowing execution pointer. If that single pointer stepped on a DAT, you lost immediately. Enter SPL (Split)—the mitotic instruction that splits your execution pointer into multiple concurrent processes!
- Executing SPL spawns a new process in your queue (1 ➔ 2 ➔ 3 ➔ 4...). - As long as at least one of your processes survives, your Warrior stays alive even if another process hits a bomb!
🎯 Your Task (No Editing Needed) Press [STEP] several times or press [PLAY] to watch your processes multiply and march forward together!
1. Fragile Mortality vs. Mitotic Division ("SPL")
From Step 1 through Step 21, every warrior you ran possessed only a single glowing execution pointer (one Program Counter). Having a single thread of execution means living on a knife's edge: if that lone pointer ever steps onto a DAT bomb, your warrior is wiped out instantaneously.
Step 22 shatters that limitation with the introduction of CoreWar's most magical instruction: "SPL" (Split). As you stepped through "SPL.A $0, #0" followed by "MOV.I $0, $1", you watched your warrior's active process count multiply—from 1 to 2, 3, 4, and beyond—like a biological cell undergoing mitosis!
Recall the fundamental survival rule of CoreWar: a warrior loses only when ALL of its processes have terminated. If you use SPL to split your organism into 16 parallel processes, an enemy bomber can blow up 15 of your threads with DAT bombs, and as long as the 16th process survives elsewhere in memory, your organism remains alive and fighting!
Executing: [0000] SPL.A $Target
│
┌─────────────┴──────────────────────────┐
▼ (1st in FIFO Queue) ▼ (2nd in FIFO Queue)
[Parent Process]: Steps to PC + 1 (0001) [Child Process]: Jumps to $Target!2. UNIX fork() and MARS Round-Robin Task Scheduling
Under the hood, the "SPL" instruction is a pure, visual miniature of the "fork()" system call and multi-threaded task scheduling found at the heart of UNIX, Linux, macOS, and Windows kernels.
When a process at Address PC executes "SPL.A $Target", the MARS virtual operating system performs two actions atomically: 1. PARENT PROCESS: The original execution pointer advances to the next sequential instruction (PC + 1) and is placed at the back of your warrior's Process Queue (a First-In, First-Out / FIFO queue). 2. CHILD PROCESS: A brand-new execution pointer is spawned pointing to the destination address (PC + $Target) and is queued immediately behind the parent process.
How does MARS execute a warrior that has 4 active processes (say, Threads P1, P2, P3, and P4) in its queue? It uses classic Round-Robin Time-Sharing! Each time your warrior's turn arrives, MARS pops ONLY ONE process (P1) from the front of your FIFO queue, executes its single instruction, and pushes P1 to the back of the line. On your next turn, P2 runs one instruction; on the turn after that, P3 runs; then P4; and only on the 5th turn does P1 get to move again.
3. The Fundamental Law of Parallelism: Redundancy vs. The 1/N Speed Penalty
This brings us to a profound law of computer architecture and parallel systems: Why not just execute SPL a thousand times immediately to become invincible?
Because in MARS (just like on a single-core CPU), your warrior receives a fixed budget of ONE instruction cycle per turn, regardless of how many processes are in your queue! - With 1 process: That lone process runs on 100% of your turns, moving and firing at maximum speed. - With 4 processes: Each individual process only gets to execute once every 4 turns—cutting each thread's speed to 1/4 (25%)! - With 100 processes: Each thread is starved for CPU cycles, creeping forward at 1/100th normal speed while a single-threaded enemy Stone bomber runs circles around it at full speed!
Spawning processes via SPL trades Individual Thread Speed (1/N) for Distributed Redundancy (survivability). Balancing this exact trade-off between mitotic replication and metabolic speed is the secret to mastering multi-process organisms in Chapter 5. Notice also how the ordering inside the FIFO queue matters: when a parent process executes "SPL $Target", the parent is scheduled BEFORE the newly spawned child on the next round of turns. This subtle scheduling rule (defined in the ICWS-94 specification) ensures that a parent copying loop can finish initializing a structure before the child thread begins executing it.
🔒 MISSION CLEAR Unlocks the Full Lecture Note
Complete the experiment in the simulator above to automatically unlock the full deep-dive article—or click below to read the full text immediately.