GCC optimizations

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
salil_bhagurkar
Member
Member
Posts: 261
Joined: Mon Feb 19, 2007 10:40 am
Location: India

GCC optimizations

Post by salil_bhagurkar »

I have an average sized kernel with about 25 C files excluding headers... Till now i was compiling the kernel with no gcc optimizations. It shouldn't make a difference but when i do compile it with any of the optimizations (-O1,2, or 3) then the kernel fails to receive interrupts and hence in a very early init stage the scheduler hangs...

I saw topics on this and came to the conclusion that i need to:
1. Use -Wall and solve all warnings
2. Use volatile wherever necessary

Hence, i am currently working on my kernel writing protorypes and declarations, and removing unused variables etc. to get rid of the warnings.

But i however fail to understand the use of volatile...

My kernel has a scheduler but currently theres only one kernel process which initiates everything...

So could any one give me the rules for using volatile or link me to a nice tutorial?

Thank you very much...
User avatar
bluecode
Member
Member
Posts: 202
Joined: Wed Nov 17, 2004 12:00 am
Location: Germany
Contact:

Post by bluecode »

Look into the osdev.org wiki: http://www.osdev.org/wiki/Volatile_(keyword)
pcmattman
Member
Member
Posts: 2566
Joined: Sun Jan 14, 2007 9:15 pm
Libera.chat IRC: miselin
Location: Sydney, Australia (I come from a land down under!)
Contact:

Post by pcmattman »

Volatile basically tells the compiler to not optimize out accesses to that particular variable. Basically, it's like saying 'don't cache this data'.

Officially, it's meant to tell the compiler that the variable's value is going to change often and without notice.
Post Reply