[haiku-bugs] Re: [Haiku] #5693: Implement pthread spinlocks (easy)

  • From: "lucian" <trac@xxxxxxxxxxxx>
  • Date: Sat, 17 Apr 2010 17:02:01 -0000

#5693: Implement pthread spinlocks (easy)
--------------------------+-------------------------------------------------
 Reporter:  bonefish      |       Owner:  nobody        
     Type:  enhancement   |      Status:  new           
 Priority:  normal        |   Milestone:  R1            
Component:  System/POSIX  |     Version:  R1/Development
 Keywords:                |   Blockedby:                
 Platform:  All           |    Blocking:                
--------------------------+-------------------------------------------------

Comment(by lucian):

 a) There's no much value, just a lower footprint (size/speed): I can skim
 off a few call/ret instructions, and code it using better optimized asm.

 b) The test is not really that superfluous.
 Hammering the processor with instructions with LOCK prefixes (as in atomic
 test and set) will block the memory lines for two cycles. In single
 processor mode this will delay access to DMA, while in multiprocessor
 setups this will delay all other processors too regardless of the
 addresses used.

 Ok, the _trylock one is not really that important as it is done only once,
 but the one in the loop will lead to poorer performance.

 See http://en.wikipedia.org/wiki/Test_and_Test-and-set

 I'll run some tests to prove my claims.

 c) I'll post a revised patch with LOCKED/UNLOCKED.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/5693#comment:4>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: