Internet Windows Android

Windows 7 page error memory. What do page failure errors say in memory

Memory allocation in Windows 9x and in Windows NT. Windows 7 Resource Monitor. Explore memory-related items and tabs. Using the Windows 7 Resource Monitor to monitor memory allocation. Increasing the size of the paging file (virtual memory). Checking memory using Windows.

3.1. Memory allocation in Windows 9x

Windows 9x is a 32-bit multi-threaded OS with preemptive multitasking and a graphical user interface. For their boot, they use MS-DOS 7.0, which provides two modes of processor operation - real (in the MSDOS.SYS file, BootGUI=0 is written in the section) and protected (BootGUI=1). Protected mode is set just before Windows 9x boots, causing the processor to manage memory using the virtual-to-physical address paging mechanism. The area of ​​the virtual address space consists of 4 kilobyte pages, which are placed in RAM or on disk.

The lower addresses of the virtual address space are shared by all processes to ensure compatibility with real-time device drivers, Windows resident programs, etc. On the one hand, this is convenient, but, on the other hand, reduces reliability (one of the main qualities of the OS), because any process can corrupt the components located at these addresses.

Each 32-bit Windows application program runs in its own address space, however, access to the desired addresses is possible, i.e. the organization of virtual addresses does not use all the hardware protections built into the microprocessor. 16-bit programs share a common address space and are also vulnerable to each other. The Windows 9x memory model is shown in Figure 3.1.

Rice. 3.1. OP distributions in Windows 9x

The bottom 64 KB of RAM is inaccessible to 32-bit programs, but 16-bit programs can write their data here. Addresses below 4 MB are mapped to the address space of each application and are shared by all processes. This makes this area unprotected from accidental writing.

The minimum required amount of memory for the operation of Windows 9x is 4 MB, but in practice it is impossible to work with this amount of memory. page file , which implements the virtual memory mechanism, is located in the Windows directory and has a variable size, changed if necessary by the system itself. Its dimensions can be set using system tools (Control Panel → System → Performance → File system), or set in the section of the SYSTEM.INI file - a line indicating the drive and file name:

Pagingfive=c:\PageFile.sys

MinPagingFileSize=65536 (64 MB)

MaxPagingFileSize=262144 (256 MB)

The first and second lines define the file name and its location, and the last two - the initial and limit size of the page file in KB.

You can obtain the minimum paging file size by running SysMon (system monitor) and selecting the paging file size and free memory as required parameters to estimate the memory requirements of the most commonly used applications.

3.2. Memory allocation in Windows NT

The differences between the distribution scheme and Windows 9x are as follows:

1) more serious use of memory protection hardware provided in the microprocessor;

2) all system program modules are located in their own virtual address spaces and application programs cannot access them.

The allocation of address space in Windows NT is shown in Figure 1. 3.2.

Rice. 3.2. OP distributions in Windows NT

Application programs are allocated 2 GB of local (native) linear (unstructured) address space (the first 64 KB are inaccessible). They are isolated from each other and can communicate with each other only through the clipboard (clipboard), or through the DDE (Dynamic Data Exchange - dynamic data exchange) and OLE (Object Linking and Embedding) mechanisms.

At the top of the 2 GB area is the code for system DLLs (dynamically linked libraries) that act as server processes. They check the values ​​of query parameters, execute the requested function, and send the results back to the address space of the calling program.

In the 2-4 GB address range, there are system (low-level) Windows components (ie the highest level of protection against unauthorized access: kernel, thread scheduler, memory manager).

For 16-bit Windows application programs, WOW (Windows On Windows) sessions are implemented in preemptive multitasking mode individually in their own address spaces or jointly in a shared address space.

When the application is launched, a process is created with its own information structure, within which the task is launched. It can run other tasks. As a result, a multitasking mode of operation is organized.

Memory management (allocation, reservation, deallocation, paging) is performed by the Virtual Memory Manager (VMM). Each virtual page is transferred to a physical page - a page frame (page frame), filled in the initial state with zeros (this is the main requirement of the standard for C2 security systems, which determines the impossibility of using their previous contents by other processes). The space for page unloading is reserved in the page file Pagefile.sys, which is a reserved block of disk space.

All Windows NT memory is subdivided into reserved(for dynamic use by processes when executing tasks), dedicated(for unloading which is reserved in Pagefile.sys) and available(the rest of the free memory).

      Virtual Memory in Windows

The most common reason for slowing down a Windows-based system is filling up physical memory. At the same time, Windows begins the so-called "paging" (paging) - moving blocks of code and program data (each such block is called a page - page) from physical memory to the hard disk. Accessing the paging file from time to time is normal and does not degrade system performance, but frequent requests for data from a file on disk can significantly slow down the overall speed of the system. This issue becomes especially noticeable when switching between multiple memory-intensive programs on a computer that doesn't have enough physical memory. As a result, the disk is almost constantly in use, because the system is trying to "pump" data from it to memory and back.

