Windows virtual Memory (Win32)

Source: Internet
Author: User

Windows is a virtual memory-based operating system. In this system environment, the Windows Memory manager often moves objects back and forth in memory,
Meet the memory needs of a variety of applications. The object being moved means that its address has changed. If the address always changes so, where should we go to find the object?

To solve this problem, the Windows operating system frees up some memory storage addresses for each application to specifically register the address changes in memory of an application (
So the handle is the address that points to the address. The handle records the address that the object in the memory manager is constantly adapting to. So we just need to remember this handle address
You can briefly know where the object is in memory. This address is assigned to the system when the object is loaded (load) and released when the system is unloaded
System.

Handle address (Stable)---> records the address of the object in memory---> The address of the object in memory (unstable)---> Actual object

Essence: Windows programs do not use physical addresses to identify a block of memory, files, tasks or dynamically loaded modules, instead, Windows API gives these items
Assigns a handle to the determination and returns it to the application and then operates through the handle.

However, it is important to note that each time the program is restarted, the system cannot guarantee that the handle assigned to the program is the same as the original handle, and most of the cases
Not the same, this and every time the cinema sells to our tickets is different seat is the same reason.

Processes are often defined as the execution of a program. You can think of a process as a separate program that has complete data space and code space in memory. A process
The data and variables that are owned belong to itself only.

A thread is a program that runs alone in a process. That is, the thread exists in the process. A process consists of one or more threads, each thread sharing
The same code and global data, but each has its own stack. Because each thread in the stack is one, local variables are private to each county. Due to the
Wired threads share the same system area, and the resources assigned to a process by the operating system are available to all threads of the process, just as global data is available to all threads
Use the same.

In short, a program has at least one process, and a process has at least one thread. Threads are less divided than processes, which makes multi-threaded routines more concurrent. Other
, the process has an independent memory unit during execution, and multiple threads share memory, which greatly improves the efficiency of the program operation. The thread is in the process of executing
is different from the process. Each separate thread has a program run entry, sequence of sequence execution, and exit of the program.

However, threads cannot be executed independently, and must be dependent on the application, which provides multiple threads of execution control. From a logical point of view, the meaning of multithreading
In an application, there are multiple execution parts that can be executed at the same time. However, the operating system does not consider multiple threads as separate applications to implement process scheduling
and management, and resource allocation, which are important differences between processes and threads.

One thread can create and revoke another thread, which can be executed concurrently between multiple threads in the same process.

The main difference between a process and a thread is that they are different ways to manage the operating system resources. The process has a separate address space, and after a process crashes, in protected mode
Does not affect other processes, and threads are just a different execution path in a process.

Threads have their own stacks and local variables, but there is no separate address space between the threads, and a thread that dies equals the entire process dies, so the multi-process program is going to
More robust than multithreaded programs, but in the process of switching, the cost of large resources, the efficiency is worse. But for some that require simultaneous and have to share certain variables
Concurrent operations, which can only be used by threads, cannot be used by processes.


In a micro-kernel-based operating system such as Mac, Windows NT, the functionality of the process has changed: he is just a unit of resource allocation, not a scheduled run
The unit. In a microkernel system, the basic unit of a real dispatch operation is a thread. Therefore, the unit that implements the concurrency feature is the thread.

A thread is the smallest unit of execution in a process, that is, the basic unit of a processing schedule. If the process is understood as a task performed by a logical operating system, it
A thread represents one of many possible subtasks that complete the task.

Windows virtual Memory (Win32)

Related Article

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.