Page 1 of 1

GCC optimizations

Posted: Sun Jul 29, 2007 11:37 am
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...

Posted: Sun Jul 29, 2007 11:58 am
by bluecode
Look into the osdev.org wiki: http://www.osdev.org/wiki/Volatile_(keyword)

Posted: Sun Jul 29, 2007 3:37 pm
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.