Operating system learning notes-1: basic concepts


Operating system learning notes-1: basic concepts

  • Hardware core = > CPU
  • Software core = > operating system (system software)

1. Main objectives:

  • ConvenienceRunning programs on hardware (bare machine) is very troublesome
  • Effectiveness

    • Improve system resource utilization: when there is no OS, devices such as I / O are often idle and not effectively utilized
    • Improve system throughput: organize work flow reasonably and shorten the running cycle of program
  • Expandability: easily add new functions and modules
  • Openness: comply with world standards and norms to achieve mutual compatibility

2. Development process

2.1 no operating system:

Phase I – manual operation:

  • The problem of monopolizing the whole machine: only after one user finishes it can the later users have the chance to use it
  • Low resource utilization:

    • Input and output speed of paper tapeBe relative toCPU processing speedVery slow, which causes the CPU to waste a lot of idle time waiting for input and output
    • The speed of manually storing programs and data into paper tapeBe relative toInput and output of paper tapeVery slow (man-machine conflict)

Stage 2 – offline I / O:

Add one between paper tape and CPUPeripheral machineThe peripheral computer helps to read data into the tape, and the tape can quickly input data into memory for processing.

  • There is a supervision program on the peripheral computer to control the input and output process. This program is the prototype of the later operating system.

2.2 single channel batch processing system

Single pass batch systemContinuous processingTry to reduce the idle waiting time of the machine as much as possible, but there is a situation where CPU and IO are not evenly used (there is always one person who does not work), and resources are still not fully utilized. Here is an example:

If the computer now needs to process three jobs, i.e. j1j2 and J3, each job needs to go through the process of input (1s), calculation (1s) and output (1s).

If the computer is a single channel batch processing system, the processing process is as follows:

Operating system learning notes-1: basic concepts

(picture source: video of Wangdao postgraduate entrance examination)

It can be seen that the input device, CPU and output device can only work serially, and there is no parallel use of them. Although the system processes three jobs continuously as much as possible, it can be seen that there is always at least one party among the input device, CPU and output device at the same timeNothing to do, which is a waste of resources.

2.3 multiprogramming system

Jobs are stored in external memory to form a “backup queue”. The job scheduler selects several jobs to transfer into memory so that they share CPU and system resources. Due to multiple procedures, it can be timelyPatch positionCPU idle.

  • Features: disorder (jobs entering memory first may not be completed first), multichannel, and schedulability
  • Advantages: high resource utilization and large system throughput
  • Disadvantages: long average turnover time, unable to interact

Here is an example:

If the computer now needs to process three jobs, i.e. j1j2 and J3, each job needs to go through the process of input (1s), calculation (1s) and output (1s).

If the computer is a multi-channel batch processing system, the processing process is as follows:

Operating system learning notes-1: basic concepts

(picture source: video of Wangdao postgraduate entrance examination)

It can be seen that input device, CPU and output device can be used in parallel. The calculation starts after the completion of the input of J1. At this time, the input device is idle, which can be used for the input of J2. After the completion of the calculation of J1, the output starts. At this time, the CPU is idle, which can be used for the calculation of J2. When the calculation of J2 is completed, the input device is idle, which can be used for the calculation of J3 As you can see, the multi-channel batch processing system makes the input device, CPU and output device all three at the same timeHave something to do, call the resources fully. Compared with the single batch system, it takes 9 seconds to complete the same work, and the multi batch system only takes 5 seconds.

2.4 time sharing system

Requirements: human computer interaction (to be able to modify and control), shared host (with the feeling of “exclusive”)

The key of human-computer interaction: the system should accept and process the user’s input in time, so the job can no longer be stored in external memory (disk), butDirect access to memoryIn addition, it is necessary to adoptRotation operationWay. The concept of time slice is introduced. Time slice can be regarded as a time limit. Each job (user) has only one time slice running time. After this time slice, it must be given to other jobs (users) to run.


  • Multiplexing: one host,Multi terminal, multiple users followTime sharing principleShare a computer
  • Independence: one user and one terminal, do not disturb each other, have a “exclusive” feeling
  • Timeliness: timely response to user requests
  • Interactivity: user requests system to provide some services

The disadvantage of a time-sharing system is that it isfairBecause they are not prioritized, they cannot be prioritized.

2.5 real time system

Real time means “in time”. We should pay attention to the difference between time-sharing system and real-time system: the real-time system can respond to the requests of external events in time, which means that urgent tasks can be queued without time sliceGet priority

