Информационный сервер для программистов: Исходники со всего света. Паскальные исходники со всего света
  Powered by Поисковый сервер Яndex: Найдется ВСЁ!
На Главную Исходники Форум Информер Страны мира
   Многозадачность в Паскале    >>    multi1
   
 
 Dos Multi Threader Unit for Turbo pascal  Bill McKee 27.02.93

Модуль для организации кооперативной многозадачности, позволяющий выполнять несколько задач-подпрограмм одновременно, независимо друг от друга. В приведенном примере запускаются две подзадачи, каждая из которых наращивает свой счетчик с разной скоростью. Компилируется BP7 в Real/Protected Mode.
A Cooperative Multi Threading Unit for DOS Borland Pascal. This unit makes multi thread process very simple for Borland or Turbo pascal users. It is not preemptive multitasking, so you don't have to worry about DOS reentrancy or using semaphores to lock resources.



3k 
 

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 begi