Let's make an analogy.
Open a QQ, opened a process, opened a thunderbolt, opened a process.
QQ in this process, the transmission of text to open a thread, the transmission of voice opened a thread, pop-up dialog box and opened a thread.
So running a software is equivalent to opening a process. In the process of running the software (in this process), a number of work support to complete the operation of QQ, then this "multiple jobs" have a thread.
So a process is in control of multiple threads.
In layman's words: "The process is the parents, the many threads of the son ...."
Serious's saying
1. What is the difference between a process and a thread?
Parsing: (1) a process is a separate unit of resource allocation and scheduling, while a thread is the basic unit of CPU scheduling
(2) Multiple threads can be included in the same process, and the thread shares the resources (registers, stacks, contexts) of the entire process, one for at least one thread.
(3) The creation of the process calls fork or vfork, while the thread's creation calls Pthread_create, and all threads it owns are destroyed when the process ends, and the end of the thread does not affect the end of other threads in the same process
(4) The thread is a light two-level process, it takes much less time to create and destroy than the process, and all the execution functions in the operating system are created threads to complete
(5) Threads are generally synchronized and mutually exclusive when they are executed because they share all the resources of the same process
(6) The thread has its own private property TCB, thread ID, register, hardware context, and the process also has its own private properties Process Control block PCB, these private properties are not shared, used to mark a process or a thread's flag
2, deadlock? What is the cause of the deadlock? What are the necessary conditions for deadlocks? How to handle deadlocks?
Resolution: (-) a stalemate that arises from mutual waiting for resources, and if no external intervention will persist
(-) Inadequate system resources, competing resources, and improper order of resource requests
(2) Mutual exclusion, non-preemption, cyclic waiting, request and hold
(3) because the mutex is immutable, it can only break one of the other three conditions to unlock the deadlock method: deprive the resource, kill one of the threads
3. Windows Memory Management method: Segment storage, page storage, Segment page storage
Analytical:
4, the process of several States?
Parsing: (1) run (running state): A running process or a process that waits on a queue, waiting for a process to run as long as the CPU is available
(2) Sleep (interruptible sleep): equivalent to blocking or waiting in the state
(3) D (non-interruptible hibernation): Process on disk
(4) T (stop State): This state can not be seen visually, because the process is stopped after the release of resources, so will not stay in Linux
(5) Z (zombie State): The child process ends first with the parent process, but the parent process does not call wait or waitpid to reclaim the resources of the child process, so the subprocess becomes a zombie process, and if the parent process is still not recovering resources from the child process, then process 1th will reclaim
5, IPC communication mode?
Parsing: (1) Pipeline (anonymous pipe (pipe affinity process communication), named pipe (Mkfifo/mknod))
(2) Message Queuing: is a message-based, non-affinity inter-process communication, the main functions: Msgget, Msgsend, MSGRECV, Msgctl
(3) Semaphore: equivalent to a mutual exclusion lock, through P, v operation, main functions: Semget, SEMOP, Semctl
(4) Shared memory: is the fastest inter-process communication, so it is often a collection of signals or mutual exclusion lock to achieve synchronization, Shmget, Shmat, SHMDT, Shmctl
6. What is virtual memory?
Parsing: Is the process part of the memory, so that a large program can be implemented in a smaller than its memory run, its main implementation depends on the program to swap out to achieve, because in memory 0~3g is used by the user, 3~4g is memory use, through the mapping to achieve the logical address to physical address mapping
7, virtual address, logical address, linear address, the difference between physical address?
Parsing: The fragmentation mechanism translates a logical address into a linear address, and then the paging mechanism translates a linear address into a physical address.
(1) Virtual address: virtual Memory mapped address
(2) Logical address: The segment offset of the program is formed, the address that is taken from the C + + program is the logical address
(3) Linear address: Is the logical address to the physical address of the middle tier, only when the paging mechanism to have a linear address, if there is no paging mechanism, then the linear address is the physical address
(4) Physical Address: Is the real memory of the hardware address,
Logical address (start segment)--"linear address (start paging)--" Physical address
What is the difference between a thread and a process?