摳丁人
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
        • 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
      • 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 No publishing access yet

        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.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        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 New
      • Engagement control
      • Make a copy
      • 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 Note Insights Versions and GitHub Sync Sharing URL Help
    Menu
    Options
    Engagement control Make a copy 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
  • 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 No publishing access yet

    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.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    --- tags: System Software --- <style> font { color: red; font-weight: bold; } </style> # 計概中的背景知識 - 不負責任整理 - 可能有不正確、不正式的用詞 - 歡迎提出修改 ## Storage 儲存資料的硬體 > 引用文 > https://ithelp.ithome.com.tw/articles/10225077 ![](https://i.imgur.com/VJq9NUM.png =400x) 1. **CPU register** CPU 使用的==暫存器==,速度非常的快但容量非常小,用來儲存instruction(指令)與資料。 2. **cache** CPU 讀取記憶體的行為相對慢,因此在讀取記憶體內容時,會是以一個單位來拿取資料後暫存於 cache(快取),CPU 下次讀取記憶體資料前會先在 cache 裡面尋找,如果有找到就能直接拿 cache 的,加速讀取的過程。 3. **main memory**(RAM) 大家比較熟悉的==記憶體==,用來儲存執行Process要用到的資源。 4. **electronic disk(SSD)** 固態硬碟,比起傳統的硬碟使用磁頭的機械行為,SSD的體積比較小、速度快也比較省電。 5. **magnetic disk(HDD)** 硬碟,就是上面講的使用磁頭的傳統硬碟,因為是物理的磁頭去讀取資料內容,資料的儲存位置會影響存取的速度,整體速度比SSD還慢,但容量大且造價便宜。 6. **optical disk** 光碟,現在已經比較少了。 7. **magnetic tapes** 磁碟片,基本上現在已經看不到了,小時候很喜歡拉磁碟片上面那條鐵片。 > 古老到需要一張照片,我真不知道這個東西。 > ![](https://i.imgur.com/qS8cF0p.png =300x) :::success 上述設備由1至7的順序,數字越大造價越便宜、容量越大、速度越慢。 1-3具有揮發性,指斷電後儲存的資料會消失,反之4-7則不會。 ::: :::info 如果 **CPU** 是 **廚師**: - **硬碟** 就是 **冰箱** - 食材可以長期儲存,不會壞掉 - 但是食材要從冰箱拿出來才能用 - 從冰箱拿食材要多花一點時間 - **記憶體** 就是 **流理台** - 從冰箱拿出來的食材、做到一半的半成品都會放在流理台上 - 流理台上的食材不拿去冰會壞掉,所以用完要拿去冰 - 從流理台直接拿食材會比較快 - **暫存器** 就是廚師的 **雙手** - 東西已經從冰箱拿放在流理台了,但是要拿在手上才能進行動作 - 就算不拿著,你的手也要碰到食材才能做事吧 - 拿在手上的東西最快,但你的手只有一雙,所以不能一次拿很多東西 ::: 作業系統是個平台,可以讓許多的程式在他之上執行,其流程如下: 1. 苦命的工程師撰寫程式碼,不管是什麼程式語言 C++, C#, python, JavaScript。 1. 透過編譯器(compiler),開始把原始碼編譯成Program。電腦這時會有一些檔案被放在硬碟(disk)之中。 1. 當使用者啟動了編譯後的Program(存放在disk裡面),作業系統會把Program載入(load)到記憶體裡面,成為一個或多個Process。 ==CPU 只能夠存取記憶體的內容,不能夠直接讀取硬碟的資料==,所以不論是要使用硬碟內的資料還是程式(Program),都需要先載入到記憶體裡面。 ## System Components 硬體架構 ![](https://i.imgur.com/zyh79Y7.png) * 指令暫存器(IR, Instruction Register):存放正在執行或即將執行的指令 * 程式技術器(PC, Program Counter):存放下一條指令的存儲單元地址,具有自動遞增的功能 * 存儲器地址暫存器(MAR, Memory Address Register):存放即將要存取的存儲單元地址 * 存儲器數據暫存器(MDR, Memory Data Register) :存放要對存儲單元進行讀寫的數據 * 指令譯碼元件:對IR中的指令進行譯碼,用以確定是哪種指令要被執行 * 控制電路:根據指令產生控制信號,在時序脈衝同步下控制CPU中各元件的動作 ![](https://i.imgur.com/RB6Vqsh.png) ## Program, Process and Instructions - **Program** (程式) - 儲存在 **硬碟** 中 - 程式碼編譯後的產物,是一堆機器碼,但不是實際在執行的指令 - 程式執行前,會被 program loader **載入**到記憶體中,變成 process - 載入時,硬碟中的內容會被複製到記憶體中,並設定好所有需要的記憶體位置資訊 - **Process** (程序) - 儲存在 **記憶體** 中 - 實際在執行的一堆指令 - **Thread** (執行緒) - 一個 process 可以有多個執行緒 - 用來實現平行執行 - 但講下去會太複雜,有興趣的人可以搜尋 "Process vs. Thread" ### Instructions and Data 一個 process 可以分為 instructions 和 data 兩個部分 - **Instructions** - 告訴 CPU 該執行那些**動作** - 這些動作作用在哪些資料上 - 這些動作的順序 - 可以想成是程式語言中的 operator 和 function - **Data** - process 中的**資料** - 所有運算時用到數值 - 可以想成是程式語言中的變數和常數 :::info 如果把 CPU 想成是廚師,那... - Instructions 就是食譜,告訴廚師該對哪些食材做哪些動作,以及每個動作間的先後順序 - Data 就是食材,是實際上被拿來操作的東西 ::: 現代的機器都屬於 **Von Neumann architecture**(馮·紐曼架構),指令會和資料一樣存放在記憶體中,所以指令也會占用記憶體空間 ![](https://i.imgur.com/oDEVebr.png =300x) ### Instruction 的組成 Instruction 中一定包含幾個欄位,用來表示以下兩個資訊 - **OP Code** - 代表此指令要執行的運算 (動作) - 同一顆 CPU 能執行的每一種運算都會被分配一個編號 - 這個編號就是 OP Code - E.g., 有一顆 CPU 支援加、減、乘、除四種運算,則可以設計成 - 0(`00`) 表示加法 - 1(`01`) 表示減法 - 2(`10`) 表示乘法 - 3(`11`) 表示除法 - **Operand** - 要拿來執行運算的資料 - 根據不同的硬體架構,有不同的表示方式 - 可以是數值 - 也可以是記憶體位置,記憶體中對應位置的資料才是實際被用於運算的資料 ## CPU and Instructions - CPU 可以執行的每一種運算都對應到一種實體的電路 - Ex: 加法運算對應到加法器電路 - 每一個運算都有一個編號 - OP Code - 在 CPU 中,控制單元會依據 OP Code 選擇對應電路產生的結果

    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
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    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