A fully-featured cooperative and preemptive multitasking kernel for 32-bit DOS programs built with DJGPP. Written in C and i386 assembly, DJTASK provides a rich set of concurrency primitives comparable to modern RTOS kernels — all running on bare DOS.
- Preemptive multitasking via IRQ0 (PIT timer) tick counting with polling-based context switching
- Cooperative multitasking via explicit
task_yield()calls - Priority-based scheduling with configurable per-task priority levels
- Round-robin groups for fair time-sharing among equal-priority tasks
- Named tasks for easy identification and debugging
- Semaphores — counting semaphores with blocking wait, try-wait, and signal
- Mutexes — binary locks with ownership tracking and try-lock support
- Condition Variables — wait/signal/broadcast with automatic mutex release and re-acquisition
- Read/Write Locks — multiple concurrent readers, exclusive writer access
- Message Queues — per-task mailboxes with blocking receive, non-blocking try-receive, and queue depth query
- Configurable message size (default 32 bytes payload per message, 16 messages per queue)
- Sleep — put tasks to sleep for a specified number of ticks or milliseconds
- Priority Queue — schedule one-shot callbacks to fire after a delay (tick or millisecond granularity)
- Automatic sleeper wake-up and callback dispatch via per-tick housekeeping
- Worker thread pool with job submission queue
- Configurable number of workers and stack size
- Clean shutdown with graceful worker termination
- Stack guard — magic sentinel values at the bottom of every task stack; periodic overflow detection
- Watchdog timer — detects stuck tasks that haven't run within a configurable timeout
- Task list dump — prints PID, name, priority, state, active flag, round-robin group, and stack guard status for every task
- Windowed text output — create bordered, colored windows on the 80×25 VGA text screen
- Per-window cursor tracking, automatic scrolling, and printf-style formatted output
- Each task can own its own window for isolated visual output
Requires DJGPP cross-compiler or native DOS DJGPP installation.
# Using make
make
# Or manually
gcc -Wall -O2 -g -o multitask.exe main.c main.S
- Preemptive
- Cooperative
- Semaphore
- Mutex
- Condition Variable
- Read/Write Lock
- Messages
- Sleep
- Priority Queue A. Task Pool B. Round-Robin Groups C. Watchdog D. Stack Guard E. VGA Text UI F. EVERYTHING
This project builds on concepts from the LWP (Light Weight Process) library (by Josh Turpen and others) for DJGPP. See the thanks file for the full list of contributors. License
text
Disclaimer: THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY, IMPLIED OR OTHERWISE. I make no promises that this software will even do what it is intended to do or claims to do. USE AT YOUR OWN RISK.
This software is provided to the public domain. The only restriction is that anything that is created using this software has to include a list of names (in the included "thanks" file) crediting the contributors to this software, as they have also contributed to your software.