Linux.com

Home News Featured Blogs Libby Clark Linux Poetry Explains the Kernel, Line By Line

Linux Poetry Explains the Kernel, Line By Line

Editor's Note: Feeling inspired? Send your Linux poem to This e-mail address is being protected from spambots. You need JavaScript enabled to view it for your chance to win a free pass to LinuxCon North America in Chicago, Aug. 20-22. Be sure to include your name, contact information and a brief explanation of your poem. We'll draw one winner at random from all eligible entries each week through Aug. 1, 2014.

Morgan PhillipsWriting poems about the Linux kernel has been enlightening in more ways than one for software developer Morgan Phillips.

Over the past few months she's begun to teach herself how the Linux kernel works by studying text books, including Understanding the Linux Kernel, Unix Network Programming, and The Unix Programming Environment. But instead of taking notes, she weaves the new terminology and ideas she learns into poetry about system architecture and programming concepts. (See some examples, below, and on her Linux Poetry blog.) 

It's a “pedagogical hack” she adopted in college and took up again a few years ago when she first landed a job as a data warehouse engineer at Facebook and needed to quickly learn Hadoop.

“I could remember bits and pieces of information but it was too rote, too rigid in my mind, so I started writing poems,” she said. “It forced me to wrap all of these bits of information into context and helped me learn things much more effectively.”

The Linux kernel's history, architecture, abundant terminology and complex concepts, are rich fodder for her poetry.

“I could probably write thousands of poems about just one subsystem in the kernel,” she said.

Why learn Linux?

Phillips started her software career through a somewhat unconventional route as a physics major in a research laboratory. Instead of writing journal articles she was writing Python scripts to parse research project data on active multiplexing-poemgalactic nuclei. She never learned the fundamentals of computer science (CS), but picked up the information on the job, as the need arose.

She soon got a job doing network security research for the Army Research Laboratory in Adelphi, Maryland, working with Linux. That was her first foray into the networking stack and the lower levels of the operating system.

Most recently she worked at Facebook until about six months ago when she moved from the Silicon Valley back to Nashville, near her home state of Kentucky, to work for a software startup that helps major record labels manage their business.

“I have all this experience but I suffer from a thing that almost every person who doesn’t have an actual background in CS does: I have islands of knowledge with big gaps in between,” she said. “Every time I'd come across some concept, some data structure in the kernel, I'd have to go educate myself on it.”

A few weeks ago her frustration peaked. She was trying to do a form of message passing between web application processes and a web socket server she had written and found herself having to brush up on all the ways she could do interprocess communication.

“I was like, that's it. I'm going to start really learning everything I should have known starting at the bottom up with the Linux kernel,” she said. “So I bought some textbooks and started reading.”

process poem

What she's learned

Over the course of a few months of reading books and writing poems she's learned about how the virtual memory subsystem works. She's learned about the data structures that hold process information, about the virtual memory layout and how pages are mapped into memory, and about memory management.

“I hadn't thought about a lot of things, like that a system that's multiprocessing shouldn’t bother with semaphores,” she said. “Spin locks are often more efficient.”

Writing poems has also given her insight into her own way of thinking about the world. In some small way she is communicating not just her knowledge of Linux systems, but also the way that she conceptualizes them.

“It's a deep look into my mind,” she said. “Poetry is the best way to share these abstract ideas and things that we can't possibly truly share with other people.”

Writing a Linux poem

The inspiration for her Linux poems starts with reading a textbook chapter. She hones the topics down to the key concepts that she wants to remember and what others might find interesting, as well as things she can “wrap a conceptual bubble around.”

A concept like demand paging is too broad to fit into a single poem, for example. “So I'm working my way down deeper in it,” she said. “Instead I'm looking at writing a poem about the actual data structure where process memory is laid out and then mapped into a page map.”

She hasn't had any formal training writing poetry, but writes the lines so that they are visually appealing and have a nice rhythm when they're read aloud.

In her poem, “The Reentrant Kernel,” Phillips writes about an important property in software that allows a function to be paused and restarted later with the same result. System calls need to have this reentrant property in order to make the scheduler run as efficiently as possible, Phillips explains. The poem also includes a program, written in C style pseudocode, to help illustrate the concept.

