delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/15/21:30:18

From: "Paul Derbyshire" <pderbysh AT usa DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Threading and asynchronous processes
Lines: 48
Organization: The Chaos Zone
MIME-Version: 1.0
Message-ID: <8R571.1176$qR3.4113921@news20.bellglobal.com>
Date: Sat, 16 May 1998 01:20:04 GMT
NNTP-Posting-Host: 206.172.182.156
NNTP-Posting-Date: Fri, 15 May 1998 21:20:04 EDT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

It is fairly simple to create multithreaded DJGPP code using hooked timer
interrupts and other fiddling. But two questions arise:

1. Can this form of threading launch a separate asynchronous process safely,
e.g. a
    shell to command.com to display a directory as a simple example? If there
are
    constraints, which of these will work?
    * Command.com and its builtin commands
    * Real-mode DOS apps
    * Other DJGPP apps
    * "start" or a Win32 app
    * Protected mode DOS apps using something other than DPMI e.g. DOS4GW
       (Somehow I doubt this one)
    If not, is it at least safe to suspend all the other threads to call it
synchronously?
2. I have written a thread-safe operator new and delete wrapping malloc and
using a
    mutex. However I have a question about safety of exception throwing. Do
    exceptions involve some sort of non-constant global objects? If so, would
this
    require suspending all threads at any throw and resuming in a catch, to be
safe,
    or could the threading scheduler be modified to make exception throwing
safe?
    Just how does the thrown object propagate anyways, using a pointer in a
register?
    What are the details of stack unwinding -- is it safe as long as each
thread has its
    own stack, and the start of its call chain is wrapped in a try block so as
not to
    allow any exceptions to pass?
    (For anyone wanting to issue remarks or concerns about the performance of
    code using malloc, please note I have written pool allocators to divert any
requests
    for small allocations (32 bytes or less) to use pools of fixed size blocks
allocated
    in big chunks, e.g. 262144 bytes.)

--
   .*.  "Clouds are not spheres, mountains are not cones, coastlines are not
-()  <  circles, and bark is not smooth, nor does lightning travel in a
   `*'  straight line."    -------------------------------------------------
        -- B. Mandelbrot  |http://www3.sympatico.ca/bob.beland/indexn2f.html
_____________________ ____|________     Paul Derbyshire     pderbysh AT usa DOT net
Programmer & Humanist|ICQ: 10423848|


- Raw text -


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