If the total amount of allocated memory exceeds the total amount of physical memory, Windows has to "pump" pages between fast RAM and much slower virtual memory in the pagefile, slowing the system down.

During the installation of Windows XP, a swap file is automatically created in the root folder on the same drive where the Windows system files are located. The paging file size is determined based on the amount of physical memory in the system. By default, the minimum page file size is 1.5 times the amount of physical memory and the maximum size is 3 times the size. The paging file can be seen in the Explorer window if you turn on the display mode of hidden and system files (Fig. 3.3).

Rice. 3.3. Enabling the display of hidden and system files

Usually, the Windows operating system itself sets the optimal amount of virtual memory and it is enough for most tasks, but if the computer is running applications that require a lot of memory, then the amount of virtual memory can be changed.

To do this, perform the following sequence of actions:

1. Log in with an account from the Administrators group and open the "Control Panel - System" window.

2. On the "Advanced" tab, click the "Settings" button in the "Performance" section (Fig. 3.4).

3. In the "Performance Options" dialog box, select the "Advanced" tab and click the "Change" button (Fig. 3.5) to display the "Virtual Memory" dialog box, as shown in Fig. 3.5. 3.6 for Windows XP and in fig. 3.7 for Windows7.

The current paging file settings are reflected in the "Total paging file size across all drives" field.

4. Select any drive from the list at the top of the dialog box to configure the settings for that drive.

You can change the following options:

- Special size. Enter a value in the field original size to set the initial size of the pagefile.sys file on the specified drive (in megabytes). In field Maximum size enter a number not less than the value in the field original size, but not exceeding 4096 MB (4 GB).

- Size at the choice of the system. Select this item to enable dynamic paging file size management for this drive. Select this option if you do not want to change the default settings offered by Windows.

- No swap file. Use for all drives where you don't need a swap file. Make sure the swap file is on at least one drive.

5. After making any changes, click Ask to record changes.

6. Repeat steps 4 and 5 for other drives (if necessary). Click OK to close the dialog box when you're done with it.

Rice. 3.4. "Options" button to go to view and/or

changing virtual memory settings

Rice. 3.5. "Change" button to go to changing virtual memory settings in Windows XP (left) and in Windows 7

Rice. 3.6. View window and settings for virtual memory size

Rice. 3.7. Window for viewing and setting the size of virtual memory in Windows7

If your computer has more than one physical drive, it is best to place the paging file on the fastest, and it is preferable if the Windows system files are located on a different drive. It is even better to split the swap file into several physical disks because the disk controller can handle multiple write and read requests in parallel.

Do not try to place the paging file on several logical drives of one physical drive!!!

If the system has one hard drive partitioned into partitions C, D, and E, and the page file is divided into several partitions, then the system may even slow down, because in such a configuration, the magnetic heads of the hard disk have to read data from several areas, and not sequentially from one area of ​​the disk.

If you decrease the minimum or maximum page file size and create a new page file on disk, the system must be rebooted for the changes to take effect. Increasing the page file size usually does not require a computer restart.

If you have a lot of physical memory, you may be tempted to disable the swap file altogether. Do not do that! !!

Windows XP was designed so that the paging file is used to perform some kernel tasks, so some third-party programs may report an out-of-memory message when attempting to completely disable virtual memory.

Windows does not use the swap file until it is needed, so disabling virtual memory will not improve performance!!!

Windows can dynamically increase the size of the paging file as needed. This function only works when you select " System selectable size”, as well as when setting a maximum size greater than the current size of the paging file.

Based on experience with previous versions of Windows, some users try to create a fixed size paging file with equal initial and maximum sizes. Theoretically, this should improve performance, as it eliminates the possibility of page file fragmentation. However, the swap subsystem is designed in such a way that, in practice, a file only occupies large blocks of disk space, which keeps fragmentation to a minimum. You may notice a slight drop in performance when Windows increases the size of the paging file, but this is a one-time operation and does not affect average performance in any way.

      Controlling memory usage in Windows

The easiest way to find out how much RAM is being used at a given time is to open the Task Manager by pressing ++ and go to the Performance tab (Fig. 3.8). A detailed description of the information on the "Performance" tab for Windows XP is presented in Table. 3.1.

Table 3.1. Decrypting Task Manager Data

The "Performance" tab for Windows7 has significant innovations compared to the corresponding tab Task Manager in Windows XP.

The number in the "Total" column of the "Physical Memory" section indicates the total amount of RAM for this system. The Cached column shows the amount of physical memory that was recently used by system resources. It remains in the cache in case the system needs it again, but is available to other processes. The new column "Available" (Available) indicates the amount of currently unused physical memory, and in the column "Free" (Free) - the amount of memory that is used by the cache, but does not contain useful information.

The Kernel Memory section contains two columns - Paged and Nonpaged. Together they indicate how much memory the kernel is using. Paged is virtual memory, and nonpaged is physical.