Real time tasks:

  • Is the task periodic? Periodic real-time task: non periodic real-time task (start deadline, finish deadline)
  • What is the deadline? Hard real time task (deadline cannot be missed): soft real time task (deadline can be missed)


  • Multiplexing: the system periodically collects multiple field information
  • Independence: collection of information and control of objects without mutual interference
  • timeliness: deadline required by control object
  • Interactivity: limited to certain system specific services
  • reliability: multi level fault tolerance measures

2.6 microcomputer operation system


2.7 network operating system


PS: withBatch processing, time-sharing, real-time processingIt’s called the general operating system

3. Basic characteristics

3.1 Concurrency:

To improve resource utilization and increase system throughput depends on the concurrent execution of programs.

The difference between parallel and concurrent

ParallelRefers toAt the same time, multiple instructions are executed on multiple processors at the same time。 For example, in the figure below, three people eat bread at the same time, and they all eat it in one minute. Whether from the micro point of view (focusing on one second) or from the macro point of view (focusing on dozens of seconds), all three are executed at the same time

ConcurrencyRefers toOnly one instruction can be executed at the same time, but multiple process instructions are quicklyRotation execution, which makes it possible for multiple processes to execute at the same time at the macro level, but in fact, it is not executed at the same time at the micro level. For example, in the figure below, ABC three people eat bread, 0-10 seconds a eat bread, 10-20 seconds B eat bread, 20-30 seconds C eat bread, so in the micro perspective (focusing on the comparison of the second level), it is obvious that they are not executed at the same time; but in the macro perspective (focusing on the overall 1 minute), the more refined time is not considered, and the three are executed at the same time.

  • Process: can run independently in the system and be the basic unit of resource allocation, and can be executed concurrently after the program creates a process

3.2 share

Multiple concurrent processes use system resources together, and resources are alternately used by multiple processes in the same time period

  • Exclusive sharing mode (for example, printer, only after a process accesses and releases the system resource, another process is allowed to access the resource)
  • Simultaneous access mode (such as disk device, which can be accessed at the same time for a period of time). At the same time, it’s on the macro level.)

PS: concurrency and sharing are mutually existing conditions, which are the most basic characteristics of OS: process concurrency is the premise of resource sharing, and access to shared resources ensures the smooth execution of process concurrency

3.3 virtual

Transforming a physical entity into several logical counterparts through virtual technology

  • Time division multiplexing technology: divide a single large time period into multiple time slices, and execute each process alternately. For example, virtual processor technology is a kind of time division multiplexing technology – Single core computer opens multiple software at the same time, which seems to users that multiple CPUs are running these software.
  • Space division multiplexing technology: virtual memory technology is a kind of space division multiplexing technology – computers only have 4G memory. Although the total memory consumed by each running software is far more than 4G, they can still operate normally, which seems to users that physical memory exceeds 4G.

3.4 asynchronous

Multiple programs execute concurrently, but due to the limited resources, the execution of the process is not always to the end, advancing at an unpredictable speed.

4. Basic functions

4.1 processor management function

  • Process control: for job creation, cancellation, planting process, control the state transition of the process
  • Process synchronization: coordinating the operation of multiple processes

    • Process mutual exclusion
    • Process synchronization mode
  • Process communication: information exchange between processes
  • Scheduling: job scheduling, process scheduling

4.2 memory management function

  • Memory allocation: static memory allocation (no new memory space can be applied during operation) and dynamic memory allocation (new memory space can be applied during operation)
  • Memory protection: each program only runs in its own memory area
  • Address mapping: logical address = > physical address
  • Memory expansion: with the help of virtual storage technology, fromlogicallyExpand memory

4.3 equipment management function

  • Buffer management: introduce buffer between I / O and CPU to improve resource utilization and system throughput. Buffer mechanism includes single buffer mechanism, double buffer mechanism and public buffer pool mechanism
  • Equipment allocation: allocate the equipment according to the type of equipment requested by the user and the allocation algorithm adopted
  • Device processing: realize the communication between CPU and device controller.

4.4 document management function

  • Management of file storage space: allocate external storage space for files
  • Directory management: creating a directory entry for a file
  • File read / write management and protection: read / write files in external storage to provide protection

4.5 interface between operating system and user

  • Command interface (directly used by users): online user interface, offline user interface
  • Program interface (used indirectly by user through program): the only way for user program to obtain OS service is to let user program access system resources during execution,Sometimes called system call
  • Graphical user interface

4.6 new functions of modern OS

  • System security: authentication technology, password technology, access control technology, anti-virus technology
  • Network functions and services: network communication, resource management, application interoperability
  • Support multimedia: admission control function, real-time scheduling, multimedia file storage