Hi,
Solar wrote:I don't see where calling static void gdtInstall (void) makes "much" difference, performance-wise, whether it's written in inline or extern ASM? The extern solution is definitely cleaner, as you have separate source files for separate languages. (Warning: ASM noob here, I might just be missing the obvious.)
Performance wise, using an external (assembly) routine would cost a CALL/RET, which adds about 2 cycles on a modern CPU. As this code would be run once during boot, the end result is that the OS would take about 1 nanosecond longer to boot.
On the other hand, for the life-time of the code, it'll probably cost programmers 20 hours or more in maintenance and assorted hassles.
Simple maths says that unless the OS is booted more than 72000000000000 times (e.g. 36 million users that boot it 2 million times each), using inline code is a waste of time (the time spent maintaining it is more than the time saved booting it).
However, there is a compromise - do the entire "gdtInstall()" in an external assembly routine. That way you avoid the extra CALL/RET, and separating architecture specific code from the portable C code will make it easier/quicker to port to a different architecture (and avoid time spent for "maintenance and assorted hassles"). It's a "win win" situation...
Cheers,
Brendan