Android from the foundation · Puzzle 4 of 16

The post office carries letters

system_server and your app are separate processes, so the town hall can't just reach in. The kernel carries its messages.

The problem

In puzzle 3, system_server decided to move your Activity to "resumed". But system_server is a process, and so is your app, and in puzzle 0 you saw that one process can't touch another's memory. So how does the town hall's decision get into your app?

See it

system_server writes a message; it can't reach into your app, so Binder in the kernel carries it there kernel system_server your app Binder resume
  1. The town hall, system_server, and your app are two separate processes, both standing on the kernel.

    Step 1 of 4
  2. The town hall writes a message: "resume your screen". But it can't reach into your app's memory. Predict: who can?

    Step 2 of 4
  3. Only the kernel reaches every process. It's built from parts that each do one job; each such part is called a driver. The one that carries messages is Binder: the post office. It carries them both ways.

    Step 3 of 4
  4. Binder delivers the message into your app. Every message between your app and the town hall travels this way.

    Step 4 of 4

The building block

Only the kernel can reach into every process (puzzle 1). So the kernel carries the message.

The kernel is made of parts that each do one job; such a part is called a driver. The driver that carries messages between processes is called Binder. Every message between your app and system_server travels through Binder, in both directions.

The analogy

The post office. The town hall writes a letter; it can't walk into your house, but the post office can deliver to every house on the street.

Check yourself

system_server wants your Activity to pause. Can it change your app's memory directly?

Not quite. Being Android's own process doesn't give it access to yours. Only the kernel reaches into every process.

Right. Separate processes never touch each other's memory; Binder carries the message.

Why does the message go through the kernel?

Right. The kernel is the only code that can reach any process, so it does the carrying.

Not quite. The kernel only carries the letter. The decision was the town hall's.

What's the difference between Binder and system_server?

Not quite. Binder is a part of the kernel, the post office. system_server is a process, the town hall.

Right. The post office delivers; the town hall decides.

Sources

What you now know

Between processes, nothing is reached directly. Binder, a driver in the kernel, carries the message, like a post office.