sysprog
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Write
        • Owners
        • Signed-in users
        • Everyone
        Owners Signed-in users Everyone
      • Engagement control Commenting, Suggest edit
      • Invitee
      • No invitee
    • Publish Note

      Publish Note

      Everyone on the web can find and read all notes of this public team.
      Once published, notes can be searched and viewed by anyone online.
      See published notes
      Please check the box to agree to the Community Guidelines.
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Versions and GitHub Sync
    • Note settings
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Sharing URL Help
Menu
Options
Versions and GitHub Sync Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Write
Owners
  • Owners
  • Signed-in users
  • Everyone
Owners Signed-in users Everyone
Engagement control Commenting, Suggest edit
Invitee
No invitee
Publish Note

Publish Note

Everyone on the web can find and read all notes of this public team.
Once published, notes can be searched and viewed by anyone online.
See published notes
Please check the box to agree to the Community Guidelines.
Engagement control
Commenting
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
  • Everyone
Suggest edit
Permission
Disabled Forbidden Owners Signed-in users Everyone
Enable
Permission
  • Forbidden
  • Owners
  • Signed-in users
Import from Dropbox Google Drive Gist Clipboard
   owned this note    owned this note      
Published Linked with GitHub
Subscribed
  • Any changes
    Be notified of any changes
  • Mention me
    Be notified of mention me
  • Unsubscribe
Subscribe
# 2024-03-{05,07,12} 問答紀錄 ## vax-r > [lab0](https://hackmd.io/@vax-r/linux2024-homework1) 整合網頁伺服器與 linenoise 套件: ## 測驗一的程式 while 如何進行優化 > Jimmy01240397 舉例一: 假設 $2^{19} + 1$ 的情況 msb 會是 19 在 while 迴圈內的 a ($2^{msb}$)的數值降到 $2^{9}$ 之前 while 內的 if 都不會成立因為 $(result(0) + 2^{10}) * (result(0) + 2^{10}) > N$ 也就是 $2^{20} > 2^{19} + 1$ $(result(0) + 2^{9}) * (result(0) + 2^{9}) <= N$ 也就是 $2^{18} <= 2^{19} + 1$ 由於 $19 / 2 = 9$ 因此可以在進 while 之前先 $msb / 2$ 舉例二: 假設 $2^{20} + 1$ 的情況 msb 會是 20 $(result(0) + 2^{11}) * (result(0) + 2^{11}) > N$ 也就是 $2^{22} > 2^{20} + 1$ $(result(0) + 2^{10}) * (result(0) + 2^{10}) <= N$ 也就是 $2^{20} <= 2^{20} + 1$ $20/2 = 10$ 舉例三: 假設 $2^{20}$ 的情況 msb 會是 20 $(result(0) + 2^{11}) * (result(0) + 2^{11}) > N$ 也就是 $2^{22} > 2^{20}$ $(result(0) + 2^{10}) * (result(0) + 2^{10}) <= N$ 也就是 $2^{20} <= 2^{20}$ $20/2 = 10$ ## 解釋為何測驗二程式相等 > Brucelee503jo3 ## 客製化的測驗題 * 學號: P7???07 $\to$ [測驗題](https://hackmd.io/0MoP3JV1SqyjCbR-dO9OnA) <s> * 學號: NM?????54 $\to$ [測驗題](https://hackmd.io/xi1l3Ty1TcC3MJN5b4Geng) * 學號: P76?0??02 $\to$ [測驗題](https://hackmd.io/JLFF13wRRIWjWMFlrZFyuw) </s> ## 為什麼要加入 `& ~1UL` 來代表 log(x) > [PochariChun](https://github.com/PochariChun/lab0-c) 為什麼要加入 `& ~1UL` ? ```c m = 1UL << ((31 - __builtin_clz(x)) & ~1UL); ``` 而不是單純使用底下形式來表示最高位元呢? ```c m = 1UL << (31 - __builtin_clz(x)) ; ``` > 注意 `& ~1UL` 會 clear 最低位,例如前者在 `x = 2` 時結果為 `1`,後者則是 `2`。 > [name=lumynou5] ## brucelee503jo3 > 經驗分享 > $\to$ [你所不知道的 C 語言: bitwise 操作](https://hackmd.io/@sysprog/c-bitwise) ## weihsinyeh > [`lib/list_sort.c` 分析](https://hackmd.io/@weihsinyeh/ry2RWmNTT) ## yeh-sudo > [快速排序的實作評估](https://hackmd.io/@yehsudo/linux2024-homework2) - [ ] 使用一般陣列與鏈結串列的差別? 使用一般陣列可以直接存取,成本較低,不需要像鏈結串列一樣,要實際走訪才能存取其中的元素,成本較高,所以今天如果是相同的排序演算法,使用陣列的效能可能會比鏈結串列要好。 - [ ] 合併排序法與快速排序法,哪一種的 [locality](https://en.wikipedia.org/wiki/Locality_of_reference) 較好? 一般的合併排序法在合併時,都是兩兩元素比較,容易將 cache 中的元素置換掉,導致 [cache thrashing](https://en.wikipedia.org/wiki/Thrashing_(computer_science)) ,而在快速排序法中,雖然與合併排序一樣,都是進行分割,但是在分割合併的時候,都是全部的元素在與一個 `pivot` 進行比較,所以 locality 較好,因此,為了降低 cache thrashing ,才出現了 lib/list_sort.c 這樣的改良版合併排序法。 - [ ] 用 gnuplot 製圖,為何執行時間的落點無法像教科書圖例平滑且純淨? 在執行測試中,會受到許多環境因素影響: * 作業系統 我們的作業系統中,都會有一個 timer 去幫助 CPU 進行排程,為了避免 [starvation](https://en.wikipedia.org/wiki/Starvation_(computer_science)) ,計時器會發出一個訊號,將原本的測試中斷,會造成測量的結果不準確。 * 次要分頁錯誤 ( [Minor Page Fault](https://en.wikipedia.org/wiki/Page_fault) ) 一個次要分頁錯誤會需要很多 CPU cycle 去處理,只要這個情況頻繁發生,就會影響到測試的效能。 * 網路 舉例,電腦上開著通訊軟體,當有人傳訊息給自己時, CPU 必須要接收並且處理這些封包,就算今天沒有通訊軟體的運作,也會有 APR 的廣播封包傳輸到電腦上, CPU 也一定要處理這些封包,沒辦法不管。 - [ ] 如何產生符合 Timsort 的測試資料? 使用 lab0-c 的 shuffle 產生,完成作業要求的亂數研究。

