Peter Chen; Kohan Chen
    • 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
    # lab0 回憶和突破 ## 2022q1 Homework1 (lab0) [2025q1 Homework1 (lab0)](/bqVA0peKTta0jLI0hAbKHg) 用關鍵字尋找和測試,為什麼不一樣。 [github](https://github.com/Destiny0504/lab0-c) [hackmd](https://hackmd.io/OJp4epQqQGSc74kP05C5tA) 再試試多一些提示的東西,因為時間複雜度我沒有處理得很好。 100分需要瞭解檔案和測試的內容,也要把握時間。 隨機性很快就結束,超過五秒都不正常。 可以提問為什麼。 [comparison](https://stackoverflow.com/questions/9706492/git-diff-output-to-file-preserve-coloring) [zoana](https://hackmd.io/@zoanana990/linux2022-lab0#q_sort-%E5%AF%A6%E4%BD%9C) hackmd [github](https://github.com/zoanana990/lab0-c.git) Readme 中的 Files 有玄機,但不知道怎麼解釋和運用。 測試過程無法包含在 github 目錄中, push 會失敗, 但要打破規則怎麽做。活用 gist 包含在註解裡。 push 失敗,[personal token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#keeping-your-personal-access-tokens-secure) 今年只能修改 queue.c ,所以要發問的線索要放這裡,用 [gist](https://gist.github.com/Urbaner3/628042a8669ec05d61a6d262fa95e1ce/revisions) 呈現。 >urbaner@urbaner-wtumagic:~/linux2025/lab2022/lab0-c_2022$ make valgrind # Explicitly disable sanitizer(s) make clean SANITIZER=0 qtest make[1]: Entering directory '/home/urbaner/linux2025/lab2022/lab0-c_2022' rm -f qtest.o report.o console.o harness.o queue.o random.o dudect/constant.o dudect/fixture.o dudect/ttest.o shannon_entropy.o linenoise.o web.o .qtest.o.d .report.o.d .console.o.d .harness.o.d .queue.o.d .random.o.d .dudect/constant.o.d .dudect/fixture.o.d .dudect/ttest.o.d .shannon_entropy.o.d .linenoise.o.d .web.o.d *~ qtest /tmp/qtest.* rm -rf .dudect rm -rf *.dSYM (cd traces; rm -f *~) ### Makefile [manual](https://hackmd.io/XdF11cBIR8aahe8bxU7gfw?view#%E4%BD%BF%E7%94%A8-Makefile-%E7%9A%84%E5%A5%BD%E8%99%95) 語法和示範(單一編譯 gcc) 將程式原始碼到執行四大步驟,依照語言分開,擺在表格的列中;目標、相依檔案,按代號依序陳列。 先按照語言整理編譯器 bash, gcc, python。 難度 bash > gcc > python 熟用編譯器 man 頁面(bash 是直接用 help,按照四大步驟分類,通常少用的出現就是有特殊目的,可以強調。 另外,python 加上 !# 指令可以視為 bash 指令,那就更多指令,而且不是單一是複合的,要依照重要性小心排列。 善用註解,並且切分 Makefile 不要一檔多用。 目前是程式編譯的相關指令參數, bash 指令先小心細分。 再把變數,像是補充一樣從四個角用箭頭導引到相關的命令行。 最後零散的是條件的參數。 另外 hook, pre-hook 也要另外處理。 目的就是先從行為規範確立後,反思寫自動編譯的人,他要的彈性狀況為何。 ## Valgrind 最詳盡資料 [src](https://www.youtube.com/watch?v=BKy2UvYNmGk) 下指令 `valgrind --trace-children=yes --time-stamp=yes --fullpath-after=/ --read-var-info=yes --tool=massif make check` 一分鐘等待,但可以知道實作的目標。 ## Jupyter notebook show up #### Ju notebook [C_kernel](https://github.com/brendan-rius/jupyter-c-kernel/tree/master ) #### magic words In Jupyter notebook, control the compile option with something called magic words [vid_demo](https://www.youtube.com/watch?v=ypIZqzy7cFs) [python](https://ipython.readthedocs.io/en/stable/interactive/magics.html#cell-magics)official [geek_supple](https://www.geeksforgeeks.org/jupyter-notebook-cell-magic-functions/) ### Valgrind [Fosdem](https://www.youtube.com/watch?v=2NdlyqY522E&t=173s) show video: ms_print, massid_visulizer 還有中文,你可能要懷疑這作業是不是有那麼難。 ## 免費圖形工具 因為開源方便整理,圖形可以幫助減輕大腦負擔,個人因素,放棄 vim + vspell 之類的工具,拼錯就算了,有空再改。 [sourcetrail](https://github.com/CoatiSoftware/Sourcetrail/tree/master),21年後停更,順手下載 bear 因為習慣用 cmake 早就可以無痛入手,這一連串都是自動配置、編譯或執行的工具。沒毛病阿。 ## 目標鎖定 [interative graph](https://makelinux.github.io/kernel/map/) with link to source code of linux kernel. ![qtest_inc_struct](https://hackmd.io/_uploads/BJtiGg9i1l.png) 這個程式的核心還是 IO,只是藉由系統運算處理記憶體的,模擬器而已。 繼續推進,檢查複習之前的程式碼,看看大家的做法,取得共識即可。對照 [assist] 的 [haloalgo](https://www.hello-algo.com/zh-hant/chapter_array_and_linkedlist/linked_list/) - web 是獨立的,只跟 console 和 report 有關。 - random 只是個 macro 沒那麼重要。 - fixture, constant 是實驗用的,單元測試系統。 - list 只是 linux API 是基礎的庫,但影響不大。 - 只是 qtest 帶著 queue 和 console 在混而已。 console 是最難理解的,他是前端,我們的工作是做後端資料處理,很紮實。 - 那 qtest 怎樣調和兩者呢? 他沒有標頭檔,一定有個理由。因為 main 在這裡。 - console 藏有 Rio 的實作,是全部最難的,有個 Callback function 讓他不能一眼看透,但通常前端會需要迴圈,他的變數是可以增加的,也就是說可以無限延展。也是唯一有用到 linenoise 和 select 的文件。 下面控制的演員是 cmd 所以 console 等於是導演。 問題是維度沒有具體表現出來。 - https://monica.im/home/chat/Claude%203.7%20Sonnet/claude_3_7_sonnet?convId=conv%3Ad7db6345-dfcc-4b74-98d4-cea104161d90 https://www.quora.com/Why-are-all-the-linked-lists-circular-in-the-Linux-Kernel https://www.data-structures-in-practice.com/intrusive-linked-lists/ list_imp.c 心機很重,看到補習班文化,我最討厭這種破壞納許平衡,不公平的學習了,強者愈強弱者愈弱,我更喜歡奪魂踞式 同死同活,從後悔中找到,平衡之處。 教材處處充滿危險,要重複看才注意得到,但你真的重複看,你時間就不夠了。 這一點,簡單說就是環環相扣,但失之毫釐,差之千里。 舉燭是個商業方式的說法,既然都已經進入周處除三害的實待了,不如大家槍發一發,壓縮成果,我倒想看看他要怎麼維持平衡。 ### branch active [branch_clone](https://www.geeksforgeeks.org/how-to-clone-all-remote-branches-in-git/) 避免隱藏分支。 ## Core dump and analysis ```shell (base) urbaner@urbaner-wtumagic:~/linux2025/chensheep/lab0-c$ ./qtest cmd> new l = NULL cmd> ih aksdjf Warning: Calling insert head on null queue Segmentation fault occurred. You dereferenced a NULL or invalid pointerAborted (core dumped) .... (base) urbaner@urbaner-wtumagic:~/linux2025/chensheep/lab0-c$ coredumpctl gdb PID: 16895 (qtest) UID: 1000 (urbaner) GID: 1000 (urbaner) Signal: 6 (ABRT) Timestamp: Wed 2025-03-12 02:39:12 CST (14min ago) Command Line: ./qtest Executable: /home/urbaner/linux2025/chensheep/lab0-c/qtest Control Group: /user.slice/user-1000.slice/user@1000.service/app.slice/app-org.gnome.Terminal.slice/vte-spawn-3c366399-18a2-4d95-a120-114c4600b160.scope Unit: user@1000.service User Unit: vte-spawn-3c366399-18a2-4d95-a120-114c4600b160.scope Slice: user-1000.slice Owner UID: 1000 (urbaner) Boot ID: 1cd399f77952431bbf9a78b99fbd120d Machine ID: 10b971ac1a304176906b1f6a23827476 Hostname: urbaner-wtumagic Storage: /var/lib/systemd/coredump/core.qtest.1000.1cd399f77952431bbf9a78b99fbd120d.16895.1741718352000000.zst (present) Disk Size: 24.8K Message: Process 16895 (qtest) of user 1000 dumped core. Found module /home/urbaner/linux2025/chensheep/lab0-c/qtest with build-id: 97ab618d8e3200dc2a71b25453f3b717a6104447 Found module linux-vdso.so.1 with build-id: 9fd856095d9a973579d1f96e0eb3d9030c15f0f2 Found module ld-linux-x86-64.so.2 with build-id: e4de036b19e4768e7591b596c4be9f9015f2d28a Found module libc.so.6 with build-id: cd410b710f0f094c6832edd95931006d883af48e Found module libm.so.6 with build-id: 7d8778fca8ea4621b268cc03662855d0cd983439 Stack trace of thread 16895: #0 0x000073c3e6a969fc __pthread_kill_implementation (libc.so.6 + 0x969fc) #1 0x000073c3e6a42476 __GI_raise (libc.so.6 + 0x42476) #2 0x000073c3e6a287f3 __GI_abort (libc.so.6 + 0x287f3) #3 0x00005ef732f0d762 n/a (/home/urbaner/linux2025/chensheep/lab0-c/qtest + 0x3762) GNU gdb (Ubuntu 12.1-0ubuntu1~22.04) 12.1 Copyright (C) 2022 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". Type "show configuration" for configuration details. For bug reporting instructions, please see: <https://www.gnu.org/software/gdb/bugs/>. Find the GDB manual and other documentation resources online at: <http://www.gnu.org/software/gdb/documentation/>. For help, type "help". Type "apropos word" to search for commands related to "word"... Reading symbols from /home/urbaner/linux2025/chensheep/lab0-c/qtest... [New LWP 16895] [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Core was generated by `./qtest'. Program terminated with signal SIGABRT, Aborted. #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=127285227788096) at ./nptl/pthread_kill.c:44 44 ./nptl/pthread_kill.c: No such file or directory. (gdb) bt #0 __pthread_kill_implementation (no_tid=0, signo=6, threadid=127285227788096) at ./nptl/pthread_kill.c:44 #1 __pthread_kill_internal (signo=6, threadid=127285227788096) at ./nptl/pthread_kill.c:78 #2 __GI___pthread_kill (threadid=127285227788096, signo=signo@entry=6) at ./nptl/pthread_kill.c:89 #3 0x000073c3e6a42476 in __GI_raise (sig=sig@entry=6) at ../sysdeps/posix/raise.c:26 #4 0x000073c3e6a287f3 in __GI_abort () at ./stdlib/abort.c:79 #5 0x00005ef732f0d762 in sigsegv_handler (sig=<optimized out>) at qtest.c:1118 #6 <signal handler called> #7 0x00005ef732f0ee72 in queue_insert (pos=pos@entry=POS_HEAD, argc=<optimized out>, argv=<optimized out>) at qtest.c:240 #8 0x00005ef732f0f02a in do_ih (argc=<optimized out>, argv=<optimized out>) at qtest.c:282 #9 0x00005ef732f108fe in interpret_cmda (argc=argc@entry=2, argv=argv@entry=0x5ef7339e9110) at console.c:214 #10 0x00005ef732f10c8a in interpret_cmd ( cmdline=cmdline@entry=0x5ef7339e8c50 "ih aksdjf") at console.c:234 #11 0x00005ef732f1178e in run_console (infile_name=infile_name@entry=0x0) at console.c:669 #12 0x00005ef732f0faa3 in main (argc=1, argv=<optimized out>) at qtest.c:1444 ``` 五個課題,對五段解說,如何運用。 記得提醒 master 分支要實作,因為他是特別的分支。 然後整理我做了什麼,得到什麼。想要什麼。 像打角子老虎機一樣,對流程圖分析,果然是一個賭徒該做的事情。 PR reference , verified sign, how, reaction ,focus to what. <Lumerence> ```shell (base) urbaner@urbaner-wtumagic:~/linux2025/lab0-c$ git commit Following files were changed: - queue.c : 1 insertions(+) Running fmtscan... 7459 lines scanned (0.227M bytes) 53 printf style statements being processed Running static analysis... tools/fmtscan.c:664:26: warning: Either the condition 'nextch2!=256' is redundant or isxdigit() argument nr 1 can have invalid value. The value is 256 but the valid values are '0:255'. [invalidFunctionArg] if (isxdigit(nextch2)) { ^ tools/fmtscan.c:657:17: note: Assuming that condition 'nextch2!=256' is not redundant if (LIKELY(nextch2 != PARSER_EOF)) { ^ tools/fmtscan.c:664:26: note: Invalid argument if (isxdigit(nextch2)) { ^ Fail to pass static analysis. ``` ### quit and restart merge failed and push fail

    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