up to Magazine | to top of site


A C Threading Library

This was published in the October 1988 issue of Computer Language Magazine. I don't have it online yet, but the code is. This implements a library for "co-routines" or simple non-pre-emptive multi tasking in C.

This is an extension to the C run-time environment to support multi-threaded programs. A single function is needed to accomplish a task switch; it is written is assembly language and is rather simple since it uses the normal function call and return mechanism to switch states. All that the function needs to do is save the value of the stack pointer and load a different value (both are parameters), a matter of 2 lines or so in whatever assembly language you are using. Once this is available, the entire environment consisting of semaphores, messages, pipes, and a scheduler can all be written in portable C. The 10 listings give a layered and modular library.

It proved to be a very popular article, and I was getting letters and calls about it for years after it was published. So, it was easy to get them to publish a sequel, which implements pre-emption and does it in C++.

Pre-Emptive Tasking in C++

This was the cover for the November 1989 issue of Computer Language Magazine. Read it and access the original code here.

Mutual Exclusion with Threads

Article #18 in the Cobb Group series.

Multithreading #1

This is still lost. But, the central lessons are the concept of Critical Initialization where a new thread is allowed to run without worry of threading issues, before it is ready for normal use; and refining this into a practice of running an object's constructor in the context of the created thread, blocking the caller until the constructor is complete. That is, the constructor is run like a normal synchronous subroutine, but in the context of the created thread, and after that the two threads run concurrently.

Multithreading #2 (no subtitle)

This essay has a file date of January 8, 1997. I don't know where it appeared or where #1 is. I found it along with an early backup copy of the threading book, which was lost in a disk malfunction. So it may be a backup of part of a larger collection which has been lost.

Complete Guide to C++ and Threads under Windows NT

This is a backup made when I was just getting started. After a few days of substantial work, I had a hard drive fail and lost the whole thing and current backups. I was so upset about it that I never returned to the project, and went on to other things. I post a recovered file here for my archives. Some of the ideas are repeated here and elsewhere, such as marshaling, the thread-launcher as an object, and critical initialization.

Atomic Counters

This started out as the same material as published in the August 1998 issues of Visual C++ Developer, and then is edited to integrate it into the rest of the documentation and evolves with updates to the material.

Valid HTML 4.01!

Page content copyright 2008 by John M. Długosz