In the "System" (System) column appeared "Descriptors" (Handles) and "Threads" (Threads), associated with the composite components of processes. The "Descriptors" column indicates the number of object identifiers (handles) that are used by currently running processes. The "Threads" column shows the number of subprocesses running within larger processes. The number in the "Processes" column, of course, indicates the total number of running processes, which can be seen on the "Processes" tab.

The Up Time column shows how much time has passed since the computer was last started. The Commit column contains information about the paging file. The first number indicates the total amount of physical and virtual memory currently in use, and the second number indicates the total amount of memory for this computer in general.

Even more detailed information can be obtained by clicking the "Resource Monitor" button and selecting the "Memory" tab (Fig. 3.9).

Rice. 3.9. Memory tab of the Windows Resource Monitor window

The "Memory" tab has a "Processes" table that lists all running processes, and information about the memory used for each process is divided into several categories (Fig. 3.10).

Rice. 3.10. Table "Processes"

In a collumn " Image» indicates the name of the process executable file. The processes started by applications are very easy to recognize - for example, the "Winword.exe" process obviously belongs to the Word text editor. Processes named "svchost.exe" represent various operating system services. The name of the service is given in parentheses next to the process name.

In a collumn " Process ID» indicates the process number - a unique combination of numbers that allows you to identify the running process.

In the column " Completed» indicates the amount of virtual memory in kilobytes reserved by the system for this process. This includes both the physical memory used and the pages stored in the paging file.

In the column " Working set» indicates the amount of physical memory in kilobytes currently used by the process. The working set is made up of shared and private memory.

In a collumn " General» specifies the amount of physical memory, in kilobytes, that this process is sharing with others. Using a single memory segment or swap page for related processes saves memory space. In this case, only one copy of the page is physically stored, which is then mapped to the virtual address space of other processes that access it. For example, all processes initiated by the system DLLs - Ntdll, Kernel32, Gdi32, and User32 - use shared memory.

In the column " Private» indicates the amount of physical memory in kilobytes used exclusively by this process. It is this value that allows you to determine how much memory a particular application needs to work.

In the column " Page Out of Memory Errors/sec.' shows the average number of out of memory page faults per second over the last minute. If a process tries to use more physical memory than is currently available, the system writes some of the data from memory to disk - the paging file. The subsequent access to the data saved to disk is called a page out of memory error.

As applications start and work with files, the memory manager keeps track of the working set size for each process and captures requests for additional memory resources. As a process's working set increases, the dispatcher matches these requests to the needs of the kernel and other processes. If there is not enough available address space, the dispatcher shrinks the working set by saving data from memory to disk.

Later, when reading this data from disk, a page out of memory error occurs. This is quite normal, but if errors occur simultaneously for different processes, the system needs additional time to read data from disk. Too frequent page out of memory errors, respectively, reduce system performance. This manifests itself in an unexpected slowdown in all applications, which then also stops unexpectedly. The slowdown is due to the active redistribution of data between physical memory and paging.

This leads to the conclusion that if out-of-memory errors for a particular process occur too often and regularly, the computer does not have enough physical memory.

To make it easier to monitor processes that cause frequent page out of memory errors, you can mark them with flags. This will move the selected processes to the top of the list, and the page out of memory error graph will be represented by an orange curve.

Keep in mind that memory allocation depends on a number of other factors, and monitoring out-of-page errors is not the best or the only way to identify problems. However, it can serve as a good starting point for observation.

The Processes table provides detailed information about the allocation of memory between individual processes, while the Physical Memory table gives an overall picture of RAM usage. Its key component is the unique histogram shown in Fig. 3.11.


Figure 3.11. The bar graph in the Physical Memory table gives you a general idea of ​​memory allocation in Windows 7

Each section of the histogram is marked with its own color and represents a specific group of memory pages. As the system is used, the memory manager moves data between these groups in the background, maintaining a delicate balance between physical and virtual memory to keep all applications running efficiently. Let's take a closer look at the histogram.

On the left is the section Reserved Equipment”, marked in gray: this is the memory allocated for the needs of the connected equipment, which it uses to interact with the operating system. Memory reserved for hardware is locked and cannot be accessed by the memory manager. Usually, the amount of memory allocated to the hardware is between 10 and 70 MB, but this figure depends on the specific configuration of the system and in some cases can reach several hundred megabytes.

Components that affect the amount of reserved memory include:

Motherboard components - such as the Advanced Programmable Input/Output Interrupt Controller (APIC);

Sound cards and other devices that perform memory-mapped input/output;

PCI Express (PCIe) bus;

Video cards;

Various chipsets;

Flash drives.

Section " used”, marked in green, represents the amount of memory used by the system, drivers, and running processes. The amount of memory used is calculated as the value of " Total» minus the sum of indicators « Changed», « Expectation" And " Free". In turn, the value Total" is an indicator of " Installed» minus the indicator « Reserved Equipment».

