home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / library / dos / multtsk / multi / multi.doc < prev    next >
Encoding:
Text File  |  1993-02-27  |  3.0 KB  |  69 lines

  1.  
  2.                         A Cooperative Multi Threading Unit
  3.                            for DOS Borland Pascal
  4.  
  5.  
  6.  
  7.    Many times a need will arise for a program to be able to perform one or
  8. more background tasks. This can be done using several different codeing
  9. techniques but the one I have found that makes program logic the clearest
  10. and leaves a program readable is to set up the progam as several different
  11. independent tasks. This unit makes that process very simple for Borland or
  12. Turbo pascal users. Since it is not preemptive you don't have to worry about
  13. DOS reentrancy or using semaphores to lock resources .You can set up locks
  14. using simple boolean variables if they are necessary. But this also places
  15. the burden on the programmer to make sure that each task includes a yield or
  16. wait call at appropriate intervals .
  17.  
  18.   Each thread must have a top level procedure that has no parameters. This
  19. procedure must be an infinite loop, that is, no return is allowed from the
  20. top level procedure of a thread. To set up multithreading simply call
  21. the MAKETASK procedure once for each thread in the program and then call
  22. the START procedure . The maketask procedure takes the address of a top
  23. level thread procedure and a number that indicates the amount of stack space
  24. this thread requires.
  25.  
  26.   After you Call the Start procedure the multithreading will begin and
  27. control will be passed to a new task each time a yield or wait procedure
  28. is called. The unit is set up for a maximum of 24 threads. This can be
  29. changed by modifying the MaxTasks constant in the interface section of the
  30. unit.
  31.  
  32.    The wait procedure that is interfaced takes a long integer parameter.
  33. This parameter designates the number of 55 millesecond "ticks" you want this
  34. thread to be idle. This 55 milleseconds is an approximation - with a value
  35. of 1 you can expect to get random waits from 1 to 55 milleseconds . With
  36. higher values the wait will be much more accurate.
  37.  
  38.   There will be no return from the Start procedure. To terminate the program
  39. simply include a halt statement in one of your threads. You may need to
  40. coordinate some things between tasks to make a clean termination but this
  41. is usually done easily with boolean variables.
  42.  
  43.   One caveat when using this unit with a protected mode program - stack
  44. checking {$S+} will not work properly. So always disable stack checking
  45. and make sure you specify enough stack space when you set up your threads.
  46.  
  47.   This Unit has not been Tested with Stonybrook Pascal+.
  48.  
  49.   This software is not warranted to be suitable for any purpose. Use is at
  50. you own risk. It has been tested extensively in many complex database/data
  51. communications programs - including network and asynchronous communications.
  52.  
  53.  
  54. Shareware Registration - $10.00
  55.  
  56.           To
  57.                 Bill McKee
  58.                 3219 Anacapa Way
  59.                 Las Vegas, NV   89102
  60.  
  61.  Registration will get you the next release when available.
  62.  Planned enhancements include -
  63.  
  64.    Inter process communication facilities.
  65.  
  66.    Dynamic task shut down
  67.  
  68.    Full StonyBrook Support
  69.