A Cooperative Multi Threading Unit for DOS Borland Pascal Many times a need will arise for a program to be able to perform one or more background tasks. This can be done using several different codeing techniques but the one I have found that makes program logic the clearest and leaves a program readable is to set up the progam as several different independent tasks. This unit makes that process very simple for Borland or Turbo pascal users. Since it is not preemptive you don't have to worry about DOS reentrancy or using semaphores to lock resources .You can set up locks using simple boolean variables if they are necessary. But this also places the burden on the programmer to make sure that each task includes a yield or wait call at appropriate intervals . Each thread must have a top level procedure that has no parameters. This procedure must be an infinite loop, that is, no return is allowed from the top level procedure of a thread. To set up multithreading simply call the MAKETASK procedure once for each thread in the program and then call the START procedure . The maketask procedure takes the address of a top level thread procedure and a number that indicates the amount of stack space this thread requires. After you Call the Start procedure the multithreading will begin and control will be passed to a new task each time a yield or wait procedure is called. The unit is set up for a maximum of 24 threads. This can be changed by modifying the MaxTasks constant in the interface section of the unit. The wait procedure that is interfaced takes a long integer parameter. This parameter designates the number of 55 millesecond "ticks" you want this thread to be idle. This 55 milleseconds is an approximation - with a value of 1 you can expect to get random waits from 1 to 55 milleseconds . With higher values the wait will be much more accurate. There will be no return from the Start procedure. To terminate the program simply include a halt statement in one of your threads. You may need to coordinate some things between tasks to make a clean termination but this is usually done easily with boolean variables. One caveat when using this unit with a protected mode program - stack checking {$S+} will not work properly. So always disable stack checking and make sure you specify enough stack space when you set up your threads. This Unit has not been Tested with Stonybrook Pascal+. This software is not warranted to be suitable for any purpose. Use is at you own risk. It has been tested extensively in many complex database/data communications programs - including network and asynchronous communications. Shareware Registration - $10.00 To Bill McKee 3219 Anacapa Way Las Vegas, NV 89102 Registration will get you the next release when available. Planned enhancements include - Inter process communication facilities. Dynamic task shut down Full StonyBrook Support