前言

距離在中大修完OS已經過去兩年了,作為一個內容繁多且碎片化知識極多的領域,我發現自己已經忘了很多了那個時候用的快樂學習法。趁著這個學期再去旁聽一次呂老師的OS課程做複習之用,也將課程內容整理到博客上以深刻印象。本文是第一次上課的總結。

OS定義

An operating system (OS) is system software that manages computer hardware, software resources, and provides common services for computer programs.

粗淺的來說,OS就是計算機軟硬體資源的分配者、提供服務的支持者,應用程式與硬體之間的中間人。

在上圖中也可以清楚的看到OS位於應用程式與硬體之間,應用程式與硬體之間的交互都要經過OS才能達成,不可直接互相交互。

OS分類

  • Batch OS (批處理作業系統) 將有相同工作或相同需求的任務合成一個批次進行處理的OS,這是一種非常陳舊的作業系統種類。

Linux下用&進行背景進程工作時,進程處理的方式即為batch.

  • Time sharing OS (分時作業系統)

每一個任務都會獲得一定的CPU time去執行,在這個時間結束後切換到另一個任務,往直至結束所有任務。

每個任務獲得的執行時間段稱為quantum 或 slice 或slot。

  • Real time OS

    這種OS應用於非常嚴謹的領域,當一個任務需要執行時,OS會立即執行該任務並在極短時間內完成回應。例如用在飛彈發射等領域。

OS 功能

  • Process management:- Process management helps OS to create and delete processes. It also provides mechanisms for synchronization and communication among processes.

  • Memory management:- Memory management module performs the task of allocation and de-allocation of memory space to programs in need of this resources.

  • File management:- It manages all the file-related activities such as organization storage, retrieval, naming, sharing, and protection of files.

  • Device Management: Device management keeps tracks of all devices. This module also responsible for this task is known as the I/O controller. It also performs the task of allocation and de-allocation of the devices.

  • I/O System Management: One of the main objects of any OS is to hide the peculiarities of that hardware devices from the user.

  • Secondary-Storage Management: Systems have several levels of storage which includes primary storage, secondary storage, and cache storage. Instructions and data must be stored in primary storage or cache so that a running program can reference it.

  • Security:- Security module protects the data and information of a computer system against malware threat and authorized access.

  • Command interpretation: This module is interpreting commands given by the and acting system resources to process that commands.

  • Networking: A distributed system is a group of processors which do not share memory, hardware devices, or a clock. The processors communicate with one another through the network.

  • Job accounting: Keeping track of time & resource used by various job and users.

  • Communication management: Coordination and assignment of compilers, interpreters, and another software resource of the various users of the computer systems.

OS相關的一些概念

Process:a process is the instance of a computer program that is being executed by one or many threads.

進程是正在被執行的程式

system call: a system call (commonly abbreviated to syscall) is the programmatic way in which a computer program requests a service from the kernel of the operating system on which it is executed.

系統調用是請求OS為程式做一些服務的方式。

DMA:Direct memory access (DMA) is a feature of computer systems that allows certain hardware subsystems to access main system memory (random-access memory) independent of the central processing unit (CPU).

DMA指硬體可以直接訪問memory而不需要經過CPU之手。

HDD:A hard disk drive (HDD), hard disk, hard drive, or fixed disk, is an electro-mechanical data storage device that stores and retrieves digital data using magnetic storage and one or more rigid rapidly rotating platters coated with magnetic material.

HDD本意指磁盤驅動器,現在參與disk同意義。

Interrupt is a signal emitted by hardware or software when a process or an event needs immediate attention.

硬體或軟體需要CPU立即注意到某事時發出的信號叫做中斷。

“时钟中断”是特别重要的一个中断,因为整个操作系统的活动都受到它的激励。系统利用时钟中断维持系统时间、促使环境的切换,以保证所有进程共享CPU;利用时钟中断进行记帐、监督系统工作以及确定未来的调度优先级等工作。可以说,“时钟中断”是整个操作系统的脉搏。

參考

  • https://www.geeksforgeeks.org
  • Wikipedia
  • https://blog.csdn.net/farmwang/article/details/70173139
  • https://www.guru99.com/operating-system-tutorial.html