<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dan.thoughts &#187; Linux</title>
	<atom:link href="http://blog.sosedoff.com/tag/linux/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sosedoff.com</link>
	<description>Web-development, PHP, Ruby, Sinatra, Merb, Rails, MySQL, SQLite, Web Services.</description>
	<lastBuildDate>Sat, 03 Jul 2010 05:46:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Setting processor affinity for a certain task or process in Linux</title>
		<link>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/</link>
		<comments>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/#comments</comments>
		<pubDate>Mon, 07 Jun 2010 01:43:37 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Shell Scripting]]></category>
		<category><![CDATA[cores]]></category>
		<category><![CDATA[processing]]></category>
		<category><![CDATA[smp]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=218</guid>
		<description><![CDATA[When you are using SMP you might want to override the kernel&#8217;s process scheduling and bind a certain process to a specific CPU(s).
What is this?
CPU affinity is nothing but a scheduler property that &#8220;bonds&#8221; a process to a given set of CPUs on the SMP system. The Linux scheduler will honor the given CPU affinity [...]]]></description>
			<content:encoded><![CDATA[<p>When you are using <a href="http://en.wikipedia.org/wiki/Symmetric_multiprocessing">SMP</a> you might want to override the kernel&#8217;s process scheduling and bind a certain process to a specific CPU(s).</p>
<h4>What is this?</h4>
<p>CPU affinity is nothing but a scheduler property that &#8220;bonds&#8221; a process to a given set of CPUs on the SMP system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU affinity:</p>
<blockquote><p>The scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications. For example, application such as Oracle (ERP apps) use # of cpus per instance licensed. You can bound Oracle to specific CPU to avoid license problem. This is a really useful on large server having 4 or 8 CPUS</p></blockquote>
<h4>Setting processor affinity for a certain task or process using taskset command</h4>
<p>taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affinity. However taskset is not installed by default. You need to install schedutils (Linux scheduler utilities) package.</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">apt-get</span> <span style="color: #c20cb9; font-weight: bold;">install</span> shedutils</pre></div></div>

<p>Under latest version of Debian / Ubuntu Linux taskset is installed by default using util-linux package.</p>
<p>The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. For example:</p>
<ul>
<li>0&#215;00000001 is processor #0 (1st processor)</li>
<li>0&#215;00000003 is processors #0 and #1</li>
<li>0&#215;00000004 is processors #2 (3rd processor)</li>
</ul>
<p>To set the processor affinity of process 13545 to processor #0 (1st processor) type following command:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ taskset 0x00000001 <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span></pre></div></div>

<p>If you find a bitmask hard to use, then you can specify a numerical list of processors instead of a bitmask using -c flag:</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">$ taskset <span style="color: #660033;">-c</span> <span style="color: #000000;">1</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span>
$ taskset <span style="color: #660033;">-c</span> <span style="color: #000000;">3</span>,<span style="color: #000000;">4</span> <span style="color: #660033;">-p</span> <span style="color: #000000;">13545</span></pre></div></div>

<p>where  -p : Operate on an existing PID and not launch a new task (default is to launch a new task)</p>
<p><small>via <a href="http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html">http://www.cyberciti.biz/tips/setting-processor-affinity-certain-task-or-process.html</a></small></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2010/06/06/setting-processor-affinity-for-a-certain-task-or-process-in-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Writing simple daemons in C</title>
		<link>http://blog.sosedoff.com/2009/02/13/writing-simple-daemons-in-c/</link>
		<comments>http://blog.sosedoff.com/2009/02/13/writing-simple-daemons-in-c/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 07:03:26 +0000</pubDate>
		<dc:creator>Dan Sosedoff</dc:creator>
				<category><![CDATA[C/C++]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[simple daemon]]></category>

		<guid isPermaLink="false">http://blog.sosedoff.com/?p=63</guid>
		<description><![CDATA[Since i started writing simple manuals about how to make system daemons i found bunch of interesting documents. For today, i just want to publish one of them instead of writing source code. This is manual originally written by Devin Watson, can be very useful for those how have no idea how to develop such [...]]]></description>
			<content:encoded><![CDATA[<p>Since i started writing simple manuals about how to make system daemons i found bunch of interesting documents. For today, i just want to publish one of them instead of writing source code. This is manual originally written by Devin Watson, can be very useful for those how have no idea how to develop such system daemons. It`s only a basic information.</p>
<p><a href="http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html">http://www.netzmafia.de/skripten/unix/linux-daemon-howto.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sosedoff.com/2009/02/13/writing-simple-daemons-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
