劉庭宇
    • 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
    # 作業系統大傻逼 ## 計算機系統四組件 * **硬體(Hardware)** * 提供基本的計算資源 * **操作系統(Operating System)** * 控制和協調各種應用程序和使用者之間的硬體資源使用 * 確保資源的有效分配和管理 * **應用程式(Application Programs)** * 定義系統資源如何用於解決使用者的計算問題 * 例子包括文字處理器、編譯器、網頁瀏覽器、資料庫系統和電子遊戲 * **使用者(Users)** * 包括人類使用者、其他機器和其他計算機系統 * 使用應用程式和操作系統來執行各種任務和操作 ## 中斷的常見功能: * 中斷將控制權轉移到中斷服務例程,通常是透過 **中斷向量(interrupt vector)** 實現的,其中包含了所有服務例程的地址。 * **中斷架構必須保存被中斷指令的地址**,以便在中斷處理完畢後能夠回到正確的執行位置。 * **陷阱或異常(trap or exception)** 是一種由**軟體生成的中斷**,可能是由錯誤或使用者的請求所引起。這些異常通常需要被操作系統或應用程序處理,以確保系統的穩定性和安全性。 * 操作系統是**中斷驅動**的: * 操作系統通常使用中斷來處理各種事件,如I/O操作、錯誤處理、多任務管理等,以確保系統能夠有效運作和及時響應用戶的需求。 ## 中斷處理 * 操作系統會保留CPU的狀態: **存儲 registers 和 program counter 的值**。這是為了確保在中斷處理完成後,CPU能夠回到原來的狀態,繼續執行被中斷的程序。 * 操作系統需要確定發生了哪種類型的中斷。這可以通過兩種方式實現: * **輪詢(polling)**:操作系統定期檢查中斷狀態,並根據不同的中斷來執行相應的處理。 * **向量中斷系統(vectored interrupt system)**:在這種系統中,每種中斷都有一個對應的中斷向量,包含了處理該中斷的程序地址。當中斷發生時,CPU根據中斷向量找到對應的處理程序,然後跳轉到該程序 ## 中斷時間線 ![](https://hackmd.io/_uploads/BkQakSfMT.png) ## I/O架構 * I/O 開始後,只有在完成 I/O 時才將控制權返回給使用者程式。 * Wait 指令使 CPU 閒置,直到下一個中斷。 * Wait 迴圈(爭取記憶體存取權)。 * 同時只允許一個 I/O 請求,無法進行同時的 I/O 處理。 * I/O 開始後,控制權會立即返回給使用者程式,無需等待 I/O 完成。 * **System call**:請求操作系統允許使用者等待 I/O 完成。 * **Device-status table**包含每個 I/O 裝置的條目,指示其類型、地址和狀態。 * 操作系統通過索引 I/O 裝置表來確定裝置狀態並修改表條目以包括中斷信息。 ## 記憶體結構 * **主記憶體(Main memory)**:CPU 可以直接訪問的唯一大型儲存媒體。 * 隨機訪問 * 通常是揮發性的 * **次要儲存(Secondary storage)**:主記憶體的擴充,提供大容量的非揮發性儲存能力。 * **硬碟(Secondary storage)**:由具有磁記錄材料的堅固金屬或玻璃碟片組成。 * 硬碟表面在邏輯上分為磁道,而磁道則分為扇區。 * 硬碟控制器確定設備和計算機之間的邏輯互動。 * **固態硬碟(Solid-state disks)**:比硬碟更快,並且是非揮發性的。 * 使用各種技術 * 變得越來越受歡迎 ## 記憶體架構 ![](https://hackmd.io/_uploads/ryfSxrzGT.png) ## 快取記憶體 * 重要原則,可在電腦的多個層次中實現(硬體、作業系統、軟體)。 * 從較慢的儲存複製使用中的資訊到較快的儲存,以供暫時使用。 * 先檢查較快的儲存(快取)以確定資訊是否存在。 * 如果存在,則直接從快取中使用資訊(速度快)。 * 如果不存在,將資料複製到快取中並在那裡使用。 * 快取大小 < 被快取的儲存。 * 快取管理是一個重要的設計問題。 * 快取大小和替換策略。 ## Direct Memory Access Structure(直接記憶體存取結構) * 用於高速I/O裝置,能夠以接近記憶體速度傳輸資訊。 * 裝置控制器直接將資料區存儲區中的數據區塊傳送到主記憶體,無需CPU介入。 * 每個**區塊(Block)** 只產生一個中斷,而不是每個**位元組(Byte)** 產生一個中斷。 ## 電腦系統架構 * 大多數系統使用單一通用處理器 * 大多數系統同時也具有特定用途的處理器 * 多處理器系統在使用和重要性上不斷增長 * 也被稱為並行系統 **(parallel systems)**,緊密耦合系統 **(parallel systems)** * 優勢包括: * 增加吞吐量 * 規模經濟 * 增加可靠性 - graceful degradation or fault tolerance * **Graceful degradation:** 旨在確保即使某些硬件組件或功能失效,系統仍能夠繼續運行,盡可能提供服務,儘管可能不再達到最優性能。這有助於提高系統的可用性和可靠性,並減少由硬件故障引起的服務中斷。 * **Fault tolerance:** 有些系統不僅實現優雅退化,還能夠容忍任何單個組件的故障,並繼續運作。容錯容忍是一種更高級的系統設計原則,旨在確保系統能夠在單個組件失效的情況下繼續正常運行,而不會因為單一組件的故障而引起服務中斷。這要求系統具有冗餘組件、自動故障恢復機制和其他技術,以確保高度的可用性和可靠性。 ## 兩種多處理器系統的類型如下: * **非對稱多處理(Asymmetric Multiprocessing):** **每個處理器被分配了特定的任務或工作**,並且不一定擁有相同的能力。通常,其中一個處理器被指派為主要處理器,而其他處理器可能專門負責特定的工作,例如I/O處理或其他特殊用途。 * **對稱多處理(Symmetric Multiprocessing):** **每個處理器具有相同的能力**,並且可以執行系統中的所有工作。處理器之間通常共享相同的工作負載,能夠同時處理多個任務,以提高系統性能和效率。這種設計通常更均衡,用於多任務處理和平行計算。 ## 叢集系統(Clustered Systems): * 叢集系統與多處理器系統不同,它是**由多個獨立的系統(或節點)組成** 的。 * 通常通過**存儲區網路(Storage-Area Network,SAN)** 共享存儲。 * 提供高可用性服務,能夠在硬件或軟體故障的情況下持續提供服務。 * **非對稱叢集(Asymmetric clustering):** 有一台機器處於熱備用模式,當主機發生故障時接管服務。 * **對稱叢集(Symmetric clustering):** 多個節點運行應用程序,相互監控,能夠共同提供服務,以實現更好的可用性和容錯容忍。 ## 熱備用主機(hot-standby host) 主要用於**監控 active server**,不執行實際的工作。如果 active server 發生故障,熱備用主機將立即接管服務,變成新的 active server,以確保系統的連續運作。

    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