[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avr-gcc-list] code sequence, function order
From: |
sebastian meuren |
Subject: |
Re: [avr-gcc-list] code sequence, function order |
Date: |
Fri, 2 Jul 2004 12:22:17 +0200 |
> I must admit to implementing the scheduler for the current project in
> assembler.
> On a larger scheduler, providing a separate stack space for each
> task, I've found it helpful to do things backwards. A task calls a
> function to pend on a semaphore, for example. The OS saves the context,
> chooses the next task to run, sets the stack pointer to that task's
> saved value, and _returns_ to the new task. Since it has to have made
> some suspending call, or it would still be running, the task is resumed
> at the line after the suspending call. A full epilogue could be part of
> your context restoration, avoiding the need to write the few lines of
> assembler to restore the registers. (YMMV)
>
Yes, that's what I'm doing! The real scheduler (pushing/poping the
registers) is implented in assembler but the main problem is, that the
argument-registers arn't saved during the "normal" task-switching
(switching between a suspended, e.g. waiting task and a runable one). The
whole register-set is only saved when a task is interrupted by an ISR and a
taskswitch has to occure because the ISR made a task with a higher priority
level runable. I try to explain this in my mail to the avr-gcc mailing-list
as an answere to D.Sc. Julius Luukko's post (look at that for details).
So thank you for your hints as well, I welcome every single one!