<?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>CS Archives - Huahua&#039;s Tech Road</title>
	<atom:link href="https://zxi.mytechroad.com/blog/category/cs/feed/" rel="self" type="application/rss+xml" />
	<link>https://zxi.mytechroad.com/blog/category/cs/</link>
	<description></description>
	<lastBuildDate>Wed, 30 Dec 2020 23:18:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.8</generator>

<image>
	<url>https://zxi.mytechroad.com/blog/wp-content/uploads/2017/09/cropped-photo-32x32.jpg</url>
	<title>CS Archives - Huahua&#039;s Tech Road</title>
	<link>https://zxi.mytechroad.com/blog/category/cs/</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Consistent Hashing</title>
		<link>https://zxi.mytechroad.com/blog/cs/consistent-hashing/</link>
					<comments>https://zxi.mytechroad.com/blog/cs/consistent-hashing/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Wed, 30 Dec 2020 23:18:37 +0000</pubDate>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[consistent hashing]]></category>
		<category><![CDATA[distributed system]]></category>
		<category><![CDATA[hash]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=7879</guid>

					<description><![CDATA[<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/consistent-hashing/">Consistent Hashing</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="花花酱 Consistent Hashing - CS大讲堂 EP17" width="500" height="281" src="https://www.youtube.com/embed/lm6Zeo3tqK4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-1.png" alt="" class="wp-image-7880" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-1-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-2.png" alt="" class="wp-image-7881" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-2.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-2-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-2-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-3.png" alt="" class="wp-image-7882" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-3.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-3-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-3-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-4.png" alt="" class="wp-image-7883" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-4.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-4-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-4-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-5.png" alt="" class="wp-image-7884" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-5.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-5-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-5-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-6.png" alt="" class="wp-image-7886" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-6.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-6-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/12/consistent-hashing-ep17-6-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/consistent-hashing/">Consistent Hashing</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/cs/consistent-hashing/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Why grid[y][x] instead of grid[x][y]?</title>
		<link>https://zxi.mytechroad.com/blog/cs/why-gridyx-instead-of-gridxy/</link>
					<comments>https://zxi.mytechroad.com/blog/cs/why-gridyx-instead-of-gridxy/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Sat, 18 Jul 2020 00:59:50 +0000</pubDate>
				<category><![CDATA[CS]]></category>
		<category><![CDATA[column major]]></category>
		<category><![CDATA[cs]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[row major]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=7111</guid>

					<description><![CDATA[<p>If you don&#8217;t like grid[y][x], you can use grid[r][c] instead. [crayon-663b425fa111f959142704/]</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/why-gridyx-instead-of-gridxy/">Why grid[y][x] instead of grid[x][y]?</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<figure class="wp-block-embed-youtube wp-block-embed is-type-video is-provider-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio"><div class="wp-block-embed__wrapper">
<iframe title="Why grid[y][x] instead of grid[x][y]? - CS大讲堂 EP16" width="500" height="281" src="https://www.youtube.com/embed/P50r4CDeUYw?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-1.png" alt="" class="wp-image-7112" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-1.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-1-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-1-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<figure class="wp-block-image size-large"><img width="960" height="540" src="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-2.png" alt="" class="wp-image-7113" srcset="https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-2.png 960w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-2-300x169.png 300w, https://zxi.mytechroad.com/blog/wp-content/uploads/2020/07/grid_y_x-ep16-2-768x432.png 768w" sizes="(max-width: 960px) 100vw, 960px" /></figure>



<p>If you don&#8217;t like grid[y][x], you can use grid[r][c] instead.</p>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">#include &lt;iostream&gt;

using namespace std;

int main(int argc, char** argv) {
  constexpr int kRows = 2;
  constexpr int kCols = 3;
  int arr[kRows][kCols] = {{1,2,3},{4,5,6}};
  for (int r = 0; r &lt; kRows; ++r) {
    for (int c = 0; c &lt; kCols; ++c)
      cout &lt;&lt; arr[r][c] &lt;&lt; &quot; &quot;;
    cout &lt;&lt; endl;
  }

  for (int r = 0; r &lt; kRows; ++r)
    for (int c = 0; c &lt; kCols; ++c)
      cout &lt;&lt; &amp;(arr[r][c]) - &amp;(arr[0][0]) &lt;&lt; &quot; &quot;;
  return 0;
}

// Output:
// 1 2 3
// 4 5 6
// 0 1 2 3 4 5</pre>
</div></div>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/why-gridyx-instead-of-gridxy/">Why grid[y][x] instead of grid[x][y]?</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/cs/why-gridyx-instead-of-gridxy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Multithreading and Multiprocessing &#8211; Parallel Computing 1</title>
		<link>https://zxi.mytechroad.com/blog/cs/multithreading-and-multiprocessing-parallel-computing-1/</link>
					<comments>https://zxi.mytechroad.com/blog/cs/multithreading-and-multiprocessing-parallel-computing-1/#respond</comments>
		
		<dc:creator><![CDATA[zxi]]></dc:creator>
		<pubDate>Tue, 08 Jan 2019 08:42:47 +0000</pubDate>
				<category><![CDATA[CS]]></category>
		<guid isPermaLink="false">https://zxi.mytechroad.com/blog/?p=4618</guid>

					<description><![CDATA[<p>Multithreading [crayon-663b425fa15fa705255417/] Multiprocessing [crayon-663b425fa15fd752759944/]</p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/multithreading-and-multiprocessing-parallel-computing-1/">Multithreading and Multiprocessing &#8211; Parallel Computing 1</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2>Multithreading</h2>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">#include &lt;stdio.h&gt;

#include &lt;thread&gt;

int a = 1;

void run(int s) {
  a += s;
}

int main(int argc, char** argv) {
  std::thread thread1(run, 2);
  std::thread thread2(run, 5);
  thread1.join(); 
  thread2.join();
  printf(&quot;%d\n&quot;, a);
  return 0;
}
// Output:
// 8</pre>
</div></div>



<h2>Multiprocessing</h2>



<div class="responsive-tabs">
<h2 class="tabtitle">C++</h2>
<div class="tabcontent">

<pre class="crayon-plain-tag">#include &lt;stdio.h&gt;
#include &lt;sys/types.h&gt;
#include &lt;unistd.h&gt;

int a = 1;
void run(bool child) { 
  a += child ? 2 : 1;
}

int main(int argc, char** argv) {
  a += 1;
  pid_t pid = fork();
  run(pid == 0);
  printf(&quot;%d\n&quot;, a);
  return 0;
}

// Output:
// 3
// 4</pre>
</div></div>



<p></p>
<p>The post <a rel="nofollow" href="https://zxi.mytechroad.com/blog/cs/multithreading-and-multiprocessing-parallel-computing-1/">Multithreading and Multiprocessing &#8211; Parallel Computing 1</a> appeared first on <a rel="nofollow" href="https://zxi.mytechroad.com/blog">Huahua&#039;s Tech Road</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://zxi.mytechroad.com/blog/cs/multithreading-and-multiprocessing-parallel-computing-1/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
