- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
PowerPC 440 context switching
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-07-2009 02:41 PM
Hi.
I'm struggeling with interrupts on a powerPC 440. How do I do context switching? What I want to do, is to just toggle a flag in the interrupt, but as soon as the interrupt is serviced and the flag is set, the main code is unable to see the state of the flag.
Thanks.
Re: PowerPC 440 context switching
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-08-2009 12:42 AM
Hi rikusleroux,
you have to ensure that the flag must not be registered but swapped into the data section like this:
static volatile int flag;
static void isr (void *p_attr){
flag=TRUE;
..
}
void main(void){
if(TRUE==flag){
..
}
..
}
Rgds,
Kai
Re: PowerPC 440 context switching
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-08-2009 12:55 AM
Thanks dorau.
So if I only put "static volatile" before my variable this will solve my problem? What if the flag is part of a struct? Should I make the whole struct "static volatile" of only the variable inside the struct? I should also mention that the struct is declared in another source file, so I'm using it as an "extern" variable. Will this make a difference?
Re: PowerPC 440 context switching
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-08-2009 01:20 AM
Hi,
>So if I only put "static volatile" before my variable this will solve my problem? What if the flag is part of a struct? Should I make the whole struct "static volatile" of only the variable inside the >struct? I should also mention that the struct is declared in another source file, so I'm using it as an "extern" variable. Will this make a difference?
The "static" keyword is not relevant. Using the keyword volatile is mandatory for global attributes that shall be processed in the ISR and main task in parallel to
avoid "race condition"!
If your flag is part of a struct, i guess you should use the volatile keyword, too.
To look how a context switch work try to examine the sources of the xilkernel multitask OS. There is a context switch implemented based on the PIT.
Rgds,
Kai











