Newsgroups: comp.os.os2.misc
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!clarkson!grape.ecs.clarkson.edu!towfiq
From: towfiq@FTP.COM (Mark Towfiq)
Subject: Re: Stopping processes
Reply-To: towfiq@FTP.COM
Organization: FTP Software, Inc., Wakefield, MA
Date: 19 Mar 91 12:23:23
Message-ID: <TOWFIQ.91Mar19122323@babyoil.FTP.COM>
In-Reply-To: graeme@praxis.co.uk's message of 4 Mar 91 15:15:49 GMT
References: <1991Mar4.151549.10409@praxis.co.uk>
Sender: usenet@grape.ecs.clarkson.edu

In article <1991Mar4.151549.10409@praxis.co.uk> graeme@praxis.co.uk
(Graeme Cutler) writes:

   [description of multiple threads starting timer processes, and problems
	with killing them, deleted]

   A grotty way to resolve the problem would be to have unique timer process
   names, but what a dirty way of doing it.  Unix handles this sort of thing
   much better ;-).  Any suggestions of there?

When I first started programming in OS/2, I did something similar to
what you are doing, and wanted to start processes left and right to
perform certain tasks.  Perhaps it was because of my familiarity with
the UNIX fork()-style of doing things.

Well, in the past couple of years, I have realized that threads are
threads, and semaphores are semaphores, and they should be used.  I am
sure there is a simple solution to your RESULTCODES problem (maybe you
are calling DosExecPgm() with the wrong flags), but I would suggest
you re-do the timing architecture.  You haven't given many details,
but I assume that timer.exe just takes an arg and waits for a period
before exiting--whatever it is, it could become a thread.  I would
suggest using a ram semaphore local to each thread (i.e. on the stack)
with a timeout value to keep time.  This eats much less memory, and
has the advantage of not starting many small processes.

If your architecture is different from what I assumed, feel free to clarify.

Hope this helps,
Mark
--
Mark Towfiq, FTP Software, Inc.                                  towfiq@FTP.COM
Work No.: +1 617 246 0900			      Home No.: +1 617 488 2818

  "The Earth is but One Country, and Mankind its Citizens" -- Baha'u'llah
