Diamondb Stress Management and IT Solutions


Forth-style Multitasking in Borland's® Turbo C 2.00

This is just a trial example that I wrote many years ago (circa 1990) to demonstrate a way of gaining forth-style multitasking ability in Turbo C 2.00. The threading ability is intentionally simple and would be classed as "light threading". Consequently any resultant programs should be quite lean. At the moment, you can still download a copy of Turbo C 2.01 from Borland's community site:

Antique Software: Turbo C version 2.01

It uses knowledge of the C stack frame and setjmp/longjmp structure. It also does naughty things with the PC's clock interrupt to get millisecond timing, though that could be excluded/modifed.

All the classic Forth multitasking elements are defined: PAUSE, STOP, ACTIVATE, MS, GRAB, GET and RELEASE.

To define a task, use the structure TASK. To initialize the multitasking, the C function

"InitTasking(TopLevelTask, StackSize)"

is used. I would suggest reading through the entire set of files and understanding all the comments before use.

The links below point to the individual files needed to compile a demonstration program. They are all contained in a zip file, MULTITHD.ZIP, the link for which is also below. You could compile Multithd.c into a library and then just link into it from your own programs.

You could ether click on the links to show each page (bit tricky for the *.prj and *.zip extensions since they are not text files) or shift-click to download them.


C Multithreading Demonstration files:

THRDEMO.C

THRDEMO.PRJ

MULTITHD.C

MULTITHD.H

MULTITHD.PRJ

MULTITHD.ZIP

Have Fun!


 

 


Home