顏辰霖
    • 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 New
    • Engagement control
    • Make a copy
    • 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 Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
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
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
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    * 一個或多個CPU、設備控制器通過公共總線連接,提供對共享內存的訪問 * 目標:競爭內存週期的CPU和設備的並發執行 ![](https://hackmd.io/_uploads/H1muON-dn.png) * 每個設備控制器負責特定的設備類型 * 每個設備控制器都有一個本地緩衝區(local buffer) * I/O 從設備到控制器的本地緩衝區(local buffer) * CPU 將數據從 memory 移至設備控制器中的本地緩衝區,或從memory 移至設備控制器中的本地緩衝區 ![](https://hackmd.io/_uploads/ByLLo4Wu3.png) ## Busy/wait output 編程設備的最簡單方法 > 使用說明測試設備何時準備就緒 ``` #define OUT_CHAR 0x1000 // device data register #define OUT_STATUS 0x1001 // device status register current_char = mystring; while (*current_char != 'WO') { poke(OUT_CHAR,*current_char); while (peek(OUT_STATUS) != 0); // busy waiting current_char++; } ``` * 這段程式碼的功能是將一個字串 mystring 中的字元逐一寫入裝置資料寄存器 OUT_CHAR * 並在每次寫入後進行忙碌等待 * 直到裝置狀態寄存器 OUT_STATUS 的值為 0。 * 程式在遇到字串中的字元為 'WO' 時停止執行。 * 在每次寫入一個字元後,會不斷檢查裝置狀態寄存器 OUT_STATUS 的值是否為 0,直到其值為 0 才會繼續執行下一次的字元寫入。 #### 這種忙碌等待的方式,其目的是確保裝置已經完成了上一次的寫入操作,並且處於可接收下一次寫入的狀態。在這期間,程式會一直停在這個循環中,不進行其他的任何操作,直到滿足等待條件。 ## Interrupt(Interrupt)輸入/輸出 * Busy/wait效率很低 * CPU 在測試設備時不能做其他工作 * 難以同時進行 I/O * Interrupt允許設備更改CPU 中的控制流 * 導致子程序調用來處理設備 ![](https://hackmd.io/_uploads/BkyzzrZOn.png) Interrupt(Interrupt) * 現代作業系統是Interrupt驅動的 * 事件的發生由來自硬體或軟體的Interrupt發出信號。 * 硬體可以隨時通過向 CPU 發送信號來觸發Interrupt * 軟體可能會因錯誤(除以零或無效內存訪問)或用戶對作業系統服務的請求(系統調用)而觸發Interrupt * 軟體Interrupt也稱為陷阱(trap) ## HW Interrupt ![](https://hackmd.io/_uploads/rJL0__zu3.png) 1. 設備 i 發生中斷 2. 執行設備的服務例程 3. 回傳至使用者 ## SW Interrupt ![](https://hackmd.io/_uploads/S1KStOf_h.png) 步驟與硬體中斷一模一樣 * 硬體中斷是由硬體設備直接觸發,需要硬體支持和中斷控制器進行處理 * 而軟體中斷是由軟體程序中的指令觸發,由軟體本身處理。 突然間被打斷就是HW,主動打斷就是SW ## Interrupt的常用功能 * Interrupt一般通過Interrupt向量將控制權轉移到Interrupt服務程序,Interrupt向量包含所有服務的地址(函數指針)(即Interrupt處理程序)例程 * Interrupt架構必須保存Interrupt指令的地址 * 當另一個Interrupt正在處理時,傳入的Interrupt被禁用,以防止丟失Interrupt # 存儲設備層次結構(Storage-Device Hierarchy) * 按層次結構組織的存儲系統。 * 速度、成本、波動性 * 只有Main memory,CPU可以直接訪問 * RAM:隨機存取存儲器(Random-Access Memory) * Secondary memory - Main memory的擴展,提供大的非易失性存儲容量 * disk ![](https://hackmd.io/_uploads/Hkk-C_Hdn.png) * 這種層次結構的存儲系統利用了存儲介質的特性和成本之間的權衡。 * 較小但更快的存儲層次(如寄存器(registers)和高速緩存(cache))用於存儲最常用和最緊急的數據,以便快速訪問。 * 較大但訪問速度較慢的存儲層次(如主存儲器(Main memory)和輔助存儲器(Secondary memory))用於存儲較大的數據集和長期存儲需求 ## RAM:隨機存取存儲器(Random-Access Memory) RAM是一種計算機系統中常見的存儲技術,用於暫時存儲數據和指令,供CPU和其他硬件設備快速訪 DRAM具有較高的存儲容量和較低的成本,常用於主存儲器。然而,DRAM的訪問速度相對較慢,並且需要定期刷新以維持數據的有效性。 * DRAM(動態RAM): * 只需要一個晶體管 * 消耗更少的電力 * 值必須定期刷新 * 訪問速度:>=30ns SRAM具有快速的訪問速度和高速度的讀寫操作,因此被用作高速緩存和寄存器。然而,SRAM的成本較高,且佔用更多的空間。 * SRAM(靜態RAM): * 需要六個晶體管 * 消耗更多電量 * 訪問速度:10ns~30ns * 用途:高速緩衝存儲器 ## 緩存(Caching) 緩存是一種常見的計算機系統優化技術,用於提高數據訪問速度和系統性能。 緩存通常被用來存儲頻繁訪問的數據,以減少對較慢的主存儲器或外部存儲設備的訪問次數。 * 正在使用的信息從較慢暫時複製到較快Storage * 首先檢查更快的Storage(緩存)以確定信息是否存在 * 如果是,則直接從**緩存**中使用信息(快速) * 如果沒有,則將數據複製到 Caching 並在那裡使用 ![](https://hackmd.io/_uploads/Hk8HTFMu3.png) ### 總的來說 * RAM作為主要的存儲設備,提供大容量的存儲空間 * 而緩存則提供更快的數據訪問速度,以提高系統的效能 它們在計算機系統中共同工作,以平衡存儲需求和性能需求。 ## disk機制 * disk結構: * disk 由一個或多個磁性碟片組成,每個碟片都被劃分為一個或多個圓形磁道,而每個磁道則被劃分為一個或多個扇區。 * 資料儲存: * disk使用磁性材料來儲存資料。資料以磁化的方式記錄在碟片上的磁性表面上。 * 尋道和定位: * 讀取或寫入資料之前,讀寫頭通過在disk上移動,定位到指定的扇區。 * 讀寫操作: * 讀取操作將讀寫頭讀取的資料傳輸到電腦系統的記憶體中 * 而寫入操作則將資料從記憶體寫入到disk中的指定扇區。 * 檔案系統: * 檔案系統負責管理disk上的檔案和目錄結構,以及檔案的讀取、寫入和刪除操作。 * 快取機制: * disk系統通常包含快取來提高效能。快取是指在disk和主記憶體之間的高速儲存區域,用於臨時儲存頻繁存取的資料 * disk速度 * 傳輸時間 = 數據大小/傳輸速率 * 定位時間(random access time)(隨機訪問時間) * 尋道時間 (seek time)(柱面)+旋轉延遲 (rotational latency)(扇區) ![](https://hackmd.io/_uploads/BkiUHFzdn.png) ## 不同級別Storage的性能(Performance of Various Levels of Storage) ![](https://hackmd.io/_uploads/B1sfrKMd3.png) ## 連貫性(Coherency)和一致性(Consistency)問題 連貫性(Coherency):指的是多個處理器或核心之間共享的數據保持一致的狀態。 一致性(Consistency):指的是多個處理器或核心在訪問共享數據時觀察到的數據值是一致的。 * 相同的數據可能出現在不同的級別 * 問題:更改寄存器中的副本使其與其他副本不一致 * 單任務訪問: * 沒問題,始終使用最高級別副本 * 多任務訪問: * 需要獲取最新的值 * 分佈式系統: * 公元前有困難,副本位於不同的計算機上 ![](https://hackmd.io/_uploads/B1AGzsru3.png)

    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