You have connected a new device, but it is in no hurry to work, or the old device has stopped functioning, or does not work correctly. What to do in these cases? Reinstall everything? It's a hassle, and it's not always necessary. How to find out what is the reason and how to eliminate it? Very simple. The fact is that in the operating system of the Windows family, and not only, there is, someDevice Manager, in fact, a very necessary and useful manager, if you can call him that. Here it is, it will help us find out what is the cause of the problem, and my cheat sheet will fix the problem. So, in the aboveDevice Manager there are traces of errors in the operation of devices in the form of codes. Knowing the error code, it is easy to determine the cause of the problem. For the uninitiated, the codes are just incomprehensible and meaningless numbers. But to a knowledgeable user, they can tell a lot. I will try my best to shed some light on this subject.


To view device errors, we first need to enter the Device Manager itself. It is done like this. Sign inControl Panel from the menuStart ( can,My a computer , right-clickProperties Device Manager, and it is also possible through the task of the command inexecute , but why complicate things). If we enter throughPanel management , then the path is:System - Hardware - Device Manager . Choose by entering the menuDevice Manager , the type of device we are interested in (keyboard, printer, modem, etc.), double-click on it, as a result we will see the devices included in this type. Select the device we need and double-click on it. We look at the column on the About tabgeneral, device status. If there is a problem with the operation of the device, it will be displayed here as an error code. So we see numbers and numbers. What do they stand for. Below I provide a complete list of errors, with a brief description of the error and possible solutions. The error code is highlighted in red, its description in blue and the elimination in black.

Code 1There is a problem with the device setup, the settings are not correct or the driver is missing. Click the button Update Driver , to start the wizardHardware upgrade . If there is no driver at all, install it.

Code 3The device driver is damaged, as an option there is not enough RAM for the device to work correctly.1. Remove the damaged driver and install a new one. To do this: Properties - Driver - Delete, then follow the instructions of the wizard. Reboot. We open againDevice Manager Action Update hardware configuration and follow the instructions of the wizard. 2. If the problem is lack of virtual memory, close running applications to unload memory. To check the state of the memory we need to get intoTask Manager , to do this, press the key combinationCtrl+Shift+Esc.We can see the virtual memory settings by right-clickingMy computer Properties - Advanced - Performance - Settings (Parameters) . You can try to increase the swap file (I described how this is done in one of the previous articles on my blog), but this is far from a drastic measure. You will have to increase the RAM. How this is done is a separate topic that goes beyond the scope of this post.

Code 10The registry key has a device-specific settingFailReasonString,the value of this parameter is displayed in the error data, that is, if there is no parameter as such, then an error code appears, in other words, the device cannot be started. Update the driver as above. Or install a newer one.

Code 12There is no stock of resources required for this device. Disable other running devices, at least one, to do this, use the troubleshooting wizard, which, if you follow its instructions, will disable the conflicting device. (In short, let me remind you: Properties - General - Troubleshooting.)

Code 14Requires a PC restart for this device to work.

Code 16It is not possible to identify the resources that are necessary for the operation of the device, the device is not fully configured. You need to assign additional resources to the device. But this can be done without problems if the device belongs toPlug and play.

Properties - Resources. If there is a resource with the ? sign in the list of resources, select it to assign it to the selected device. If the resource cannot be changed, clickChange settings , if this function is not available, uncheck the boxAutomatic setting

Code 18Reinstall the device driver. We try to update the driver or remove it and do it, as in the example withcode 3.

Code 19Insufficient information in the registry about the device settings, or the settings are corrupted. RunTroubleshooting Wizard and follow his instructions, it will not help - reinstall the device, as mentioned above. (code 3). Or, if that doesn't work, downloadLast Known Good Configuration. If this does not help, you need the help of a specialist, as it is necessary to edit the system registry. Lacking knowledge and experience, on your own, there is nothing for you to do there, any system administrator will confirm this for you. Knowing and able, he knows how to do it, without me. And for the inexperienced, it's better not to try. The registry is the heart of the operating system and only an experienced specialist, or under his guidance, should carry out operations on it. In no way do I want to offend anyone, but if you have not worked with the system registry and if your computer is dear to you, my advice is to forget your way there. I do not write for professionals, they do not need it, but for the average user. Of course, I can write how and what to do there, but this will be an explanation on the fingers, and if you, as a result of the slightest mistake, damage your computer, I will be to blame. I don't need it at all, and neither do you.

Code 21 The device is removed from the system, that is, the operating system is trying to remove the device, but the process has not yet completed.


Pause for a few seconds and press the key


Code 22 The device is disabled. The device must be turned on.Action - Enable and follow further instructions.


Code 24 The device is missing or incorrectly installed, the driver has failed, the device may have been prepared for removal. Remove the device and reinstall.


Code 28 There is no driver. Install the driver. To do this, you need to Update the driver, the steps are as in the instructions for Code 1.


Code 29Disabled device . You need to allow the device to work in settingsBIOS,read the instructions for using the device.


Code 31The system was unable to load drivers for this device. . Update your drivers as described above.


Code 32The driver for this device is disabled in the system registry . Uninstall and reinstall the driver (described above)


Code 33The operating system cannot determine the resources for this devices . Set up the device or replace it.


Code 34The operating system cannot determine the settings devices . Review the hardware documentation that came with it and manually configure it on the Resources tab.


Code 35The PC firmware does not have the necessary information to properly device operation . Need to updateBIOS.For instructions on how to do this, contact the supplier, but it is better to use the services of an experienced craftsman.


Code 36The device requires an interrupt to operate.PCI,and the device is set to interruptisa,or vice versa . Need to change settingsBIOS,refer to an experienced master.


Code 37The operating system does not recognize the driver for this device. . Reinstall the driver (described above).


Code 38The OS cannot load the driver for the device because, the previous version of the driver remains in memory . You need to restart your PC. Run the Troubleshooting Wizard if it does not start (Properties - General - Troubleshooting) and follow the instructions of the wizard. After a mandatory reboot.


Code 39The OS cannot load the device driver. Driver is corrupted or not at all . Reinstall the driver as described above.


Code 40There is no access to the equipment, as there is no information in the system registry or the information contains an error . Reinstall the driver.


Code 41Device not detected . Run the Troubleshooting Wizard (described above), if it does not help, update the hardware configuration (see above) or update the driver. If not, please install a newer version of the driver.


Code 42The system already has such a driver. That is, there are two different devices with the same name, possibly due to an error . Restart your PC.


Code 43Stopping the device due to problems in its operation . Run the Troubleshooting Wizard and follow its instructions.


Code 44An app or service has stopped the device . Restart your PC.


Code 45Device not connected . Connect your device.


Code 46This error appears when the operating system shuts down. Nothing needs to be done, the next time you start the OS everything will work.


Code 47 The device has been prepared for secure removal but has not yet been removed (e.g. flash) . Remove the device, then plug it back in, restart your PC.


Code 48The device, or rather its software, is blocked . Update the driver or install a new one.


Code 49The device cannot be started because it has a large system registry hive that exceeds the allowable registry settings . Delete devices that are not in use from the registry. You can do this: Device Manager - View - Show hidden devices. Here you will see hidden devices that are not connected to your PC. Select the devices you want to remove, click Properties for the device - Driver - Uninstall, then follow the instructions of the wizard and finally restart the PC.


Manual for removing any viruses from your PC with your own hands. All virus removal methods that really work and are proven in practice, step-by-step instructions with illustrations - simple and accessible even for a schoolchild + video tutorials + ultraiso program to create bootloaders + useful links to tools in the fight against viruses. Download archive

When a process starts in Windows, many of the pages that display EXE and DLL file images may already be in memory because they are being used by other processes. Writable image pages are labeled "copy-on-write" so they can be shared until they need to be modified. If the operating system recognizes an EXE that was already running, it can write the page link pattern (using a technique that Microsoft calls Super-Fetch). This technology tries to prefetch many necessary pages in advance (although the process has not yet received page faults on them). This reduces the latency of launching applications (reading pages from disk is superimposed on the execution of the initialization code of images). This technology improves disk output performance by making it easier for disk drivers to orchestrate read operations (to reduce the required seek time). This prefetching process is used during system boot as well as when a background application comes to the foreground and when the system resumes from hibernation.

Forward paging is supported by the memory manager, but is implemented as a separate system component. Swapped pages are not inserted into the process's page table, instead they are inserted into a standby list, from which they can be quickly inserted into the process (without disk access).

Unmapped pages are somewhat different - they are not initialized by reading from a file. Instead, the first time an unmapped page is accessed, the memory manager provides a new physical page (making sure its contents are zero-filled, for security reasons). On subsequent page faults, the unmapped page may need to be found in memory or read from the swap file.

Demand paging in the memory manager is controlled by page faults. Every error causes an interrupt to the kernel. The kernel then builds a machine-independent handle (which reports what happened) and passes it to the runtime memory manager. The memory manager then checks the access for validity. If the failed page falls within the committed area, then it looks up the address in the VAD list and finds (or creates) the process's page table entry. In the case of a shared page, the memory manager uses the prototype page table entry (associated with the segment object) to populate the new process page table entry.

The page table entry format differs depending on the processor architecture. For x86 and x64 processors, the elements of the displayed page are shown in fig. 11.17. If an element is marked as valid, then its content is interpreted by the hardware (so that the virtual address can be translated into a valid physical page). Unrendered pages also have their own elements, but they are marked as invalid and the hardware ignores the rest of the element. The software format is somewhat different from the hardware format and is determined by the memory manager. For example, for an unmapped page (which must be laid out and zeroed before being used), this fact is noted in the page table entry.


Two important bits of the page table entry are updated directly by the hardware. These are the access bit (A) and the changed bit (D). These bits keep track of the use of a given page mapping to access the page, and whether the page can be modified by that access. This really improves system performance because the memory manager can use the access bit to implement Least-Recently Used (LRU) paging. The principle of LRU is that those pages that have not been used the longest have the least chance of being reused in the near future. The access bit allows the memory manager to determine that the page has been accessed. The "modified" bit tells the memory manager that the page may have been modified (or, more importantly, it has not been modified). If the page has not been modified since it was read from disk, then the memory manager does not need to write its contents to disk (before using it for something else).

Both the x86 and x64 architectures use a 64-bit page table entry (see Figure 11.17).

Each page fault can be classified into one of five categories:

1. The page is not fixed.

2. Attempt to access a page with permission violation.

3. Attempt to modify a copy-on-write page.

1. Need to increase the stack.

2. The page is fixed but not currently displayed.

The first and second cases are programming errors. If a program tries to use an address that does not have a valid mapping, or tries to perform an illegal operation (such as trying to write to a read-only page), this is called an access violation and usually results in the termination of the process. An access violation is often the result of invalid pointer values, including access to memory that has been freed and detached from the process.

The third case has the same symptoms as the second (an attempt to write to a read-only page), but its handling is different. Because the page was marked copy-on-write, the memory manager does not throw an access violation. Instead, it makes a private copy of the page for the current process, and then returns to the thread that attempted to write to the page. The thread retries the write operation, which will now complete without a page fault.

The fourth case occurs when a thread pushes a value onto its stack and hits a page that hasn't been allocated yet. The memory manager recognizes this as a special case. As long as there is room in the virtual pages reserved for the stack, the memory manager will supply new pages, zero them out, and map them to the process. When the thread resumes execution, it will retry the access, and this time it will succeed.

And finally, the fifth case is a normal page fault. However, it has several sub-variants. If a page is mapped to a file, then the memory manager must examine its data structures (such as the prototype page table associated with the segment object) to ensure that there is no copy of it in memory. If there is a copy (for example, in another process, in a standby list, or in a list of modified pages), then it will simply make it shared (it may have to mark it as copy-on-write to do this if the changes are not shared). supposed). If there is no copy yet, then the memory manager will allocate a free physical page and prepare it for copying a page of the file from disk into it, unless another page is being transferred from disk at that moment (in which case you just need to wait until this transfer is completed).

If the memory manager can handle a page fault by finding the correct page in memory (rather than reading it from disk), then the error is called a soft fault. If you need a copy from disk, then this is a hard fault. Soft bugs are much cheaper and have little impact on application performance (compared to hard bugs). Soft errors can occur because the shared page has already been mapped to another process, or simply a new zeroed page is needed, or the desired page has been removed from the process's working set but is reclaimed before being reused. Soft errors can also occur because pages have been compressed to effectively increase the size of physical memory. For most CPU configurations, it is more efficient to compress memory and I/O in current systems, rather than wasting expensive I/O (in terms of performance and power) that requires reading a page from disk.

When a physical page is no longer mapped to any process's page table, it is placed on one of three lists: free, modified, or reserved. Those pages that are never needed again (such as the stack pages of a terminating process) are freed immediately. Those pages that can page fault again are either in the modified list or in the reserve list (depending on whether the "modified" bit was set for any page table element that displayed this page since it was last read from disk). Pages from the modified list will eventually be written to disk and then moved to the reserve list.

The memory manager can allocate pages as needed (using a list of either free or reserved pages). Before allocating a page and copying it from disk, the memory manager always checks the lists of reserved and modified pages to see if the page is already in memory. The Windows paging scheme converts future hard errors into soft ones (by reading pages that might be needed and putting them on the fallback list). The memory manager does a small amount of paging itself - it accesses groups of consecutive pages (rather than individual pages). Additional pages are immediately placed on the reserve page list. This is not a waste, since the overhead of the memory manager is much less than the cost of performing I/O operations. Reading a whole cluster of pages is slightly more expensive than reading a single page.

Page table elements in fig. 11.17 refer to physical (not virtual) page numbers. The kernel needs to use virtual addresses to update the page table entry (and page directory). Windows maps the page tables and page directories for the current process to the kernel's virtual address space using the self-map element in the page directory (Figure 11-18). By mapping a page directory entry to a page directory (self-map), we obtain virtual addresses that can be used to refer to page directory entries (Figure 11.18a) and page table entries (Figure 11.18b). The self-map takes up 8 MB of kernel virtual addresses per process (on x86 processors). For simplicity, the figure shows the x86 self-map element for 32-bit PTE records (Page-Table Entries). In fact, Windows uses 64-bit PTEs, so the system can use more than 4 GB of physical memory. With 32-bit PTE entries, the self-map element uses only one PDE entry (Page-Directory Entry) in the page directory and therefore takes up only 4 MB of addresses, not 8 MB.

Preemptive/nonpreemptive algorithms.

In the case of a preemptive algorithm, the operating system can at any time interrupt the execution of the current thread and switch the processor to another thread. In non-preemptive algorithms, the thread given the processor decides when to hand over control to the operating system.

Algorithms with quantization.

Each thread is given a time slice during which the thread can run on the processor. When the quantum expires, the operating system switches the processor to the next thread in the queue. The quantum is usually equal to an integer number of intervals of the system timer 1 .

Algorithms with priorities.

