History of operating system development
Punched card
A computer room, a user can only use.
The CPU utilization rate
Line processing system
Support for multiple users to use a computer room
Off-line batch processing
High-speed disk
Improve reading speed file
advantage
Improve CPU utilization
Multi-channel technology (where research-based single core)
Multi-channel
Multiplexing (*****) on space
CPU may be provided to a plurality of users
Multiplexing (*****) on time
Save state switching +
advantage
If the CPU met IO operation, CPU use right of the current program will be disconnected immediately (will improve utilization of CPU)
Shortcoming
If a program uses the CPU time is too long, it will immediately use the right CPU program currently executing off (the program will reduce utilization)
Single Channel
When using the CPU is running a series of multiple users
must be allowed to run to completion on a program to run a program
Concurrent and Parallel
Complicated by
Refers looks like running simultaneously, a plurality of programs save state continuously switching +
parallel
It runs on a real sense, in the case of multi-core, simultaneous execution of multiple programs
process
Procedures and processes
Program: a bunch of code that
processes a bunch of code that runs: Process
Process Scheduling
- FCFS scheduling
Disadvantages: A program to use, program B must wait for the program to use A use after the CPU - Short job priority scheduling
disadvantages: If the program A uses the longest time, there are N time is short program, must wait for all to use after a short time with the program - Round-robin process
time executed by the CPU 1 second, N program loading, to one second aliquot plurality of N time slices Grading feedback queue
will be executed into layers priority levels
Level 1: the highest priority
level 2: Second Priority
level 3: analogy
......When the three states of the scheduler
Ready state: will enter the ready state when all processes created, ready to dispatch
blocking state: those who encounter blocking state into the IO operations, IO operation ends, they must re-enter the ready state
to run state: after the process scheduler, enter the running stateSynchronous and asynchronous
It refers to the submission of the task
Synchronize
If two tasks required to submit, at the time of submission of the first task, you must wait after the execution of the task, we can continue to submit and execute the second task
asynchronous
Means that if two job submission, no place to wait when submitting the first task, and can be submitted immediately perform a second task
Blocking and non-blocking
Clog
Blocking state, met IO will clog
Non-blocking
Ready state and run state
Interview questions: synchronous and asynchronous, blocking and non-blocking is the same thing?
Not the same concept, synchronous and asynchronous preparation period, blocking and non-blocking is the construction period
Create a process in two ways
- Define a task
windows: create a child process, windows will reload the current parent process code to perform a
linux / mac: will the current parent process to re-copy the code in to perform A custom class, and inherit Process
join
Tells the operating system, so that the child process is finished, at the end of the parent process
Inter-process data mutual isolation
The main process and sub-process will have their own name space, isolated from each other so that data
Property of process objects
当前进程.pid
Get the child process
os.getpid()
to obtain the main process pid number
cmd view the process ID:tasklist|findstr
process IDTwo conditions process ID recovery
join.
Child process can be recycled to the main processThe main process ends normally, the child process will be recycled to the main process
Zombie process and orphaned
Zombie process
Refers to the process has ended, but there are PID number, not destroyed
Disadvantages: occupation PID number, operating system resources occupancyOrphaned
Refers to the process is still running, but the parent process ends unexpectedly
operating system optimization mechanisms: a mechanism similar to the orphanage, to help you recover the child has no parent processDaemon
Refers to the end of the primary process, the main process of all child processes created to follow the end, and recovery