Shared Memory in Windows NT

Source: Internet
Author: User
Shared Memory in Windows NT

Both code and data are treated the same way in Windows NT-both are represented by pages of memory and both have their pages backed by a file on disk. the only real difference is the file by which they are backed-code by the executable image and data by the system pagefile. because of this, memory-mapped files are also able to provide a mechanism for sharing data between processes. by extending the memory-mapped file capability to include portions of the system pagefile, applications are able to share data that is backed by the pagefile. shown in figure 3, each application simply maps a view of the same portion of the pagefile, making the same pages of memory available to each application.

Figure 3. processes share memory by mapping independent views of a common region in the system pagefile.

Windows NT's tight security system prevents processes from directly sharing information among each other, But mmfs provide a mechanic that works with the security system. in order for one process to share data with another via mmfs, each process must have common access to the file. this is achieved by giving the MMF object a name that both processes use to open the file.

Internally, a shared section of the pagefile translates into pages of memory that are addressable by more than one process. to do this, Windows NT uses an internal resource called a prototype page-table entry (PPTE ). pptes enable more than one process to address the same physical page of memory. a ppte is a system resource, so their availability and security is controlled by the system alone. this way processes can share data and still exist on a secure operating system. figure 4 indicates how pptes are used in Windows NT's virtual addressing scheme.

Figure 4. Prototype page-table entries are the mechanisms that permits pages of memory to be shared among processes.

One of the best ways to use an MMF for sharing data is to use it in a DLL (Dynamic-link library ). the porttool application serves as a useful authentication. porttool uses a DLL to provide its porting functionality and relies on the main application for the user interface. the reason for this is simple: Other applications can then also use the DLL functionality. that is, other editors that are programmable can import the porting functionality. because it is entirely feasible for porttool to be running while another editor that imports the porttool DLL is also running, it is best to economy Mize system resources as much as possible between the applications. porttool does this by using an MMF for sharing the porting information with both processes. otherwise, both applications wocould be required to load their own set of porting information while running at the same time, a waste of system resources. the porttool Code demonstrates sharing memory via an MMF in a DLL.

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.