Patent ID: 8739176

Claim:
A multitasking method for task-driven applications which employs only a single call stack and constrains task suspension to task preemption, wherein application code of a task-driven application is distributed across a plurality of handling functions, and execution flow of a task of a task-driven application is controlled by assigning a plurality of the handling functions to the task in sequence, the assigning being performed through one or more services requested by the task, the method comprising: initializing a plurality of tasks, each task including a status, a priority, and an attribute which identifies one of the handling functions as an assigned handling function of the task, wherein the respective priorities of at least two of the tasks are non-identical; invoking a preemptive scheduler to begin multitasking, wherein the scheduler, whenever invoked, performs a process to execute one of the plurality of tasks comprising: selecting a task with the highest relative priority of one or more tasks which are not pending on any event and determining the status of the selected task; setting the status of the selected task to running and calling the assigned handling function of the selected task when the determined status is ready; and returning from the scheduler to resume execution of the selected task using execution context restored from the single call stack when the determined status is running; requesting, by a task of the plurality of tasks, an assignment service which sets the assigned handling function of the requesting task to a subsequent handling function when executed, wherein the subsequent handling function is specified by the requesting task as part of the request; invoking the scheduler after executing a wait operation called by a calling task, wherein executing a called wait operation comprises making the calling task pend on an identified semaphore of one or more semaphores, wherein the semaphore is specified by the calling task as part of the call, and wherein execution context of a pending task is not preserved; and invoking the scheduler after processing a triggered signal, wherein, when the triggered signal interrupts an executing task which has a lower priority than the priority of a task made ready by processing the triggered signal, the interrupted task is suspended such that execution context of the interrupted task is maintained on the single call stack.