Application Examples
{-----------------------------------------------------------}
{ Determine if there are enough expanded memory pages for
}
{ this application.
}
{-----------------------------------------------------------}
Pages_Needed := APPLICATION_PAGE_COUNT;
Error_Code
:= EMM_Pages_Available (Total_EMM_Pages,
Available_EMM_Pages);
If Error_Code <> STATUS_OK then
Error (’Error determining number of EMM pages available.’,
Error_code);
Writeln (’There are a total of ’, Total_EMM_Pages,
’ expanded memory pages present in this system.’);
Writeln (’
’, Available_EMM_Pages,
’ of those pages are available for use.’);
Writeln;
{-----------------------------------------------------------}
{ If there is an insufficient number of pages for the
}
{ application, then report the error and terminate the
}
{ EMM example program.
}
{-----------------------------------------------------------}
If Pages_Needed > Available_EMM_Pages then
Begin
Str (Pages_Needed, Pages_Number_String);
Error (’We need ’ + Pages_Number
’ EMM pages. There are not that many available.’,
Error_Code);
end; { Pages_Needed . Available_EMM_Pages }
{-----------------------------------------------------------}
{ Allocate expanded memory pages for our use.
}
{-----------------------------------------------------------}
Error_Code :=
Allocate_Expanded_Memory_Pages (Pages_Needed, Emm_Handle);
Str (Pages_Needed,Pages_Number_String);
If Error_Code <> STATUS_OK then
Error (’EMM test program failed trying to allocate ’
+ Pages_Number_String
+ ’ pages for usage.’,Error_Code);
Writeln (APPLICATION_PAGE_COUNT,
’ EMM page(s) allocated for the EMM test program.’);
Writeln;
{-----------------------------------------------------------}
{ Map in the required logical pages to the physical pages
}
{ given to us, in this case just one page.
}
{-----------------------------------------------------------}
Logical_Page
:= 0;
Physical_Page := 0;
Error_Code := Map_Expanded_Memory_Pages (EMM_Handle,
Logical_Page,
Physical_Page);
If Error_Code <> STATUS_OK then
Error (’EMM test program failed trying to map ’
+ ’logical pages into physical pages.’,
Error_Code);
Writeln (’Logical Page ’,
Logical_Page,
4-19
Artisan Technology Group - Quality Instrumentation ... Guaranteed | (888) 88-SOURCE | www.artisantg.com