This DPMI 0.9 Specification is hosted by Tenberry Software, Inc.

14. Page Locking Services


[Next Section] * [Previous Section] * [DPMI Index]
[Tenberry Home] * [Software Quality] * [DOS/4G] * [DOS/4GW] * [DOS/16M]

These services are only useful under DPMI implementations that support virtual memory. They will be ignored by 16-bit DPMI implementations (although they will always return with carry clear to indicate success).

Some implementations of DPMI may ignore these calls. However, if the calls are ignored then the DPMI host will be able to handle page faults at arbitrary points during the application's execution including interrupt and exception handler code.

Although memory ranges are specified in bytes, the actual unit of memory that will be locked will be one or more pages. Page locks are maintained as a count. When the count is decremented to zero, the page is unlocked and can be swapped to disk. This means that if a region of memory is locked three times then it must be unlocked three times before the pages will be unlocked.


14.1 Lock Linear Region

This function locks a specified linear address range.

To Call

     AX = 0600h
     BX:CX = Starting linear address of memory to lock
     SI:DI = Size of region to lock in bytes

Returns

     If function was successful:
     Carry flag is clear.

     If function was not successful:
     Carry flag is set.

Programmer's Notes


14.2 Unlock Linear Region

This function unlocks a specified linear address range that was previously locked using the Lock Linear Region function.

To Call

     AX = 0601h
     BX:CX = Starting linear address of memory to unlock
     SI:DI = Size of region to unlock in bytes

Returns

     If function was successful:
     Carry flag is clear.

     If function was not successful:
     Carry flag is set.

Programmer's Notes


14.3 Mark Real Mode Region as Pageable

Under some implementations of DPMI, all memory in virtual 8086 mode is locked by default. If a protected mode program is using memory in the first megabyte of address space, it is a good idea to use this function to turn off automatic page locking for regions of memory that will not be touched at interrupt time.

Do not mark memory as pageable in regions that are not owned by your application. For example, you should not mark all free DOS memory as pageable since it may cause a page fault to occur while inside of DOS (causing a crash). Also, do not mark the DPMI host data area as pageable.

It is very important to relock any real mode memory using function 0603h before terminating a program. Memory that remains unlocked after a program has terminated could result in fatal page faults when other software is executed in that address space.

Note that address space marked as pageable by this function can be locked using function 0600h. This function is just an advisory service to allow memory that does not need to be locked to be paged out. This function just disables any automatic locking of real mode memory performed by the DPMI host.

To Call

     AX = 0602h
     BX:CX = Starting linear address of memory to mark as pageable
     SI:DI = Size of region to page in bytes

Returns

     If function was successful:
     Carry flag is clear.

     If function was not successful:
     Carry flag is set.

Programmer's Notes


14.4 Relock Real Mode Region

This function is used to relock memory regions that were marked as pageable by the previous function.

To Call

     AX = 0603h
     BX:CX = Starting linear address of memory to relock
     SI:DI = Size of region to page in bytes

Returns

     If function was successful:
     Carry flag is clear.

     If function was not successful:
     Carry flag is set.

Programmer's Notes


14.5 Get Page Size

This function returns the size of a single memory page in bytes.

To Call

     AX = 0604h

Returns

     If function was successful:
     Carry flag is clear
     BX:CX = Page size in bytes

     If function was not successful:
     Carry flag is set

Programmer's Notes

None.


[Next Section] * [Previous Section] * [DPMI Index]
[Tenberry Home] * [Software Quality] * [DOS/4G] * [DOS/4GW] * [DOS/16M]
This HTML edition of the DPMI 0.9 Specification is hosted by Tenberry Software, Inc., makers of the DOS/16M and the DOS/4G family of DOS extenders. Page last modified 2003.1.28, <webmaster@tenberry.com>