/* Einkornix, a tiny, primitive cooperative-multitasking operating system for the ARM EABI, which consists of 34 instructions of Thumb-2 code (84 bytes) and 4 bytes of data, plus 8 bytes per thread, plus the thread stacks. The implementation is in einkornix.S. Documentation is below, or see einkornix-test.c for example usage. Relatedly, monokokko.S is a cut-down all-assembly version not compatible with the standard ABI. */ /* An Einkornix thread is called a task. This struct stores its state: */ typedef struct eintask { void *stack; struct eintask *next; } eintask; /* Call einstart initially to create a task list consisting of a single task, the current one, initializing an uninitialized eintask in the process: */ void einstart(eintask *me); /* Call to start a new task; first you must allocate kid and initialize kid->stack to point to an 8-byte-aligned location at the end of its stack space (which you must also allocate). start is the function to invoke initially in the new task, passing it argument userdata. start must not return. */ void einspawn(eintask *kid, void (*start)(void *userdata), void *userdata); /* Call from a task to yield the CPU to other tasks. */ void einyield(void); /* Call from a task to terminate it. Does not return. If you want to reclaim the task's eintask struct or stack space for reuse, you'll need to keep track of it in your own code. */ void einexit(void);