www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/02/17/17:17:20

From: "Mr. X" <fake AT spam DOT free DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Thread safe programs.
Date: Mon, 16 Feb 1998 01:18:58 -0800
Organization: Skylink Networks, Inc. (http://www.skylink.net./)
Lines: 44
Message-ID: <6c902l$j3j$1@news.skylink.net>
References: <3 DOT 0 DOT 16 DOT 19980215134907 DOT 32ef8a54 AT hem1 DOT passagen DOT se>
NNTP-Posting-Host: ppp072.max4.las-vegas.nv.skylink.net
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

Peter Palotas wrote
>Uhm, okay, I'll explain what I'm doing. I'm writing a library somewhat like
>FORTIFY if you've heard of it which catches all calls to
>new/delete/malloc/free/calloc/realloc and adds stuff to a global linked
>list, and checks for out of bounds writings and a lot of other stuff.
>
>Now maybe it's not neccessary to have global read/write data, but I can't
>think of any other way.
>
>So to make this library thread-safe I now provide a couple of #defines for
>disabling/enabling threads.


   Only the memory allocation routines need to modify the list.  Just have
one memory handler that every thread has to call to get/release memory.
This handler would use the normal routines but would maintain the ownership
list, etc.  So threads couldn't free memory they didn't own, etc.  You could
also add exit handlers to free unfreed resources on a thread's exit, etc.
You could even go on to make new array functions and everything....

   Of course, a real language would take this sorta stuff into consideration
when it was designed.  :)  I've always wondered, if C is so much better, why
does everybody spend so much time trying to add stuff to C that's been in
other languages for years?  :)

   Also, it should be obvious by now, that the place to track resources is
the OS.  If you're just working for DJGPP, you might consider talking to the
author(s) of the multithreading code about adding it to their memory handler
or to the memory handler for DJGPP itself.  He's still looking at malloc()s,
etc.  Of course, since resource tracking slows stuff down, it should be an
option.  What would be *really* cool, is if it was controlled by an
environment varible and could be set at runtime.  Like DJGPP_DEBUG=ON and
all DJGPP programs would use resource tracking, print errors to
DJGPP_STDERR=MONO for a second screen, etc.  This would help developers when
their developing and end users when they have a problem, they could actually
give useful feedback.  But they could leave it off if they prefer speed or
don't understand the messages anyway....

   How about a whole microunix while you're at it?  :)

X



- Raw text -


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