<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>文章 on 我的博客</title><link>https://quhongbin.github.io/posts/</link><description>Recent content in 文章 on 我的博客</description><generator>Hugo</generator><language>zh-CN</language><atom:link href="https://quhongbin.github.io/posts/index.xml" rel="self" type="application/rss+xml"/><item><title>C++ Templates</title><link>https://quhongbin.github.io/posts/1/01/c-templates/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://quhongbin.github.io/posts/1/01/c-templates/</guid><description>&lt;h1 id="c-templates"&gt;C++ Templates&lt;/h1&gt;&#10;&lt;p&gt;Templates are C++'s mechanism for &lt;strong&gt;generic programming&lt;/strong&gt; &amp;mdash; writing&#10;code that works with any type without repeating yourself. Unlike runtime&#10;polymorphism (virtual functions), templates are resolved entirely at&#10;compile time: the compiler generates a separate copy of the function or&#10;class for each set of type arguments actually used. This is called&#10;&lt;strong&gt;template instantiation&lt;/strong&gt;.&lt;/p&gt;&#10;&lt;p&gt;Templates are the foundation of the C++ Standard Library:&#10;&lt;code&gt;std::vector&amp;lt;int&amp;gt;&lt;/code&gt;, &lt;code&gt;std::map&amp;lt;std::string, double&amp;gt;&lt;/code&gt;,&#10;&lt;code&gt;std::sort(begin, end)&lt;/code&gt; &amp;mdash; all templates. They power everything from&#10;containers to algorithms to smart pointers. Understanding templates&#10;deeply means understanding how modern C++ achieves its combination of&#10;abstraction and zero-overhead performance.&lt;/p&gt;</description></item><item><title>operating-system operating-system</title><link>https://quhongbin.github.io/posts/1/01/operating-system-operating-system/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://quhongbin.github.io/posts/1/01/operating-system-operating-system/</guid><description>&lt;h1 id="process"&gt;Process&lt;/h1&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A basic resources unit which is assigned with memory in OS - Has isolated memory address&#10;&lt;blockquote&gt;&#10;&lt;p&gt;arly System&lt;/p&gt;&#10;&lt;/blockquote&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h1 id="thread"&gt;Thread&lt;/h1&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;A basic unit is called by CPU&lt;/li&gt;&#10;&lt;li&gt;rely on and within [&lt;em&gt;Process&lt;/em&gt;]&lt;/li&gt;&#10;&lt;li&gt;use the virtual address from the Process, but the Threads must be in same process&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;h1 id="coroutine"&gt;coroutine&lt;/h1&gt;&#10;&lt;ul&gt;&#10;&lt;li&gt;&#10;&lt;hr&gt;&#10;&lt;/li&gt;&#10;&lt;/ul&gt;&#10;&lt;table&gt;&#10;&#9;&lt;thead&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;dimension&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;Process&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;thread&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;th&gt;&lt;strong&gt;coroutine&lt;/strong&gt;&lt;/th&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/thead&gt;&#10;&#9;&lt;tbody&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;caller&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;os's kernel&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;os's kernel&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;user program&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;memory space&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Individual(no shared)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;share with Memory of Process&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;share with Memory of Proces&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;switching performance overhead&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;very high (us-ms)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;middle(us)&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;low(ns)&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;parallel&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;hundreds of concurrent cons&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Several thousand up to tens of thousands&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;hundreds of thousands to millions&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;concurrent ability&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;multicore&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;multicore&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;concurrent within singal thread&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&#9;&#9;&lt;tr&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;&lt;strong&gt;usage&lt;/strong&gt;&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;sandbox, dense scenario of CPU-process&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;Web service, dense scenario I/O&lt;/td&gt;&#10;&#9;&#9;&#9;&#9;&#9;&lt;td&gt;high-concurrent gateway,async web crawler&lt;/td&gt;&#10;&#9;&#9;&#9;&lt;/tr&gt;&#10;&#9;&lt;/tbody&gt;&#10;&lt;/table&gt;&#10;&lt;hr&gt;&#10;&lt;p&gt;&lt;a href="memory_alignment.excalidraw"&gt;file:memory_alignment.excalidraw&lt;/a&gt;&lt;/p&gt;</description></item></channel></rss>