COrnell Miniature ATmel Operating System (COMATOS)
By Ben Greenblatt
Welcome to COrnell Miniature ATmel Operating System (COMATOS), a simple, non-preemptive real-time operating system for the Atmel AT90S8515 and related microcontrollers. This site documents the internal workings of COMATOS and provides instruction in programming for the operating system.
Basic Features:
- Size: Approximately 1K of program memory and 144 bytes of data memory
- Scheduling
- Up to 8 tasks
- Non-Preemptive - Tasks are expected to terminate themselves
- Timeout function - Tasks can be set to run periodically at any interval from 1ms to 255ms
- Messaging function - Tasks can be set to run upon reception of messages from any combination of other tasks
- Operating System Clock
- System clock ticks every 1 ms
- 4 Byte global system time
- System can be set to terminate when a task fails to return after any amount time from 1ms to 65535ms
- Application Programmer's Interface (API) - Intuitive operating system calls for message passing, UART manipulation, and basic task maintenance
- Debugging Features
- C++ Debug Monitor runs on PC and connects to MCU via UART
- Fully transparent Register Dump system call sends register values to the UART
- System halt when task fails to return, no tasks loaded, or bad return code
- Send-string-to-UART call available to user programs
Basic Rules
Programming under an OS is dramatically different from programming a foreground-background system. Tasks in COMATOS are basically subroutines. Each task is created using a special OS call, OSCreateTask. A scheduler runs routinely to determine which tasks are eligible to run. Since this is a non-preemptive operating system, it is the responsibility of the task to return control to the OS. Many larger operating systems preserve the state of all of the registers for each task, effectively giving each process its own register set. Because the AT90S8515 only has 512 bytes of SRAM, storing all of the registers is infeasible. As a result, the state of the registers is not preserved between runs of a task. Several options are available for storing state. First, tasks can send messages to one another containing information. Secondly, each task has a byte of memory, called PCBState, in which to store state information. Finally, dynamically changing the address at which execution of a task begins, through the OSSetEntryPt call, allows for execution of different code depending on the state of the task.
I recommend examining this documentation, especially the Application Programmer's Interface and the tutorial before beginning to code for COMATOS.
Questions? Contact Ben Greenblatt
Copyright 1999 Benjamin M. Greenblatt