November 15th, 2008


New sleep state for processes in Linux: TASK_KILLABLE.

The Linux kernel provides two ways to put a process to sleep.

The normal way to put a process to sleep is to set the process's state to either TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE and call the scheduler's function schedule(). This results in the process getting moved off from the CPU run queue. If the process is sleeping in interruptible mode (by setting its state to TASK_INTERRUPTIBLE), it can be awakened either by an explicit wake-up call (wakeup_process()) or by signals needing processing.

However, if the process is sleeping in uninterruptible mode (by setting its state to TASK_UNINTERRUPTIBLE), it can only be awakened by an explicit wake-up call. It is advised to put the processes into interruptible sleep mode rather than uninterruptible sleep mode unless you really, really need to (such during device I/O when processing signals is difficult).

But be cautious of cases where the wakeup call on the process sleeping uninterruptibly could not happen for some reason, making the process unkillable, which will eventually cause frustration since the only way out is a system reboot. On one hand, you need to take care of some details, because doing otherwise will introduce bugs both on the kernel and on the user side. On the other hand, you may get deadly immortals (blocked and unkillable processes).

10k hours = mastery.

By the age of 20, the elite performers had all totalled 10,000 hours of practice over the course of their lives. The merely good students had totalled, by contrast, 8,000 hours, and the future music teachers just over 4,000 hours.

The curious thing about Ericsson's study is that he and his colleagues couldn't find any "naturals" - musicians who could float effortlessly to the top while practising a fraction of the time that their peers did. Nor could they find "grinds", people who worked harder than everyone else and yet just didn't have what it takes to break into the top ranks. Their research suggested that once you have enough ability to get into a top music school, the thing that distinguishes one performer from another is how hard he or she works. That's it. What's more, the people at the very top don't just work much harder than everyone else. They work much, much harder.

This idea - that excellence at a complex task requires a critical, minimum level of practice - surfaces again and again in studies of expertise. In fact, researchers have settled on what they believe is a magic number for true expertise: 10,000 hours. "In study after study, of composers, basketball players, fiction writers, ice-skaters, concert pianists, chess players, master criminals," writes the neurologist Daniel Levitin, "this number comes up again and again. Ten thousand hours is equivalent to roughly three hours a day, or 20 hours a week, of practice over 10 years... No one has yet found a case in which true world-class expertise was accomplished in less time. It seems that it takes the brain this long to assimilate all that it needs to know to achieve true mastery."