delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/26/14:53:22

From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Function locking problem (for ISR).
Date: Sat, 26 Apr 1997 14:06:44 -0400
Organization: Cornell University http://www.cornell.edu
Lines: 55
Sender: asu1 AT cornell DOT edu (Verified)
Message-ID: <33624434.1596@cornell.edu>
References: <5jss1o$alv AT lion DOT cs DOT latrobe DOT edu DOT au>
Reply-To: asu1 AT cornell DOT edu
NNTP-Posting-Host: cu-dialup-0011.cit.cornell.edu
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Gregary J Boyles wrote:
> 
> Excuse the size of the file below - you can ignore most of it.
> 
> Down near the bottom of the file there is a function called DoLocking
> which calls Allego style macros for locking code and data. It causes a
> general protection fault because if I comment it out the problem
> disappears. Any sugestions?
> 
> #define START_FUNC(x) void x##_start(){}
> #define END_FUNC(x) void x##_end(){}
> #define LOCK_FUNC(x) _go32_dpmi_lock_code(x##_start,(long)x##_end-(long)x##_start);
> #define LOCK_DATA(x) _go32_dpmi_lock_data(x,sizeof(x));
> 
> #include <dos.h>
> #include <iostream.h>
> #include <stdlib.h>
> #include "string.hh"
> #include "misc.hh"
> 

phewwww ... try to post something shorter the next time.

first, include the correct header files: you absolutely need dpmi.h and
probably go.32.h.

the main problem is how pointers to class member functions are
implemented in c++. basically, 

// Destructor.
START_FUNCTION(Func2);
TimeC::~TimeC()

this won't give you what you need to pass to the locking functions
because pointers to member functions are implemented as simple offset
values. as strostrup writes in the ARM:

"note that &S.i yields the address of i in the specific object S,
whereas &S::i yields a representation of i's relative position in all
objects of class S" (p.156)

i think there is a discussion going on regarding this in
comp.lang.c++.moderated.

you might want to lock the whole area your object takes, but then, i am
no expert in this stuff.

   -- Sinan
 
*******************************************************************
 A. Sinan Unur                                WWWWWW
                                              |--O+O
 mailto:sinan DOT unur AT cornell DOT edu                C   ^ 
 http://www.people.cornell.edu/pages/asu1/     \  ~/ 
*******************************************************************

- Raw text -


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