Saturday, November 4, 2006

Upgrading His Memory

It started with a question about upgrading the memory on his computer. That led to a conversation of bits and bytes and a question about which is which and what they mean. That led to a conversation about pixels and how many bits they take, which returned us to the topic of memory and whether he needed more.

We had a conversation of RAM memory and hard disks. That led us to a conversation about operating systems and virtual memory. And in order to motivate the need for that, we covered multitasking and Unix processes. If you look at the picture I drew, you'll clearly see where our conversation ended up: with chunks of memory being swapped from RAM to disk (pages-out) and back (pages-in). And that was the answer to his memory upgrades question: his ratio of pages-out to pages-in was too high.

He was remarkably patient thru all this: paying attention, studying my diagrams, asking good questions. I have tried to get him interested in such things in the past to no avail, so I smiled inwardly at his evident interest.

Later in the evening, we came back to the subject.

Do you want to see how to write a Unix process? I asked. He answered by pulling up a chair.

I showed him main() and waved my hands at printf() and fflush(). We throttled the process with nanosleep(), which he seemed to absorb with little difficulty. And we watched the process consume more or less of the CPU, depending on how we throttled it.

But then I took it too far.

I went on about return codes and shell scripts, and his eyes began to droop. I ran into a compiler warning, and his head began to nod. I searched in vain for the typo I had somehow introduced into the code, and he jerked in his seat.

Dad, he said. I need to go to bed.

Ok. Good night, Ben, I said.

Inwardly my smile was undaunted.


11:24:35 PM   permalink: []   feedback: Click here to send an email to the editor of this weblog.   comments: []