操作系统复习

1. Operating System

  1. What does a Mordern OS do?

    Provide abstractions
    Provide Standard Interface
    Mediates Resource Usage
    Consumes Resources

2. Processes and Threads

2.1 What is process and threads

Process is an execution stream in the context of a particular process state.
Thread is an execution stream in the context of a thread state.

The key difference: Multiple threads share parts of their state.

Allowing read write the same memory, but each thread still have own registers.

Reason:

  1. The threads must corrdinate their activities very closely.
  2. It is much easier to coordinate activities.

2.2 Process state information

  1. Register
  2. Stack
  3. Memory
  4. Open file tables
  5. Singal management information

2.3 Multiprogramming

Multiple processes at a time.
Allow system to separate out activites cleanly.

2.4 Context switch

Because multiprogamming, there needs to share the resource, such as CPU.

Therefore, OS needs the ability to switch from one process to another.
That is Context Switch

2.5 PCB

The way to implement the Context Switch is to save and restore the hardware state in PCB (Process Control Block).

2.5.1 PCB depends on hardward

  1. Register

  2. Porcessor Status Word

  3. Memory

    Some machine needs the Memory Management Unit(MMU)

    But the older PC switch all the process’s memory out to disk

2.6 Event-driven

OS is fundamentally event-driven.

That is to wait for an event to happen, response appropriately to the event, then wait for the next event

2.7 Thread Control Block

It is tipically register.

Don’t need to do anything to the MMU when switch threads.

2.8 Each user process is backed by kernel thread

That is the OS will have a separate thread for each process.
And perform the OS activities on behalf of the process.

Advantages:

  1. Allow the programmer to program the actions associate with that activity as a single serial stream of actions and events

  2. Programmer does not have to deal with the complexity of interleaving multiple activities on the same thread

2.9 Asyncorony

0%