Import from clipboard

Advanced permission required

Your current role can only read. Ask the system administrator to acquire write and comment permission.

This team is disabled

Sorry, this team is disabled. You can't edit this note.

This note is locked

Sorry, only owner can edit this note.

Reach the limit

Sorry, you've reached the max length this note can be.
Please reduce the content or divide it to more notes, thank you!

Import from Gist

Import from Snippet

or

Export to Snippet

Are you sure?

Do you really want to delete this note?
All users will lose their connection.

Create a note from template

Create a note from template

Oops...
This template is not available.
Upgrade
All
  • All
  • Team
No template found.

Create custom template

Upgrade

Delete template

Do you really want to delete this template?
Turn this template into a regular note and keep its content, versions, and comments.

This page need refresh

You have an incompatible client version.
Refresh to update.
New version available!
See releases notes here
Refresh to enjoy new features.
Your user state has changed.
Refresh to load new user state.

Sign in

Forgot password

or

By clicking below, you agree to our terms of service.

Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
Wallet ( )
Connect another wallet

New to HackMD? Sign up

Help

  • English
  • 中文
  • Français
  • Deutsch
  • 日本語
  • Español
  • Català
  • Ελληνικά
  • Português
  • italiano
  • Türkçe
  • Русский
  • Nederlands
  • hrvatski jezik
  • język polski
  • Українська
  • हिन्दी
  • svenska
  • Esperanto
  • dansk

Documents

Tutorials

Book Mode Tutorial

Slide Mode Tutorial

Contacts

Facebook

Twitter

Discord

Feedback

Send us email

Resources

Releases

Pricing

Blog

Policy

Terms

Privacy

Cheatsheet

Syntax Example Reference
# Header Header 基本排版
- Unordered List
  • Unordered List
1. Ordered List
  1. Ordered List
- [ ] Todo List
  • Todo List
> Blockquote
Blockquote
**Bold font** Bold font
*Italics font* Italics font
~~Strikethrough~~ Strikethrough
19^th^ 19th
H~2~O H2O
++Inserted text++ Inserted text
==Marked text== Marked text
[link text](https:// "title") Link
![image alt](https:// "title") Image
`Code` Code 在筆記中貼入程式碼
```javascript
var i = 0;
```
var i = 0;
:smile: :smile: Emoji list
{%youtube youtube_id %} Externals
$L^aT_eX$ LaTeX
:::info
This is a alert area.
:::

This is a alert area.

Versions and GitHub Sync
Upgrade to Prime Plan

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

No updates to save
Compare with
    Choose a version
    No search result
    Version not found
Sign in to link this note to GitHub
Learn more
This note is not linked with GitHub
 

Feedback

Submission failed, please try again

Thanks for your support.

On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

Please give us some advice and help us improve HackMD.

 

Thanks for your feedback

Remove version name

Do you want to remove this version name and description?

Transfer ownership

Transfer to
    Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

      Link with GitHub

      Please authorize HackMD on GitHub
      • Please sign in to GitHub and install the HackMD app on your GitHub repo.
      • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
      Learn more  Sign in to GitHub

      Push the note to GitHub Push to GitHub Pull a file from GitHub

        Authorize again
       

      Choose which file to push to

      Select repo
      Refresh Authorize more repos
      Select branch
      Select file
      Select branch
      Choose version(s) to push
      • Save a new version and push
      • Choose from existing versions
      Include title and tags
      Available push count

      Upgrade

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Upgrade

      Danger Zone

      Unlink
      You will no longer receive notification when GitHub file changes after unlink.

      Syncing

      Push failed

      Push successfully