Date: Sun, 26 Oct 1997 16:54:17 +0200 (IST) From: Eli Zaretskii 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: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk 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 ); }