Sophie

Sophie

distrib > CentOS > 6 > i386 > by-pkgid > cf93d8a8acdcc6fe2225039da0502495 > files > 2167

kernel-doc-2.6.32-131.17.1.el6.centos.plus.noarch.rpm

<?xml version="1.0" encoding="ANSI_X3.4-1968" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968" /><title>Software Interrupt Context: Softirqs and Tasklets</title><meta name="generator" content="DocBook XSL Stylesheets V1.75.2" /><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel" /><link rel="up" href="ch02.html" title="Chapter&#160;2.&#160;The Players" /><link rel="prev" href="ch02s02.html" title="Hardware Interrupts (Hard IRQs)" /><link rel="next" href="ch03.html" title="Chapter&#160;3.&#160;Some Basic Rules" /></head><body><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Software Interrupt Context: Softirqs and Tasklets</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a>&#160;</td><th width="60%" align="center">Chapter&#160;2.&#160;The Players</th><td width="20%" align="right">&#160;<a accesskey="n" href="ch03.html">Next</a></td></tr></table><hr /></div><div class="sect1" title="Software Interrupt Context: Softirqs and Tasklets"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="basics-softirqs"></a>Software Interrupt Context: Softirqs and Tasklets</h2></div></div></div><p>
    Whenever a system call is about to return to userspace, or a
    hardware interrupt handler exits, any 'software interrupts'
    which are marked pending (usually by hardware interrupts) are
    run (<code class="filename">kernel/softirq.c</code>).
   </p><p>
    Much of the real interrupt handling work is done here.  Early in
    the transition to <acronym class="acronym">SMP</acronym>, there were only 'bottom
    halves' (BHs), which didn't take advantage of multiple CPUs.  Shortly 
    after we switched from wind-up computers made of match-sticks and snot,
    we abandoned this limitation and switched to 'softirqs'.
   </p><p>
    <code class="filename">include/linux/interrupt.h</code> lists the
    different softirqs.  A very important softirq is the
    timer softirq (<code class="filename">include/linux/timer.h</code>): you can
    register to have it call functions for you in a given length of
    time.
   </p><p>
    Softirqs are often a pain to deal with, since the same softirq
    will run simultaneously on more than one CPU.  For this reason,
    tasklets (<code class="filename">include/linux/interrupt.h</code>) are more
    often used: they are dynamically-registrable (meaning you can have
    as many as you want), and they also guarantee that any tasklet
    will only run on one CPU at any time, although different tasklets
    can run simultaneously.
   </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>
     The name 'tasklet' is misleading: they have nothing to do with 'tasks',
     and probably more to do with some bad vodka Alexey Kuznetsov had at the 
     time.
    </p></div><p>
    You can tell you are in a softirq (or tasklet)
    using the <code class="function">in_softirq()</code> macro 
    (<code class="filename">include/linux/interrupt.h</code>).
   </p><div class="caution" title="Caution" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Caution</h3><p>
     Beware that this will return a false positive if a bh lock (see below)
     is held.
    </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="ch02s02.html">Prev</a>&#160;</td><td width="20%" align="center"><a accesskey="u" href="ch02.html">Up</a></td><td width="40%" align="right">&#160;<a accesskey="n" href="ch03.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Hardware Interrupts (Hard IRQs)&#160;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top">&#160;Chapter&#160;3.&#160;Some Basic Rules</td></tr></table></div></body></html>