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.
Two versions of COMATOS exist at this time. The first was written in the Fall of 1999 in assembly. The second was written in the summer of 2000 using the Codevision AVR C compiler.
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, the assembly version allows the user to dynamically change the address at which execution of a task begins, through the OSSetEntryPt call, allowing 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.