A. The difference between programs and processes
1. Programs
A bunch of static code files
2. Process
Program a running process, abstract concept (originated in the operating system)
3. Process whom run
Controlled by the operating system calls, handed CPU running
II. Operating System
Operating system location on your computer
1. What is the operating system
Operating system is a coordinated control program management and control of computer hardware and software resources.
2. The role of the operating system
1. Some ugly operation of complex computer hardware becomes simple and beautiful interface
2. The multiple processes to seize the CPU resources become reasonable and orderly.
3. Multi-channel technology
Multi-channel multi-channel technology refers to a plurality of programs. Multi-channel technology background in order to solve the plurality of programs competing for the same resources (such as CPU) ordered scheduling problem, i.e. solution multiplexed (multiplexed on the multiplexing time 1. Space 2.)
1. spatial multiplexing on
The memory is divided into several parts, each part into a program, so that, at the same time in memory there will be a multi-channel program. (Memory isolation)
2. multiplexed on time
CPU implemented switch between a plurality of processes, and hold.
Improve efficiency, maximize use of CPU
If an IO-intensive process, improve the efficiency of switching back and forth (automatic switching when blocking IO)
If it is a computationally intensive, reducing the efficiency toggling
Theory III. Process
1
2
3
4
5
6
7
8
9
|
1.
串行:所有任务一个一个完成
2.
并发:一个cpu完成多个人为,看起来像是同时完成
3.
并行:多个cpu执行多个任务,真正的同时完成
4.
阻塞:cpu遇到io就是阻塞
5.
非阻塞:没有io,就叫非阻塞
6.
进程创建:一个子进程必须依赖于一个主进程才能开启
unix:fork一个子进程会完全复制一个主进程的所有资源,初始资源不变
windows:操作系统调用CreateProcess创建进程。创建一个子进程,会复制主进程所有的资源,但是会改变一些资源
7.cpu
:cpu是用来做计算,cpu是无法执行IO操作的,一旦遇到io操作,应该让cpu去执行别的任务
|
Status of the process
Encounters IO operations (Input, output), will block, complete IO will enter the ready state, then wait cpu execution. Program execution time slice is finished (cpu cut to another program execution), it will enter the ready state.
IV. Concurrent and Parallel
Either concurrent or parallel, users seem "simultaneous" operation, whether it is a process or thread, just one task only, the real work is cpu, cpu to do these tasks, while the same time, only a cpu perform a task
1. Concurrent
Pseudo-parallel, that appear to be run simultaneously. Cpu + single multi-channel technology can be implemented concurrently
2. Parallel
Run, only be achieved in parallel with multiple cpu
Nucleation single, multi-channel technique may be utilized, a multi-core, each core may also use multi-channel technology (for multi-channel technology in terms of single-core)