Dec 052017
 
C++ source code for multi-tasking kernel.
File CPPTASK.ZIP from The Programmer’s Corner in
Category C++ Source Code
C++ source code for multi-tasking kernel.
File Name File Size Zip Size Zip Type
CONOUT.CPP 2608 936 deflated
CONOUT.HPP 471 286 deflated
README.TXT 4804 1874 deflated
SIO.HPP 4027 1363 deflated
TASK.HPP 11384 2957 deflated
TEST.CPP 4757 1644 deflated
TEST.PRJ 29992 2263 deflated
TSIO.CPP 2938 1083 deflated
TSIO.PRJ 28820 2248 deflated
TSK.MAC 2396 774 deflated
TSKALLOC.CPP 978 455 deflated
TSKASM.ASM 7119 2371 deflated
TSKBIOS.ASM 4413 1315 deflated
TSKBUF.CPP 3539 1085 deflated
TSKCNT.CPP 3015 904 deflated
TSKCONF.HPP 1934 746 deflated
TSKDOS.ASM 20254 5496 deflated
TSKFLG.CPP 2935 853 deflated
TSKKBD.ASM 4718 1359 deflated
TSKLOCAL.HPP 2471 922 deflated
TSKMAIN.CPP 9190 2829 deflated
TSKMSG.CPP 2609 864 deflated
TSKPIP.CPP 5535 1498 deflated
TSKRSC.CPP 2908 932 deflated
TSKSIO.CPP 22461 5300 deflated
TSKSUB.CPP 1655 753 deflated
TSKTASK.CPP 8193 2380 deflated
TSKTIM.ASM 5698 1926 deflated
TSKTIMER.CPP 2976 1027 deflated
TSKWPIP.CPP 5857 1565 deflated

Download File CPPTASK.ZIP Here

Contents of the README.TXT file


This package is a port of CTask from C to C++, hence the name CPPTask. Since
this is a spare time (and until now for personal use only) activity, I have
not documented the changes that I have made.

For the most part, all of the changes that I have made were for converting
CTask to a class-based system. The original package was largely "object-
oriented" anyway. The interesting areas surfaced in the C++ to assembly
language interface (different linkage, etc.), and in the area of dynamic
allocation of tasks, pipes, etc. The first problem was solved by creating
C-linkage functions that invoked member functions. These functions are
used by the assembly language routines. For example, in several of the
assmbly language routines the function "inc_counter(counterptr)" was used.
Since that function became "counter::inc_counter(void)", I created a
function called "asm_inc_counter(counterptr)" with C-linkage. That function
simply invokes the member function:

void asm_inc_counter(counterptr ptr)
{
ptr->inc_counter();
}

I'm not sure if this is the best way, but it works. Also, several of the
assembly language routines created objects, and since constructors cannot
be invoked directly, I moved the creation of the objects to the C++ code
and used the objects as described earlier.

The biggest problem was the dynamic creation of objects. The C version of
the create_??? routines checked for a NULL pointer and allocated memory if
necessary. I redefined the new operator to perform the same processing.
I am not sure if I have done everything that is necessary in the new "new".
The file TSKALLOC.CPP contains the code. Also, I created "task::operator new"
and "task::operator delete" to perform some processing previously done
elsewhere. One final change in this area concerns the deletion of tasks
that are enqueued on a timer queue. The original version merely set a
flag in the tlink structure that indicated that this entry could be deleted.
Unfortunately, the statement:

delete mytask;

could be disasterous if a timer queue was pointing to it. My solution was
to change the task definition to include a pointer to a tlink structure
instead of having the structure nested. This would allow the parent task
to be deleted and the tlink structure to be marked for deletion when it was
removed from the timer queue.

I also removed the Named object processing (I was to lazy to convert it),
and the support for other compilers. Since I was converting it to Turbo C++
and I have no access to any other, I would be unable to test any conditional
compilations anyway. Finally, I have not yet ported the parallel port
interface or the AT-BIOS interface.

Other than added some comments and rearranging some of the files, that is
all I changed (funny it doesn't sound like much now.) I also changed the
name of a couple of the structures, (so they made more sense to me) I hope
this doesn't cause to much confusion.

I am still not convinced that I have covered everything in the area of
dynamic allocation and deallocation. I have tried some very minor variations
on the original test programs, and it seems to work , but...

Good Luck!

Rich



P.S. Here is a list of the files included in the archive:


tskmain.cpp - some of the main routines, and the declaration of
the static objects
tsksub.cpp - some support routines
tsktask.cpp - task object routines
tsktimer.cpp - timer object routines
tskalloc.cpp - memory allocation routines
tskrsc.cpp - resource object routines
tskcnt.cpp - counter object routines
tskflg.cpp - flag object routines
tskmsg.cpp - mailbox object routines
tskpip.cpp - pipe object routines
tskwpip.cpp - word pipe class routines
tskbuf.cpp - buffer class routines
tsksio.cpp - comm port class routines
conout.cpp - sample use of console output
test.cpp - simple test program
tsio.cpp - simple serial I/O test program

conout.hpp - header file for sample console output
sio.hpp - header file for comm port class
task.hpp - header file for all other classes
tskconf.hpp - header file containing configuration definitions
tsklocal.hpp - header file used internally by CPPTask

tskasm.asm - scheduler
tskbios.asm - BIOS support (NOT PORTED!!!)
tskdos.asm - DOS support
tskkbd.asm - keyboard support
tsktim.asm - timer interrupt support

tsk.mac - include file for assembly language

test.prj - sample project file
tsio.prj - sample project file


 December 5, 2017  Add comments

Leave a Reply