Subj : Re: What is the real costs of LOCK on x86 multiprocesor machine? To : comp.programming.threads From : Mirek Fidler Date : Sat Jul 30 2005 07:47 pm Joe Seigh wrote: > Sean Kelly wrote: > >> Joe Seigh wrote: >> >>> Statically or dynamically linked code? The only case I >>> think you can safely get away with making LOCK optional >>> is in system dynamically linked libraries that are hardware >>> configuration specific. I use LOCK in inlined code since it's >>> in effect statically linked and you don't know where the code >>> will eventually execute. >> >> >> >> What about testing the hardware configuration on startup and setting a >> global state flag? Would it be worthwhile to do this and deal with the >> duplicated asm and branching it would require? >> > Depends on whether the global state flag is in cache when you test it > and whether ia32-64 handles short conditional jumps effectively. The > condition means the pipeline stalls until the flag can be tested. AFAIK not true. That is what branch prediction is for, is not it? I believe that in case of testing single flag that never changes, actuall amortized branch costs will be lower than one cycle. Mirek .