discussion forum



message

Name: unknown
Date: June 10, 2003 at 09:51:35
Subject: Re: Hyperthreading and 'lock' prefix
In Reply To: Re: Hyperthreading and 'lock' prefix by
james on June 10, 2003 at 04:01:12
Text: || the x86 instruction set supports the 'lock' prefix for various
|| instructions (e.g. inc, add) to guarantee atomicity in multiprocessor
|| environments, i.e. multiple _physical_ processors. But is this
|| prefix also necessary for hyperthreading processors, i.e. two
|| logical processors within one physical processor?
|
| Yes.
|
| I mean, how else is virtual processor #2 gonna know
| that it shouldn't write to a location that virtual
| processor #1 is currently operating on with a read-
| modify-write operation?

Actually I think this goes to architechture. I suspect the lock is less important on a single HT processor that has a uniform view of memory, either via the cache or write buffers. I'd still use them. My preference would be to serialize access to structures rather than do multiple locked RMW actions on elements within the structure, but to each their own.

If there is a chance that the instruction flow might not be serialized then use the lock. I'm not sure exactly how HT dispatches instructions and does load balancing, it could fill executions units in parallel from two or more instruction streams in which case the lock would be needed.

I guess I'd like to know why you don't want to use locks? Multithreading is problematic, any dual processor system (physical/virtual) will likely catch race conditions you wouldn't see on a single processor so you need to program defensively because you ultimately can't control the environment your code might actually run on, now or in the future.

If you don't want to use the lock because it costs too much, then you might want to revisit your algorithm design to eliminate or reduce your need for them.





post a followup message
(Be nice... or be blocked. Be technical... or be erased.)

Name: optional link title:
eMail: optional link URL:
Subject: optional image URL:
  Insert line breaks by hand when only about one inch remains at the right side. Otherwise your message will be unreadable.
Text:
 

  Note: The above eMail form fields may look unaligned if you are using a browser other than Netscape Navigator version 3.0.



currently posted followup messages
(You may have to press the RELOAD button of your browser.)




main page