Skip to content

Commit

Permalink
update 2024年 06月 02日 星期日 19:41:17 CST
Browse files Browse the repository at this point in the history
  • Loading branch information
ccrysisa committed Jun 2, 2024
1 parent f4bdc40 commit 62d99d4
Show file tree
Hide file tree
Showing 16 changed files with 1,637 additions and 71 deletions.
486 changes: 481 additions & 5 deletions content/posts/linux-kernel-internals/linux2023-lab0.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion content/posts/linux-kernel-internals/linux2023.md
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ Linux 核心設計/實作 (Spring 2023) 課程進度表暨線上資源
- [ ] [Linus Torvalds 教你分析 gcc 行為](https://lkml.org/lkml/2019/2/25/1092)
- [ ] [Pointers are more abstract than you might expect in C](https://pvs-studio.com/en/blog/posts/cpp/0576/) / [HackerNews 討論](https://news.ycombinator.com/item?id=17439467)
* [ ] [C 編譯器原理和案例分析](https://hackmd.io/@sysprog/c-compiler-construction)`*`
* [ ] [C 語言: 未定義行為](https://hackmd.io/@sysprog/c-undefined-behavior)`*`: C 語言最初為了開發 UNIX 和系統軟體而生,本質是低階的程式語言,在語言規範層級存在 undefined behavior,可允許編譯器引入更多最佳化
* [x] [C 語言: 未定義行為](https://hackmd.io/@sysprog/c-undefined-behavior)`*`: C 語言最初為了開發 UNIX 和系統軟體而生,本質是低階的程式語言,在語言規範層級存在 undefined behavior,可允許編譯器引入更多最佳化
* [ ] [C 語言: 編譯器和最佳化原理](https://hackmd.io/@sysprog/c-compiler-optimization)`*`
* 《Demystifying the Linux CPU Scheduler》第 1 章
* [作業](https://hackmd.io/@sysprog/linux2023-homework4): 截止繳交日: Mar 30
Expand Down
5 changes: 5 additions & 0 deletions content/posts/sysprog/linux-hashtable.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ $$
$$
{{< /raw >}}

- $K$: key value
- $A$: a constant, 且 $0 < A < 1$
- $m$: bucket 数量,且 $m = 2^p$
- $w$: 一个 word 有几个 bit

上面两条式子的等价关键在于,使用 **二进制编码** 表示的整数和小数配合进行推导,进而只使用整数来实现,具体推导见原文。

$(\sqrt{5} - 1 ) / 2 = 0.618033989$
Expand Down
2 changes: 2 additions & 0 deletions content/posts/sysprog/posix-threads.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,10 @@ POSIX 的全称是 Portable Operating System Interfaces,结合上图,所以
从 CPU 厂商群魔乱舞中诞生的标准,自然是要保证可移植 Portable 的啦 :rofl:
{{< /details >}}

{{< admonition success >}}
下面的这个由 Lawrence Livermore National Laboratory 撰写的教程文档写的非常棒,值得一读 (他们还有关于 HPC 高性能计算的相关教程文档):
- [POSIX Threads Programming](https://hpc-tutorials.llnl.gov/posix/)
{{< /admonition >}}

### Synchronizing Threads

Expand Down
2 changes: 1 addition & 1 deletion docs/index.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/posts/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@
</div><main class="container"><div class="page archive">
<div class="header"><h1 class="single-title animate__animated animate__pulse animate__faster">所有文章
<sup>57</sup>
</h1><p class="single-subtitle total-word-count" title='总计约 132558'><i class="fa-regular fa-keyboard fa-fw" aria-hidden="true"></i> 总计约 132.56K</p></div><h2 class="group-title">最近更新</h2><article class="archive-item">
</h1><p class="single-subtitle total-word-count" title='总计约 134334'><i class="fa-regular fa-keyboard fa-fw" aria-hidden="true"></i> 总计约 134.33K</p></div><h2 class="group-title">最近更新</h2><article class="archive-item">
<a href="/posts/linux2023-lab0/" class="archive-item-link">Linux 核心设计: lab0-c</a>
<span class="archive-item-date" title='2024-06-01 23:54:20'>更新于 06-01</span>
</article><article class="archive-item">
Expand Down
12 changes: 9 additions & 3 deletions docs/posts/linux-hashtable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
Linux 核心如同其它复杂的资讯系统,也提供 hash table 的实作,但其原始程式码中却藏有间接指针 (可参见 你所不知道的 C 语言: linked list 和非连续内存) 的巧妙和数学奥秘。
"><meta itemprop="datePublished" content="2024-03-16T10:59:36+08:00" />
<meta itemprop="dateModified" content="2024-03-16T13:13:05+08:00" />
<meta itemprop="wordCount" content="757"><meta itemprop="image" content="https://ccrysisa.github.io/logo.png" />
<meta itemprop="wordCount" content="786"><meta itemprop="image" content="https://ccrysisa.github.io/logo.png" />
<meta itemprop="keywords" content="Sysprog,Linux,Hash table," /><meta property="og:title" content="Linux 核心的 hash table 实作" />
<meta property="og:description" content="
Linux 核心如同其它复杂的资讯系统,也提供 hash table 的实作,但其原始程式码中却藏有间接指针 (可参见 你所不知道的 C 语言: linked list 和非连续内存) 的巧妙和数学奥秘。
Expand Down Expand Up @@ -43,7 +43,7 @@
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https:\/\/ccrysisa.github.io\/posts\/linux-hashtable\/"
},"genre": "posts","keywords": "Sysprog, Linux, Hash table","wordcount": 757 ,
},"genre": "posts","keywords": "Sysprog, Linux, Hash table","wordcount": 786 ,
"url": "https:\/\/ccrysisa.github.io\/posts\/linux-hashtable\/","datePublished": "2024-03-16T10:59:36+08:00","dateModified": "2024-03-16T13:13:05+08:00","publisher": {
"@type": "Organization",
"name": ""},"author": {
Expand Down Expand Up @@ -172,7 +172,7 @@
</h1></div><div class="post-meta">
<div class="post-meta-line"><span class="post-author"><a href="https://github.com/ccrysisa" title="作者"target="_blank" rel="external nofollow noopener noreferrer author" class="author"><img loading="lazy" src="https://avatars.githubusercontent.com/u/133117003?s=400&amp;v=4" data-title="ccrysisa" data-alt="ccrysisa" class="avatar" style="background: url(/svg/loading.min.svg) no-repeat center;" onload="this.title=this.dataset.title;this.alt=this.dataset.alt;for(const i of ['style', 'data-title','data-alt','onerror','onload']){this.removeAttribute(i);}this.dataset.lazyloaded='';" onerror="this.title=this.dataset.title;this.alt=this.dataset.alt;for(const i of ['style', 'data-title','data-alt','onerror','onload']){this.removeAttribute(i);}"/>&nbsp;ccrysisa</a></span>
<span class="post-category">收录于 <a href="/categories/linux/"><i class="fa-regular fa-folder fa-fw" aria-hidden="true"></i> Linux</a>&ensp;<a href="/categories/linux-kernel-internals/"><i class="fa-regular fa-folder fa-fw" aria-hidden="true"></i> Linux Kernel Internals</a></span></div>
<div class="post-meta-line"><span title="发布于 2024-03-16 10:59:36"><i class="fa-regular fa-calendar-alt fa-fw me-1" aria-hidden="true"></i><time datetime="2024-03-16">2024-03-16</time></span>&nbsp;<span title="更新于 2024-03-16 13:13:05"><i class="fa-regular fa-edit fa-fw me-1" aria-hidden="true"></i><time datetime="2024-03-16">2024-03-16</time></span>&nbsp;<span title="757"><i class="fa-solid fa-pencil-alt fa-fw me-1" aria-hidden="true"></i>约 800 字</span>&nbsp;<span><i class="fa-regular fa-clock fa-fw me-1" aria-hidden="true"></i>预计阅读 2 分钟</span>&nbsp;</div>
<div class="post-meta-line"><span title="发布于 2024-03-16 10:59:36"><i class="fa-regular fa-calendar-alt fa-fw me-1" aria-hidden="true"></i><time datetime="2024-03-16">2024-03-16</time></span>&nbsp;<span title="更新于 2024-03-16 13:13:05"><i class="fa-regular fa-edit fa-fw me-1" aria-hidden="true"></i><time datetime="2024-03-16">2024-03-16</time></span>&nbsp;<span title="786"><i class="fa-solid fa-pencil-alt fa-fw me-1" aria-hidden="true"></i>约 800 字</span>&nbsp;<span><i class="fa-regular fa-clock fa-fw me-1" aria-hidden="true"></i>预计阅读 2 分钟</span>&nbsp;</div>
</div><div class="details toc" id="toc-static" data-kept="false">
<div class="details-summary toc-title">
<span>目录</span>
Expand Down Expand Up @@ -260,6 +260,12 @@ <h2 id="linux-核心的-hash-函数">Linux 核心的 hash 函数</h2>
\end{split}
$$
</div>
<ul>
<li>$K$: key value</li>
<li>$A$: a constant, 且 $0 &lt; A &lt; 1$</li>
<li>$m$: bucket 数量,且 $m = 2^p$</li>
<li>$w$: 一个 word 有几个 bit</li>
</ul>
<p>上面两条式子的等价关键在于,使用 <strong>二进制编码</strong> 表示的整数和小数配合进行推导,进而只使用整数来实现,具体推导见原文。</p>
<p>$(\sqrt{5} - 1 ) / 2 = 0.618033989$<br>
$2654435761 / 4294967296 = 0.618033987$<br>
Expand Down
5 changes: 5 additions & 0 deletions docs/posts/linux-hashtable/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ $$
$$
{{< /raw >}}

- $K$: key value
- $A$: a constant, 且 $0 < A < 1$
- $m$: bucket 数量,且 $m = 2^p$
- $w$: 一个 word 有几个 bit

上面两条式子的等价关键在于,使用 **二进制编码** 表示的整数和小数配合进行推导,进而只使用整数来实现,具体推导见原文。

$(\sqrt{5} - 1 ) / 2 = 0.618033989$
Expand Down
Loading

0 comments on commit 62d99d4

Please sign in to comment.