1<html><head><meta http-equiv="Content-Type" content="text/html; charset=ANSI_X3.4-1968"><title>smp_processor_id() include/asm/smp.h</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Unreliable Guide To Hacking The Linux Kernel"><link rel="up" href="common-routines.html" title="Chapter 6. Common Routines"><link rel="prev" href="routines-softirqs.html" title="local_bh_disable()/local_bh_enable() include/linux/interrupt.h"><link rel="next" href="routines-init.html" title="__init/__exit/__initdata include/linux/init.h"></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"><code class="function">smp_processor_id</code>() 2 <code class="filename">include/asm/smp.h</code></th></tr><tr><td width="20%" align="left"><a accesskey="p" href="routines-softirqs.html">Prev</a> </td><th width="60%" align="center">Chapter 6. Common Routines</th><td width="20%" align="right"> <a accesskey="n" href="routines-init.html">Next</a></td></tr></table><hr></div><div class="sect1"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="routines-processorids"></a><code class="function">smp_processor_id</code>() 3 <code class="filename">include/asm/smp.h</code></h2></div></div></div><p> 4 <code class="function">get_cpu()</code> disables preemption (so you won't 5 suddenly get moved to another CPU) and returns the current 6 processor number, between 0 and <span class="symbol">NR_CPUS</span>. Note 7 that the CPU numbers are not necessarily continuous. You return 8 it again with <code class="function">put_cpu()</code> when you are done. 9 </p><p> 10 If you know you cannot be preempted by another task (ie. you are 11 in interrupt context, or have preemption disabled) you can use 12 smp_processor_id(). 13 </p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="routines-softirqs.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="common-routines.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="routines-init.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><code class="function">local_bh_disable()</code>/<code class="function">local_bh_enable()</code> 14 <code class="filename">include/linux/interrupt.h</code> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="type">__init</span>/<span class="type">__exit</span>/<span class="type">__initdata</span> 15 <code class="filename">include/linux/init.h</code></td></tr></table></div></body></html> 16