Each thread is assigned a priority (priority) - an integer indicating the degree of privilege of the thread. The operating system, if there are several threads ready to execute, selects the thread with the highest priority among them.

Windows implements a mixed scheduling algorithm - preemptive, based on quantization and priorities.

  1. Multitasking type for DOS application
  2. Service Guarantees
  3. Scheduling foreground processes
  4. Purpose of the swap file
  5. Processes P1, P2, P3 allocate 100, 20, 80 MB of memory. The system has 128MB of OP. What is the amount of used memory in the swap file. What is the size of the swap file.
  1. What is a "page fault"?

Interrupt 14 -page fault (#PF): Intel386 ...

It is generated if the paging mechanism is activated (CR0.PG = 1) and one of the following situations occurs when translating a linear address into a physical one:

  • element of the page table or page catalog used in address translation, has zero presence bit, i.e. the desired page table or page is not present in physical memory;
  • procedure does not have privilege level, sufficient to access the selected page, or attempts to write to a page that is write-protected for the current privilege level.

The page fault handler obtains information about its cause from two sources: the error code pushed onto the stack, and the contents of CR2, which contains the linear address that caused the error. The page error code has a special format (Fig. 3.7.).

An interrupted program, after eliminating the causes that caused the page fault (for example, a page load in physical memory), can be continued without any additional adjustments.

If a page fault was caused due to a violation of page security privileges, then the access bit (A) in the corresponding page directory entry is set. The behavior of the access bit in the corresponding page table entry for this case is not regulated in Intel processors and may be different in different models.

  1. A high page fault rate indicates:

Unreliability of the program

Unreliability of RAM

Other: explain

Column "Errors of the absence of a page in memory / sec."

In the column "Page out of memory errors / sec." (Hard Faults/sec) indicates the average number of memory page faults per second over the last minute. If a process tries to use more physical memory than is currently available, the system writes some of the data from memory to disk - the paging file. The subsequent access to the data saved to disk is called a page out of memory error.

What do page out errors indicate?

Now that you have an idea of ​​what information is collected in the Processes table, let's see how to use it to monitor memory allocation. As applications start and work with files, the memory manager keeps track of the working set size for each process and captures requests for additional memory resources. As a process's working set increases, the dispatcher matches these requests to the needs of the kernel and other processes. If there is not enough available address space, the dispatcher shrinks the working set by saving data from memory to disk.

Later, when reading this data from disk, a page out of memory error occurs. This is quite normal, but if errors occur simultaneously for different processes, the system needs additional time to read data from disk. Too frequent page out of memory errors, respectively, reduce system performance.. You have probably experienced an unexpected slowdown in all applications, which then also suddenly stopped. Almost certainly, this slowdown was due to the active reallocation of data between physical memory and swap.

The conclusion follows from this: if out-of-page errors for a particular process occur too often and moreover regularly, The computer does not have enough physical memory.

To make it easier to monitor processes that cause frequent page out of memory errors, you can mark them with flags. This will move the selected processes to the top of the list, and the page out of memory error graph will be represented by an orange curve.

Keep in mind that memory allocation depends on a number of other factors, and monitoring out-of-page errors is not the best or the only way to identify problems. However, it can serve as a good starting point for observation.

  1. How Thread Priority is Formed in Windows

Priorities

Windows implements preemptive priority scheduling, when each thread is assigned a certain numerical value - a priority, according to which a processor is allocated to it. Threads with the same priorities are scheduled according to the Round Robin algorithm (carousel). An important advantage of the system is the ability to preempt threads running in kernel mode - the code of the executive system is completely reentrant. Only threads holding the spinlock are not preempted (see "Thread Synchronization"). Therefore, spinlocks are used with great care and set to a minimum time.

The system has 32 priority levels. Sixteen priority values ​​(16-31) correspond to the real-time priority group, fifteen values ​​(1-15) are for normal threads, and a value of 0 is reserved for the system page-zeroing thread (see Figure 6.2).

Rice. 6.2. Thread Priorities

To relieve the user of the need to remember the numerical values ​​​​of priorities and be able to modify the scheduler, the developers introduced into the system priority abstraction layer. For example, the priority class for all threads of a particular process can be set using the set of constant parameters of the SetPriorityClass function, which can have the following values:

  • real time (REALTIME_PRIORITY_CLASS) - 24
  • high (HIGH_PRIORITY_CLASS) - 13
  • above normal (ABOVE_NORMAL_PRIORITY_CLASS) 10
  • normal (NORMAL_PRIORITY_CLASS) - 8
  • below normal (BELOW_NORMAL_PRIORITY_CLASS) - 6
  • and broken (IDLE_PRIORITY_CLASS) 4

The relative thread priority is set by the same parameters of the SetThreadPriority function:

The combination of six process priority classes and seven thread priority classes forms 42 possible combinations and allows forming the so-called basic thread priority.

The base priority of a process and the primary thread defaults to a value in the middle of the process priority ranges ( 24, 13, 10, 8, 6 or 4). Changing a process's priority changes the priorities of all of its threads, leaving their relative priorities unchanged.

Priorities 16 through 31 are not really real-time priorities, because under Windows' soft real-time support, no guarantees are made about the timing of threads. These are simply higher priorities that are reserved for system threads and those threads that are given such priority by a user with administrative rights. Nevertheless, the presence of real-time priorities, as well as the preemptibility of the kernel code, the localization of memory pages (see "Memory manager operation") and a number of additional features - all this allows you to run soft real-time applications, such as multimedia, in the Windows OS environment. The system thread with zero priority is engaged in zeroing memory pages. Regular user threads can have priorities from 1 to 15.


Similar information.


Many computing systems incorporate some form of memory manager (also known as a memory manager, MMU), with which a multitasking operating system allocates memory to each task and provides protection from user programs. For example, a typical problem occurs when an application program makes an error in computing an address, possibly using an index value that is too large or too small. If there is no protection in the system, this kind of error can change the codes included in the programs of the operating system, or modify the device tables, and even cause an unplanned start of the device with fatal consequences, such as an unauthorized write to the data file.

In addition to protecting the operating system from inadvertent destruction, the memory manager provides automatic program relocation. The memory manager converts the logical or program addresses of user programs into physical or hardware addresses. These addresses may be located in memory completely different from where logical addresses point. Address translation results in the complete removal of the operating system and protected I/O devices from the user's address space. Any attempt to read or write to memory outside the user's address space causes the processor to crash the user's program.

Information is usually transmitted in chunks consisting of a fixed number of bits; The 80386 MP uses chunks of 32 bits unless it is instructed to reduce chunk sizes to 16 bits. These portions are called words. The process of writing a word into a memory system is called memory entry, the process of getting a word from memory - reading from memory.

There are two memory access methods: random and sequential. Sequential access is used in those memory systems where the access to words is carried out in some predetermined order. Random access, on the other hand, implies the possibility of accessing the words of the storage system in any order and in approximately the same time.

No matter how perfect the memory is, when the signal passes between devices, there are delays in its propagation. Propagation delay is defined as the time required for a logic signal to travel through a device or a sequence of devices forming a logic chain. This delay also takes into account the signal passing through all interconnecting lines between microcircuits.

Direct Memory Access (DMA)

Direct memory access allows external devices and memory to directly exchange data without program intervention. DMA provides maximum I/O speed and maximum process parallelism. While interrupt I/O and software-controlled I/O transfer data through the processor, in the case of DMA, data is transferred directly between the I/O device and memory.

In order to minimize the number of data buses, special measures are taken to allow the use of a conventional backbone for RPS. These measures consist in the fact that the processor releases the highway, and the external device captures it and uses it to transfer data.

For the duration of the RAP, the execution of the program is usually suspended. The trunk is released as soon as the RAP request control line is excited. The processor terminates the current operation, releases the address and data lines, and asserts a signal on one of the control lines to prevent inadvertent decoding of undefined control signals.

The I/O interface transfers data directly to memory using a special register. When it needs to transfer data, the interface asks the processor for a memory cycle. Once acknowledged, the interface sends the data directly to memory while the processor pauses for one memory cycle. The logic that performs this transfer is called channel.

The channel contains a register for storing the address of the memory location to or from which data is being transferred. In most cases, the channel also includes a word counter to count the number of direct transfers made. In addition, the channel must contain a circuit that provides the exchange of control signals, synchronization and other auxiliary operations. On fig. 13.4 shows the logical connections between the CPU and the PDP controller.

RAP components. The main components of a DMA are a request trigger, an address register, a counter, and a data register that is used by the peripheral. Forwarding data over a DMA channel includes several steps: 1) initialization of the DMA logic to perform the DMA during repeated trunk occupation cycles; 2) asynchronous with respect to the program operations activation of the RAP; 3) notification of the end of transfers (on a signal from the counter or as a result of a change in the state of the device); 4) calling the "cleanup" program at the end of transfers; 5) completion of the DMA with the help of an interrupt handler, which returns control to the main program.

Block data transfer. The DMA procedure for high-speed devices uses data transfer in blocks. By executing the current program, the processor initiates the transfer of a block of data and determines the number of words that make up the block. However, the actual transmission of words is performed under the control of a separate device - the PMA controller. The maximum block transfer rate over the DMA channel is limited only by the duration of the memory cycle (read or write) and the speed of the DMA controller.

RAP with occupation of the memory cycle. The program initiates a block transfer by placing the start address in the address counter and the number of words in the word counter. and issuing a run command. This type of RAP is often referred to as RAP with occupying the memory cycle, because it pauses program execution for approximately one machine cycle each time.

When using DMA with a memory cycle, data transfer is carried out in parallel with other processes performed by the CPU. The sequence of actions here is the same as for the block transfer, with the exception that the DMA controller takes up memory cycles from the processor and, therefore, slows down its operation (block data transfer over the DMA channel also takes memory cycles, unless DMA is used on a separate bus).