鄭朝駿
    • Create new note
    • Create a note from template
      • 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
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • 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
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
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
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • 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
    # 2024q1 Homework5 (assessment) contributed by < `ChengChaoChun` > ## 閱讀〈因為自動飲料機而延畢的那一年〉 在閱讀到這一系列文章的一半之前,我曾經以為開發自動飲料機的專案最終可能就不了了之。這是一個創新的產品,然而,在經過一個月的探索後,作者只完成了落杯器機構的設計,且還未能實現自動化。在這個設計過程中,他經常遇到一些出乎意料的困難,由於是從零開始,這些問題不是單靠網路搜尋就能輕易解決的。每當面對這些技術挑戰,作者都必須花費大量的時間進行研究和實驗以及等待工廠加工的設計成品。為了這個創新的產品,作者決定延畢來完成。這種對研究的堅持與熱情,令人深感佩服。 作者的成功有一部分也是因為改變設計方案,不再執著於完全自行設計,而是購買設計好的產品去開發。為此,他甚至親自前往果糖機工廠,深入了解機器的內部設計和運作方式。最終,他將購買的機器與自己的設計融合,成功創造了一台自動飲料機。 ## 課程學習心得 到目前為止,我覺得我還在原地踏步,目前老師布置的作業我都沒有完成過。在大學的時候因為沒有認真的學習,當時我的標準是可以及格就好,每次都是隨便應付一下考試,反正肯定會及格,甚至實驗課的代碼我都是跟同學拿來然後隨便改改就提交了,最終就是目前由於基礎太差,沒有辦法達到作業要求的標準。第二次的作業和第四次的作業是分析題目程式並完成延伸問題,在很多題目上我思考了很久還是沒辦法理解,有的題目我盡力的把我理解的部分記錄在作業上,有的則是沒辦法去記錄在作業上,因為絕大部分看不懂,更不用說去完成延伸問題了。而第一次作業和第三次作業對我來說難度更高了,老師列出的代辦事項大部分沒有完成。 目前我就像〈因為自動飲料機而延畢的那一年〉的作者在設計落杯器的階段,搞笑的是,我之前還嘗試看了 `Linux 6.8` 原始碼,當時我以為我從 `start_kernel` 函式開始追蹤應該可以理解 `linux kernel` 大概是如何設計的,最後的結果當然是放棄了,然後我又把目標轉向了 `task_struct` , 我嘗試去理解 linux 是如何描述 PCB 的,即便去掉原始碼很多條件編譯的部分,我仍然沒辦法掌握,畢竟它現在高達 600 行呢。我記得我是在第四周的時候買了《深入理解計算機系統》這本書的,當時拿到之後我就看到這本書實在是太厚了,懶得看了,我甚至都沒有拆封,直到最近我才開始閱讀這本經典書籍。 :::danger 你的問題絕對不是在 Linux 核心原始程式碼中,一定有更根本的問題。 `task_struct` 不能算是 Linux 核心的 PCB,因為其描述的範疇遠超過 PCB ::: 對於這學習的目標,我會我盡可能地在課程上,課本上去學習,並踏出那一小步。對於未來的目標,我想要能夠為 linux 的程式碼做貢獻,這可以很好的展示你對計算機和作業系統的理解,因為如果現在去面試工作的話,我實在不知道可以告訴面試官我會什麼。 :::danger 不要花時間在自憐,詳細描述你遇到的技術問題,我們才可討論並解決。 ::: --- ```c #include <stdatomic.h> typedef struct __list { int value; struct __list *next; } list_t; // *concurrent* add, remove ``` TODO: 寫完並討論 Head | A -> B -> C | Tail 1. Remove A 2. Add_tail D ``` #include <stdio.h> #include <stdlib.h> #include <pthread.h> #include <semaphore.h> sem_t mutex; typedef struct __list { int value; struct __list *next; } list_t; list_t *head, *tail; void init_list(){ head = NULL; tail = NULL; sem_init(&mutex, 0, 1); } void print_list(){ if(!head){ printf("list is empty\n"); return; } printf("list: "); for(list_t *ptr=head;ptr!=NULL;ptr=ptr->next){ printf("%d, ",ptr->value); } printf("\n"); } void *add_head(void *arg){ list_t *node = malloc(sizeof(list_t)); if(!node){ printf("error!"); return NULL; } node->value = (int)arg; sem_wait(&mutex); node->next = head; head = node; if(!tail) tail = node; printf("add_head %d, ", node->value); print_list(); sem_post(&mutex); return NULL; } void *add_tail(void *arg){ list_t *node = malloc(sizeof(list_t)); if(!node){ printf("error!"); return NULL; } node->value = (int)arg; node->next = NULL; sem_wait(&mutex); if(head){ tail->next = node; tail = node; }else{ head = node; tail = node; } printf("add_tail %d, ", node->value); print_list(); sem_post(&mutex); return NULL; } void *remove_head(void *arg){ sem_wait(&mutex); if(!head){ printf("remove head, list is empty\n"); sem_post(&mutex); return NULL; } list_t *node = head; head = head -> next; free(node); printf("remove head, "); print_list(); sem_post(&mutex); return NULL; } void *remove_tail(void *arg){ sem_wait(&mutex); if(!head){ printf("remove tail, list is empty\n"); sem_post(&mutex); return NULL; } list_t *ptr = head, *node; while(ptr->next && ptr->next != tail){ ptr = ptr->next; } ptr->next = NULL; if(head == tail) head = NULL; node = tail; free(node); tail = ptr; printf("remove tail. "); print_list(); sem_post(&mutex); return NULL; } int main() { init_list(); pthread_t tid[8]; pthread_create(tid, NULL, add_head, (void *)200); pthread_create(tid+1, NULL, remove_head, NULL); pthread_create(tid+2, NULL, remove_head, NULL); pthread_create(tid+3, NULL, add_tail, (void *)500); pthread_create(tid+4, NULL, remove_head, NULL); pthread_create(tid+5, NULL, add_head, (void *)700); pthread_create(tid+6, NULL, add_tail, (void *)800); pthread_create(tid+7, NULL, remove_head, NULL); for(int i=0;i>8;i++){ pthread_join(tid[i], NULL); } pthread_exit(NULL); return 0; } ``` TCP 3-way handshake SYN TODO: ksort + extra

    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