Operating System - 1 Operating System Overview

1 What is the operating system

Not a complete, accurate, accepted definition
is system software

  • The user's perspective, os is a control software
  • Management Applications
  • Provide services for applications
  • Kill the application
  • Resource Management
  • Peripheral management, allocation of resources
    Here Insert Picture Description
    the operating system level architecture
  • Under the application
  • On the hardware

Application software: office software, video player software

  • Located below the operating system application software, provide support services for the application software

Here Insert Picture Description
shell: external interfaces such as
kernel: the operating system's internal components:

  • CPU scheduler
  • Physical Memory Management
  • Virtual Memory Management
  • File System Management
  • Interrupt handling and device drivers (and deal directly with the underlying hardware)

OS kernel features:

  • Concurrently (a period of time, a plurality of CPU)
    • A computer system running a plurality of programs exist, the OS needs to manage and schedule
  • shared
    • "Simultaneous" visit
    • Share the mutex
  • virtual
    • The use of multi-channel programming techniques, allowing each user to have a feel for his dedicated service computer
  • asynchronous
    • Execution of the program is not consistent in the end, but stop and go, pushing forward speed unpredictable
    • But as long as the same operating environment, OS need to ensure that the results should be the same as running

2 Why Study the operating system

3 How to learn operating system

4 operating system instance

unix(apple)、linux(android\windows)

5 operating system history

With the changes in hardware, computer architecture, etc.

  1. Early computer programs and data transfer tape
    operating system only play the role of loading
    data up to the computer, and transmits it (a simple mechanical process)
  2. The rapid development of CPU and other hardware, computer speed has been improved, the performance of underutilized
  3. Batch phase (concurrent)
  4. Increasing memory capacity, the CPU executing a plurality of programs (multiprogramming, a CPU)
  5. In order to make better use of computer resources, and better and user interaction, there has been time-sharing system (the period of time is divided into small, can not be perceived, interrupted help achieve time-os)
  6. PC operating system
  7. The rapid development of the network, there has been distributed operating system (storage operation is done by computing data center, connected together by an intermediate internet)
  8. Future trends: more than one computer to work around 1 person

6 operating system structure

Assembly language and machine binding, non-portable
C language is portability

  1. Simple System: MS-DOS (1981-1994)

    • Portion of the monolithic kernel module
    • Function is relatively weak
    • Vulnerable, broken ring
    • Subject to hardware
  2. Unix, using the C language

  3. Microkernel design, as far as possible the core functionality to a user space, the kernel only put basic, loosely coupled, but if the file management and memory management to interact with the kernel, performance is not high

  4. Academia there is a more extreme way - the outer core. The core is divided into two parts, one dealing with the hardware to complete replication of hardware resources; part of dealing with the particular application, over the first portion. Improved speed

  5. Virtual machine monitor (VMM): to convert the interface into many separate machine illusion, each of these interfaces (virtual machine) is valid copy of an original computer system and the completion of all processor instruction (n virtualized computer systems (full computer), so that more than one computer on a single physical computer system had to use more than one variable)
    Here Insert Picture Description
    under the operating system is vmm, hardware is under vmm

7 start, interrupts, exceptions and system calls

7.1 computer starts

Here Insert Picture Description
Power above three main open
os os in the beginning, not in memory
DISK: storage os
the BIOS: the I / O processing system (performed after detecting power peripherals, to load the appropriate software) based on
- the first step specific location and begin execution
Here Insert Picture Description
- POST (power on Self Test)
- look for the video card (screen) and execute BIOS (keyboard and mouse)
- the Bootloader (load os) go from the hard disk into memory, initially in the first primary hard drive boot sector
of a sector is 512 bytes
Here Insert Picture Description

7.2 operating system to interact with the equipment and procedures (interrupt exception system scheduling)

Peripherals for processing by an interrupt and IO
-oriented applications to activate the corresponding function through system calls and exceptions

definition:

  1. System call (from the application)
    Application actively sends a service request to the operating system (application program sends an instruction to the operating system)
  2. Exception (from undesirable application)
    illegal instruction or other processing change state (e.g., memory error) (application exception occurs during execution, the need to complete the corresponding function os)
  3. Interrupt (from peripheral)
    interrupts from different hardware devices and networks timer

Why the application to be contacted by os and hardware?

  • The computer is running, the kernel is a trusted third party (the application can not be trusted, os trusted)
  • Only the kernel can execute privileged instructions
  • In order to facilitate the application (os shielding device such that the bottom of the application software, os to provide a simple interface to up, so that more portable applications)

Differences interrupt abnormal system call

  1. source:
    • Interrupt: Peripherals
    • Exception: an unexpected application behavior (should not have access to the address space accessible; resources are not being met, but quietly os ready)
    • System call: application requests the operation service (read and write files)
  2. Processing time
    • Interrupts: Asynchronous (the application does not know when to lead to disruption event occurs)
    • Exception: synchronous (except 0 will produce abnormal)
    • System call: synchronous (request is synchronous) or asynchronous (return is likely to be synchronous or asynchronous applications may immediately after issuing a request to do other things, the return is asynchronous; synchronization is waiting after the request.)
  3. Response Status
    • Break: continuous, for user application is transparent
    • Exception: kill or re-execute unexpected application instructions
    • System call: Wait and continue the ongoing

Interrupt and exception handling mechanism

  • Interrupts are peripheral events
  • Exceptions are the internal CPU events
  • Interrupt and exception forces the CPU to access some of interrupts and exceptions service access functions

Interrupt

  • hardware:

    • Set interrupt flag (CPU initialization)
      • The internal and external events interrupt flag is set
      • Interrupt event ID
        interrupt ID value of the program of events visit the interrupt vector address
        interrupt is interrupted by an executing program to execute more urgent events, which require certain hardware and software protection (conservation and recovery mechanisms), after this safeguard processed interrupt can continue to perform the original program
  • software:

    • Save the current processing status
    • Interrupt service routine processing
    • Clear terminal labeling
    • Restore previously saved state processing

Exception: Exception number

  • Save site
  • Exception Handling
    • Killing an abnormality program
    • Re-execute the abnormal instruction (os to make up work, handling exceptions)
  • Recovery site

Software system imperceptible abnormalities, do not know when it will be extremely

System calls

The application calls printf (), the system will start calling write ()

  • The main program is accessed by the system call to continue high-level API interface rather than direct
    Here Insert Picture Description
    Here Insert Picture Description
    user mode: a state during which the CPU is running os, (machine instructions, access IO) some instructions can only be executed
    kernel mode: during operation os a state in which the CPU can execute all commands (the privilege, the IO ...)
    when the system call, the user will be realized from the state transition to kernel mode, the control application submitted os, os system can be emitted make a call sign recognition, to complete a specific service
    application issues:
  • Function calls, passing parameters to achieve within a stack space and return
  • System call, os and applications have their own stack, the stack switch switching states require overhead, overhead return is safe and reliable
    Here Insert Picture Description
    verification argument is to say, os mistrust application software, to verify
    the cost is worth it a must
Published 16 original articles · won praise 0 · Views 244

Guess you like

Origin blog.csdn.net/qq_42713936/article/details/104950015