Uduru0522
    • 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 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
    • 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 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
    --- title: "Operating System - Chapter 1: Introduction to Operating System" --- # <u>Operating System Chapter 01</u><br><span>Introduction to Operating System</span> ###### tags — `operating-system`, `note` <style> .markdown-body h1 > span:last-child{ font-size: 18pt; float: right; width: 100%; text-align: right; border-bottom: 1pt #EEE solid; padding-bottom: 5pt; margin-bottom: 5pt } .markdown-body h1{ border: none; } .markdown-body i, em{ font-weight: 550; color: sienna; } .markdown-body h3::before{ content: "▮ "; position: relative; left: -3px; bottom: 2px } .markdown-body h2{ padding-top: 5px; padding-left: 6px; background: linear-gradient(90deg, rgba(0,0,0,0.15) 0%, rgba(58,121,9,0.15) 25%, rgba(255,255,255,0) 100%); } .markdown-body img{ width: 100%; border: 3px #888888 solid } li li strong{ font-weight: 600; } .word-meaning{ color: #CCCCCC; } </style> ## Component of a Operating System + **Kernel** — The program that is *always* running on the computer. + **Middleware** — Frameworks that ease application development and provide feature. + **System Software** — Aids the kernel. ## Component of a General-Purpose Computer + **CPU** — One or more, the **c**entral **p**rocessing **u**nit. + **Device Controller** — Controls a type of devices. + **Device Driver** — Provide the operating system a uniform interface to the device controller. + **Shared Memory** + **Memory Controller** — Rules access to the shared memory. + **Bus** — Connects the above components. ![](https://i.imgur.com/rHrUjsz.png) ## Interrupts When a hardware triggers an interrupt, the CPU backups its current execution and executes the *interrupt service routine*. Since they occur frequently, the routine must be performed fast. The **Interrupt Vector**, contains a table of addresses pointing to the various interrupt service routines . ### Implementation of Interrupts + **Inturrupt-Request Line** — Connects to the CPU hardware, which the CPU checks after every instructions. Signals interruption and the corresponing routine table index. + **Interrupt-Handler Routine** — The routine where the specified routine index would jump to. The handler backups any states that would be changed. After the routine, it executes a `return_from_interruption` instruction to restore the states. Using keywords, + The device controller *raises* a interruption, + The CPU *catches* the interruption and, + *Dispatches* to the corresponding handler, + Finally, the handler *clears* the interrupt. ### Interrupt-Controller Hardware Handles the following work, apart from basic interrupt handling: + Defer interrupt handling during critical processing + Efficent way to dispatch to the proper handler + Distinguish interrupts with different priorities and respond. ### Interrupt-Request Lines + **Nonmaskable Interrupt** — Reserved for events, like errors. + **Maskable Interrupt** — Used by device controllers to request service, can be blocked by CPU during critical sequences. ### Interrupt Chaining The entries of the interrupt vector points to *a list of handlers*, and checks one by one which could do the work. Balances between a huge interruption table and the time-consuming search by only 1 interrupt handler. ## Storage + **RAM** (Random Access Memory) - *main memory* — most of programs stores here. - *Volitale* — Data lost when power off. - Implemented on **DRAM**(Dynamic random-access memory). + **Firmwares** - E.g., **EEPROM**(Electrically Erasable Programmable Rean-Only Memory) - Used to store the *bootstrap program* — Loads the operating system. - *Non-volitale* — Data still present after power loss. - Slow on writing data, cannot rewrite frequently. All storage form provide *array of bytes*, with addresses assigned to all of it. ### Instruction-Execution Cycle — Under <u>von Neumann Architecture</u> 1. Instruction fetchd from memory, stored to *instruction register*. 2. Instruction *decoded* and fetch operand data. 3. Execution. 4. Writeback result to memory (if need to). ### Secondary Storage + **HDD** (Hard Drive Disk) + **NVM** (Nonvolatile Memory) Used to deal with the two cons of main memory: 1. Too small to store all needed program and data. 2. Volitile, cannot store permanently ### Tertiary Storage + Slow and large for special purposes. + E.g., CD-ROM, cache memory ![](https://i.imgur.com/hMqaVMN.png) ## I/O Structure Interrupt driven I/O creates huge overhead on bulk data transfer, so the devices utilies **DMA** (Direct Memory Access) — Directly write data onto the storage, not envolving the CPU. Only 1 interrupt is generated after each block of data is finished transferring, signaling the CPU. ## Components of Computer System + **CPU** — The hardware that executes instructions. + **Processer** — Processor—Aphysical chip that contains one or more CPUs. + **Core** — The basic computation unit of the CPU. + **Multicore** — Including multiple computing cores on the same CPU. + **Multiprocessor** — Including multiple processors. ### SMP — Symmetric Multiprocessing Each peer CPU has its own registers, own cache, can execute all instruictions. Shared cache also exists between CPUs. ### NUMA — Non-Uniform Memory Access Each CPU owns its seperate local memory, but all shares a physical address space, connected by *shared system interconnect*. Memory access on own memory is faster than accesing others', thus "non-uniform". ### Blade Servers System with <u>mutiple processer boards, I/O boards, networking boards, etc.</u>, but each holds its own operating system and can work and boot independly. ### Clustered Systems Multiple computer systems connected via **LAN** (Local Area Network) or **WAN** (Wide Area Network), while each node is typacially a multiprocesser system. + **High-Availiability** — Continues even when some systems go down, the monitoring system would pick up the work and continue. + **Graceful Degradation** — The degree of above availiability. + **Fault Tolerence** — The ability to detect, diagnose and possibly correct the faliure. #### Asymmetric Clustering 1 system from the cluster constantly monitor other systems, called the *hot-standby system*; when the system fails, the hot-standby system become the one running. #### Symmetric Clustering Pairs of systems are processing and also monitoring each other. #### DLM — Distributed Lock Manager The function that a system controls access to shared storage space within clustered systems. #### SAN — Storage Area Network Local storage pool assigned to each system on clustered systems, that when ever data on some host systems, the control system may order it to process. ## Operating System Operations 1. The *bootstrap program* locates and loads the operation system kernel to memory 2. **System Daemons** — System programs loaded along the kernel that also runs the whole time. After this phase, the system is fully booted. 3. The operating systems waits for either *interrupts*, *traps* (or an *exeception*) — an software generated interrupt due to errors or *system call*. ## Multiprogramming & Multiprocessing By proper *CPU scheduling*, we are able to achieve the following ideas: ### Multiprogramming By loading multiple *processes* on the memory and switching different between them when the CPU has to wait for the current executing process (that is, whenever it causes the CPU to idle), the CPU is kept busy and multiple programs are executed simutaneously. ### Multitasking The process switch occurs frequently, providing a fast *respond time* to the user. ## Dual-Mode / Multimode Processing The operating system switch between 2 modes: + **User Mode** — To perform user applications + **Kernel Mode** — Switched when user application request service, able to access and execute *previleged instructions*. Some providers extend to more modes: + <u>Intel processers</u> has *rings 0~3*, which ring 0 is the kernel mode, and ring 3 is the user mode. + <u>ARMv8 systems</u> has 7 modes. CPU with supports *virtualization* often has a seperate mode to indicate the **VMM** (Virtual Machine Manager) is in control. ## Timers Could be used to signal program timeout, for example. + **Fixed Rate Timers** — Sends a interrupt after everey specified time lapsed. + **Varable Timer** — Implemented by a fixed rate timer and a counter. Under Linux, `HZ` marks the number of interrupt sent in 1 second, and `jiffles` counts how many interrupts had been sent. ## Resource Management ### Process Management + **Program Counter** — Exist in each thread, points to the next instruction execute + **System Process** — Executes system code. + **User Process** — Execute user coed. The operating system is responsible for: + Create/Delete both user and system processes + Schedule process and threads on CPUs + Suspend/Resume processes + Provide mechanism for process synchronization + Procidde machanism for process communication ### Memory Management For better utilization of CPU time, multiple programs are loaded on the memory, thus make managing memory a neccessity. The operating system is responsible for: + Keep track of each part of memory's availiability or its owner + Allocate/Deallocate memory space according to need + Decide which data/program to move in/out of memory ### File System Management The operating system is responsible for: + Create/Delete files + Create/Delete directories to organize files + Support primitives<span class="word-meaning"> (basic construction)</span> for manipulating file and directories + Map files to mass storage + Backup file on nonvolitale storage media ### Mass-Storage Management On secondary storage devices, the operating system is responsible for: + Mounting/Unmounting + Free space management + Storage Allocation + Disk Scheduling + Partitioning + Protection ### Cache Management Caching lets the CPU access frequently used data faster, by directily connect to the registers and store copies of data in the memory. ### I/O System Management The operating system hides the peculiarities of the I/O system behind the *I/O subsystem*. The I/O sybsystem's components are: + Memory managment component that supports *buffering*, *caching* and *spooling* <span class="word-meaning">(to send data to a intermideate store)</span> + A general device-driver interface + Driver for specific hardware devices. ## Protection and Security **Protection** is the action to limit and controlling process or user access to resources. However, it couldn't avoid attacks like faking authorized user's sigmature. **Security** is to defent the system from attacks. By assigning every user its unique **UID** (User ID), the operating system could recogonize usere and grant their privileges. ## Virtualization Abstracting a single physical computer into to seperater computer environments. **Emulation** — Simulating hardware in software. **VMM** (Virtual Machine Manager) — Runs several guest operating systems, manage resource use and protecting from each other. ## Distributed Systems Pschyally seperate, possible heterogeneous conputer systems that are networked so the users could access all resources within the system. The most common network protocol is *TCP/IP*. ### Network Characterization Networks are characterized according to their distances. 1. **WAN** — Wide Area Network (E.g., A city) 2. **LAN** — Local Area Network (E.h., Within a campus) Or, other forms: 1. **PAN** — Personal Area Network (E.g., bluetooth between phone and headset) 2. **MAN** — Metropolian Area Network (Buildings within a city) ## Computing Enviroments + **Traditional Computing** — The "typical office enviroment" + **Mobile Computing** — Using devices that are portable and lightweight + **Client Server Computing** — A system where **server systems** satisfies requests generated by *client systems* throught network. + **Peer-to-Peer Computing** — All nodes (peers) in the network can act like both client and the server. + **Cloud Computing** — Delivers computing, storage and applications as a <u>service</u>. - **Public Cloud** — Availiable via the internet, grant access to whom willing to pay - **Private Cloud** — Within company, for only the company's use - **Hybrid Cloud** — Mix the above two - **SaaS (Software as a Service)** — Applications availiable via the internet (E.g., Document Processers) - **PaaS (Platform as a Service)** — Software stack ready for application use via internet (E.g., Database server) - **IaaS (Infrastructure as a Service)** — Server/Storages abailiable via internet (E.g., storage for backup copies)

    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