Mail Archives: djgpp/1998/08/25/16:48:45
On 25 Aug 98 at 14:28, JS Churchill wrote:
> I have changed the _crt0_startup_flags which was
> int _crt0_startup_flags = _CRT0_FLAG_NEARPTR | _CRT0_FLAG_NONMOVE_SBRK;
>
> it now includes _CRT0_FLAG_LOCK_MEMORY;
>
> it now works perfectly under DOS and windows using malloced mem
> but could someone pleas tell me why it was not working without this..
> thanks in advance
> Simon
When you use interrupts you must ensure that DOS code is never
called during the interrupt. You can easily avoid calling it directly from
your handler. However, if your handler's code is not currently in
physical memory then it must be paged in from disk. This would
involve various DOS functions, which cannot be called, so instead we
get a page fault.
To prevent this from happening, you must lock all memory touched
during the interrupt; this ensures that it's always in physical
memory, never swapped out to disk. One way to do this is as you did
above -- by forcing all memory to be locked. The other way is to use
the locking functions in libc to lock specific regions of memory.
Look up `_go32_dpmi_lock_code' and `_go32_dpmi_lock_data'.
--
george DOT foot AT merton DOT oxford DOT ac DOT uk
- Raw text -