1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>Locking Between Tasklets/Timers</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Locking"><link rel="up" href="locks.html" title="Chapter 3. Locking in the Linux Kernel"><link rel="prev" href="lock-user-timers.html" title="Locking Between User Context and Timers"><link rel="next" href="lock-softirqs.html" title="Locking Between Softirqs"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Locking Between Tasklets/Timers</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="lock-user-timers.html">Prev</a> </td><th width="60%" align="center">Chapter 3. Locking in the Linux Kernel</th><td width="20%" align="right"> <a accesskey="n" href="lock-softirqs.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="lock-tasklets"></a>Locking Between Tasklets/Timers</h2></div></div></div><div class="toc"><dl class="toc"><dt><span class="sect2"><a href="lock-tasklets.html#lock-tasklets-same">The Same Tasklet/Timer</a></span></dt><dt><span class="sect2"><a href="lock-tasklets.html#lock-tasklets-different">Different Tasklets/Timers</a></span></dt></dl></div><p> 2 Sometimes a tasklet or timer might want to share data with 3 another tasklet or timer. 4 </p><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="lock-tasklets-same"></a>The Same Tasklet/Timer</h3></div></div></div><p> 5 Since a tasklet is never run on two CPUs at once, you don't 6 need to worry about your tasklet being reentrant (running 7 twice at once), even on SMP. 8 </p></div><div class="sect2"><div class="titlepage"><div><div><h3 class="title"><a name="lock-tasklets-different"></a>Different Tasklets/Timers</h3></div></div></div><p> 9 If another tasklet/timer wants 10 to share data with your tasklet or timer , you will both need to use 11 <code class="function">spin_lock()</code> and 12 <code class="function">spin_unlock()</code> calls. 13 <code class="function">spin_lock_bh()</code> is 14 unnecessary here, as you are already in a tasklet, and 15 none will be run on the same CPU. 16 </p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="lock-user-timers.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="locks.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="lock-softirqs.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Locking Between User Context and Timers </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Locking Between Softirqs</td></tr></table></div></body></html> 17