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, Emoji Reply
      • Invitee
    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • 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
    • Emoji Reply
    • Enable
    • 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, Emoji Reply
Invitee
Publish Note

Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

Your note will be visible on your profile and discoverable by anyone.
Your note is now live.
This note is visible on your profile and discoverable online.
Everyone on the web can find and read all notes of this public team.
See published notes
Unpublish note
Please check the box to agree to the Community Guidelines.
View profile
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
Emoji Reply
Enable
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
# 2023-08-17 討論 :::info :information_source: 請在此提出欲討論的素材 ::: 測驗作答到 20:55 => https://hackmd.io/@sysprog/linux2023-summer-quiz2 ## You * 第一次作業的答案會公布嗎? 想知道自己答的怎麼樣。 * 想請問作業二關於pi-mutex的內容, 有閱讀linux關於pi futex的解說 不過還是不理解pi-futex如何知道目前誰是lock owner 然後跟嘗試上鎖的thread比較priority高低? 可以詳細說明它的演算法或者怎麼做到的嗎? lockdep, https://www.kernel.org/doc/html/next/locking/index.html PIP, PCP * 請問老師能否說明一下作業二MUTEX_SLEEPING設計的用意是什麼?追蹤完程式碼沒有理解MUTEX_SLEEPING設定的目的,進一步嘗試把MUTEX_SLEEPING拿掉 (只用MUTEX_LOCK等待跟判斷) 也可以正確執行。有找同學討論過,不過還是想藉作業討論時間聽老師說明一下 * 對於 [並行程式設計: 執行順序](https://hackmd.io/@sysprog/concurrency-ordering#Happens-before) happens-before 的舉例有疑慮:文中以 C 語言片段舉例 A happens-before B ```c int A = 0, B = 0; void foo() { A = B + 1; // (1) B = 1; // (2) } int main() { foo(); } ``` 但是這邊 assign to A 跟 assign to B 沒有 happens-before 關係,他們為 concurrent 關係 (neither A $hb$ B nor B $hb$ A),如下圖說明。有 happens before 關係的是兩條分支上的任兩事件,不同分支上的事件關係為 concurrent,其完成順序可交換,不用有次序 ![](https://hackmd.io/_uploads/ryb3gcjh3.png) * 欲討論 quiz 0 [測驗 β](https://hackmd.io/@sysprog/linux2023-summer-quiz0#%E6%B8%AC%E9%A9%97-beta) 中 `mask` 的用法。當 alignment 為非二的冪的數值時,為什麼只能用除以 `alignment` 的方式,而無法用與 `~mask` 做 AND bitwise operation 來遮蔽餘數;我的[說明](https://hackmd.io/0pVNZEoBR2OU3-5FL-8kCQ?both#%E8%80%8C%E7%95%B6-alignment-%E7%82%BA%E9%9D%9E%E4%BA%8C%E7%9A%84%E5%86%AA%E7%9A%84%E6%95%B8%E5%80%BC%E6%99%82)如下: alignment 跟 mask 的最高有效位元 (MSB ) 皆為 1,若帶入上述程式碼,會將欲保留的 alignment 的 MSB 給遮蔽掉;如以下 alignment = 3 的例子, alignment 的 MSB 用 ‘*’ 來標記: ``` alignment = 3 = 4'b0011 mask = 2 = 4'b0010 ~mask = 4'b1101 * (121 + 2) & ~mask = 7'b1111011 & 7'b1111101 ------------ 7'b1111001 * (122 + 2) & ~mask = 7'b1111100 & 7'b1111101 ------------ 7'b1111000 ``` 故對此 case, 題目的範例程式利用除法得到商後,直接計算對應的 alignment 的位置;而非用遮蔽餘數的方式。 * 想問 Futex_Wait_Requeue_PI 是不是要呼叫 Futex_CMP_Requeue_PI 來做 requeue? * 台灣有老師所謂的 "Internet Company" 嗎 * 這次可以公佈答案嗎,完全猜不出來 * 在討論區有提問,不過從老師的回答還是不太知道該怎麼開始,要怎麼從"Linux 核心內附的文件"去了解runc, containerd/WSL2甚至進一步到k3s or k8s的運作原理? <s>目前是打算從[這篇文章](https://blog.lizzie.io/linux-containers-in-500-loc.html)開始</s> * 所以說像作業二要實作PI mutex有什麼做法上的提示嗎?除了了解lockdep之外, 本來想透過重新寫API讓mutex知道誰目前擁有它, 誰嘗試擁有它並且比較priority, 不過這樣的方向好像是錯誤的, 了解lockdep機制就能知道它怎麼做到priority boosting等等嗎? * 想請問老師怎麼看 Linux kernel 說引入 rust 是為了 memory-safety,但使用上卻一堆 **unsafe** 這樣是不是「跟風、舉燭」 > [linux/rust/alloc/alloc.rs](https://github.com/torvalds/linux/blob/6aeadf7896bff4ca230702daba8788455e6b866e/rust/alloc/alloc.rs#L97) > [unsafe中文](https://rust-lang.tw/book-tw/ch19-01-unsafe-rust.html) * 為什麼可以知道 *EMPTY 和 *ABORT 是不會被用到的 address? MPMC ==> SPSC SP <---> SC web server(工作模式) web client web client MP <---> MC (dmesg) [ringbuffer] (fixed) lock 才能保證 order of messages

Import from clipboard

Paste your markdown or webpage here...

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 has been removed or transferred.
Upgrade
All
  • All
  • Team
No template.

Create a 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

Help & Tutorial

How to use Book mode

Slide Example

API Docs

Edit in VSCode

Install browser extension

Contacts

Feedback

Discord

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
Get Full History Access

  • Edit version name
  • Delete

revision author avatar     named on  

More Less

Note content is identical to the latest version.
Compare
    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

      Pull from GitHub

       
      File from GitHub
      File from HackMD

      GitHub Link Settings

      File linked

      Linked by
      File path
      Last synced branch
      Available push count

      Danger Zone

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

      Syncing

      Push failed

      Push successfully