www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/10/26/09:56:45

Date: Sun, 26 Oct 1997 16:54:17 +0200 (IST)
From: Eli Zaretskii <eliz AT is DOT elta DOT co DOT il>
To: cumani AT dns DOT ien DOT it
cc: djgpp AT delorie DOT com
Subject: Re: Question: locking memory
In-Reply-To: <34505E87.1E5E@is.ien.it>
Message-ID: <Pine.SUN.3.91.971026165358.17911M-100000@is>
MIME-Version: 1.0

On Fri, 24 Oct 1997 cumani AT dns DOT ien DOT it wrote:

> I wish to allocate a buffer in my app and lock it into memory, since it
> has to be accessed by an int handler. I suppose that
> _go32_dpmi_lock_data should work for this. However, when processing is
> finished, i want to unlock and free the buffer, but in the library there
> is no complementary unlock_data routine

Usually, programs lock memory, install an interrupt handler and then
don't uninstall it until the program exits.  That's why there's no
corresponding unlock function.

However, `_go32_dpmi_lock_data' does little beyond calling the raw
DPMI memory-locking function.  I reproduce its full source below.  As
you can see, it would be very easy to call `__dpmi_unlock_linear_region' 
function to unlock the region locked by `_go32_dpmi_lock_data'.


int _go32_dpmi_lock_data( void *lockaddr, unsigned long locksize )
    {
    unsigned long baseaddr;
    __dpmi_meminfo memregion;

    if( __dpmi_get_segment_base_address( _go32_my_ds(), &baseaddr) == -1 ) return( -1 );

    memset( &memregion, 0, sizeof(memregion) );

    memregion.address = baseaddr + (unsigned long) lockaddr;
    memregion.size    = locksize;

    if( __dpmi_lock_linear_region( &memregion ) == -1 ) return( -1 );

    return( 0 );
    }

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019