II. Process Management
2.1 Processes and Threads
Basic concepts of the 2.1.1 process
PID (ProcessID)
The concept of the 2.1.1 process
Multi-channel concurrency to perform issues that may occur:
We have to introduce some constraints to the rude execution of the program:
What the process includes:
The Process Control block is a data structure in the Linux is a structural body.
(The answer is the picture above)
Pending status
(Linux code)
2.1.6 Threads
At the beginning of the design process is independent, the process is not allowed to use the same address space, you have to open up a new storage space, and then to fetch, threading design solves this problem.
For example, the player problem:
Single process, read the PCB in the storage space to take out into an area, and then decode, and then put out, and then go to play.
With a thread, in the same storage space, the dispatch is read, decoded, played.
A thread is a unit of a scheduled unit process that is degraded to a resource
Kernel-Level threads:
User-Level threads:
1.runtime
2 . LWP
Online Information:
A user thread is a thread implemented in a user program that does not require kernel support and is not dependent on the operating system core, and the user process uses line libraries to provide functions to create, synchronize, dispatch, and manage threads to control the user thread. User threads do not require user-state/kernel-mindset switching, are fast, the operating system kernel does not know the existence of multithreading, so a thread blocking will cause the entire process (including all its threads) to block. Because the processor time slice allocation here is based on the process as the basic unit, the time per thread execution is relatively reduced in order to add thread support to the operating system, using the user space to increase the runtime to implement the thread, the user thread can not be perceived by the operating system.
Kernel threads and user threads have their own advantages and disadvantages and are generally used in conjunction with
2. 3 Synchronization and mutual exclusion
2. 3.1 Concept of process synchronization
Mutual exclusion: You and I do not communicate, you take away I can not use, when you take away I can use
Direct control of synchronization: You and I have communication, relay competition, the second bar to wait for the first stick to be able to run the stick can not be thrown on the ground, you must give me the stick (and mutually exclusive is to rob each other resources)
Synchronization: Consumers must wait for producers to produce to consume, not to consume in thin air.
N a buffer: If n is produced If you can't put it in, don't let it go.
(Hang the sign and hold the key to get in)
(similar to topological sorting in data structures)
Take the left chopsticks and take the right chopsticks, eat
4
Operating system--chapter II Process Management