Windows common face question--process, thread

Source: Internet
Author: User

1. What is the process and what is the thread, please talk about your understanding

A: Processes and threads are an important concept in the operating system. A process is an application running in an operating system, and a thread is a unit that is required to accomplish a task independently in a program and to implement a function. Process is like a factory, can complete a product production, and the thread is like a factory different departments, can be complementary interference to complete a task independently. A process runs at least one thread.

2. How to access the same kernel object in different processes. Please say at least three ways

A: To access the kernel object, you need to have a handle entry in the handle table of the process pointing to this kernel object.
A. Inherited from a parent process to a child process, when a parent process creates a child process, the child process can inherit all the inheritable handles from the parent process to its own handle table if the property of the inherited handle is specified. (But even if the handle is inherited, the child process does not know who it inherits, what the handle value is, and can only be told by the parent process through process communication)
B. When creating a kernel object in process A, name the kernel object and open the kernel object by name in process B. (This method cannot be used if the kernel object cannot be named or if it does not have an identity.) )
C. Use the DuplicateHandle () API to open the object and get a handle.

3. When a process is destroyed, will the handles in the kernel object handle table be destroyed? Combine the reference count to talk about your understanding of the problem.

A: Each kernel object has a reference count , you can think that each kernel object structure has a field called reference count, when a process created or opened this kernel object, the kernel object reference count from 1, the process terminates or closes the handle, the reference count is reduced by 1, When the reference count is reduced to 0 , the kernel object is automatically destroyed. Therefore, when a kernel object m is created in process a, another process object uses this kernel object, and when process a exits, M is not destroyed, because he is also used in process B, and only if no process uses this kernel object, the kernel object is automatically destroyed.

4. Please talk about the way you know the communication between processes, the more detailed the better.

A.wm_copydata message
The WM_COPYDATA message is a message that is dedicated to data transfer and can carry a large volume of message parameters. However, wm_copydata data will be sent to the target process stack space to save, so the data sent in a single time should not be too large .
B. Postal Slots
Mail slots are one of the simplest forms of interprocess communication in Windows, where a process can create a mail slot, and other processes can communicate with the process of creating a mail slot by opening the mail slot. Mail slot communication when the one-way, the server can only read messages, the client can only write messages, messages are written to the slot in the form of a queue to save.

Windows common face question--process, thread

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.