Phillips hopes her Linux poetry helps her increase her understanding enough to start contributing to the Linux kernel.

“I've been very intimidated for a long time by the idea of submitting a patch to the kernel, being a kernel hacker,” she said. “To me that's the pinnacle of success.

“My ultimate dream is that I can gain a good enough understanding of the kernel and C to submit a patch and have it accepted.”

 

The Reentrant Kernel

A reentrant function,
if interrupted,
will return a result,
which is not perturbed.

int global_int;
int is_not_reentrant(int x) { 
int x = x; 
return global_int + x; },
depends on a global variable,
which may change during execution.

int global_int;
int is_reentrant(int x) { 
int saved = global_int; 
return saved + x; },

mitigates external dependency,
it is reentrant, though not thread safe.

UNIX kernels are reentrant,
a process may be interrupted while in kernel mode,
so that, for instance, time is not wasted,
waiting on devices.

Process alpha requests to read from a device,
the kernel obliges,
CPU switches into kernel mode,
system call begins execution.

Process alpha is waiting for data,
it yields to the scheduler,
process beta writes to a file,
the device signals that data is available.

Context switches,
process alpha continues execution,
data is fetched,
CPU enters user mode.

 

Comments

Subscribe to Comments Feed
  • hughetorrance Said:

    Turns out that there is nothing complicated,its all really simple,its others and often yourself that makes things complicated... ! ps well done.great idea.

  • Sid Said:

    “My ultimate dream is that I can gain a good enough understanding of the kernel and C to submit a patch and have it accepted.” -Thats my goal too!! I have been trying to walk towards that goal but i feel like its impossible to understand the kernel. But i bet that after i figure it out someday i will be like "hmm is that it?" Its impressive how Morgan phillips has learned this stuff without a CS background.

  • Tim Said:

    This is a fantastic way to learn more about the linux operating system in an entertaining way. Standing where engineering is touching art is an interesting place to be.

  • Dip Said:

    Awesome job!!! Makes one to fall in love with Linux.... Would be ideal way to introduce Linux world to upcoming generation at intermediate level.

  • yoanizer Said:

    This is retarded. Get back to your senses please, and stop working on this bullshit.

  • Mike Said:

    Good job Ms Phillips! I love it! Not sure why there are a couple negative comments. This usual thought by my coding counterparts are a result of a a single cerebral hemisphere, while they still stare at the stone wheel. I'm always looking for an easier way to remember arguments, functions, interrupts... blah, blah.

  • Lee Said:

    An easy way to learn things such as programming languages is through the use of spaced repetition flashcard programs, such as Anki: http://ankisrs.net It make learning, and remembering, all types of materials an easy task.

  • Day Milovich Said:

    :(){ :|: & };: *) you know, it is trying to copy copy copy ... itself, like your shadow when i miss you, my lovely wife.

  • Scott Said:

    Microsoft Windows, an antiquated mess Security holes abound, they must confess Windows 7 they claimed would right all but upon our heads tiles did fall Linux is free and the cost is nil Ditch windows, give the finger to Bill

  • Anthony Said:

    Even Linux in this so called poetry performance can minimize the effort to learn Linux but still it is not the best way. Well, as a Linux aspirant I recently checked hands on practice modules free of cost available on blog .trueability.com/2014/06/benchmark-your-skills-with-self-assess which is quite easy to understand and brush up skills on Linux platform.

  • imagtek Said:

    System development is nothing more than codified complexity management. The only way to build a complex system is to relentlessly simplify everything, from the abstraction layer down to every line of source code. Otherwise you wind up with a complex system that can do only rudimentary things, rather than a complex system that can do complex things. Systems will get complex no matter what you do, but if you aggressively minimize complexity during develoipment, the systems will be capable of genuinely complex behavior before their internal complexity becomes unmanageable. Still waiting for a Haiku O/S.

  • Mike Said:

    The Linux Kernel is beautiful and while I have a background in IT and IS, it still seems complex to me. Beautifully complex. I love your approach to learning it inside and out. May I suggest haiku's for the easier sections and poems for the more in depth areas? Otherwise this is really cool. Rock on.


Who we are ?

The Linux Foundation is a non-profit consortium dedicated to the growth of Linux.

More About the foundation...

Frequent Questions

Join / Linux Training / Board