Hi Sam, > My compiler (gcc 4.4.2) did not like the assembly that was being used for the > current spinlock implementation, and I had some trouble figuring out how > the assembly actually worked. I implemented my own spin lock that uses > very little assembly and I attached it to this message.
That's interesting. Can you describe the problem in more detail? Our automated build tests http://l4ka.org/projects/pistachio/buildstatus/hg.php run through with gcc 4.4.2, both for x32 and x64. Maybe it's a binutils problem? We use 2.19.1 for x64 and 2.19.51 for x32. Note there is a bug in GCC that sometimes mixes up sections in a way that linking fails afterwards. In pistachio, we occasionally run into this bug in when moving text into a different section, e.g., as done with spinlocks. If you click on FAIL in x86-x32-p4-smp 4.3.3 FAIL or x86-x64-p4-smp 4.3.3 FAIL on the webpage above you can read get the error message of that bug. I believe it has something to do with those bugs: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33871 http://sourceware.org/bugzilla/show_bug.cgi?id=11111 and it depends on the combination of gcc and binutils. I didn't spend time to investigate or work around the bug, however, as I got the impression that the problem went away with more recent revisions of gcc (>= 4.4.) and binutils (>= 2.19). Your spinlock implementation is more generic and clean, but doesn't move the contended code path into a different section, in order to maintain the uncontended code as a fall-through path, as the original assembly code does. Maybe one could include both and enable the original one only with known-good compiler/binutils versions, but that requires knowing which ones fail. For now, I'd suggest I include your fix, but leave it #if0'ed. > Please let me know what the proper patching procedure is, and if you want > the code I will be happy to supply a patch. Patches and fixes are always welcome. Typically, people post patches or solutions on this list and we commit a fix ourselves. All L4Ka::Pistachio code is released under the two-clause BSD license. Thanks! -Jan -- Jan Stoess KIT/UKa System Architecture Group Phone: +49 (721) 608-4056 Fax: +49 (721) 608-7664 eMail: sto...@kit.edu