- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
Can i use Peterson Lock as SMP Lock, if the processor doesn't support Get-and-Set instruction?
Thanks,
Mani
Link Copied
4 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, of course. However, then hardware has to support either sequentially-consistent memory model or #StoreLoad style memory fences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Peterson's lock was designed for precisely this scenario. However, you need to ensure that the operations become visible to the other processors in the right order. The algorithm assumes a sequentially-consistent memory model, and on some platforms this will require memory fence operations before and/or after some of the stores and loads.
You also need to bear in mind that Peterson's lock is not a replacement for a general-purpose mutex --- each thread that tries to access the critical section must have a specific ID. The basic algorithm only works with 2 specific threads, though it is possible to extend it to more.
You also need to bear in mind that Peterson's lock is not a replacement for a general-purpose mutex --- each thread that tries to access the critical section must have a specific ID. The basic algorithm only works with 2 specific threads, though it is possible to extend it to more.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
thanks for the reply.
But how can we extend Peterson lock for N-processes?
Thanks,
Mani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
This paper describes a technique to convert two-wayPeterson'slock into N-way:
http://www.google.com/url?sa=t&source=web&cd=10&ved=0CDcQFjAJ&url=http%3A%2F%2Fciteseerx.ist.psu.edu%2Fviewdoc%2Fdownload%3Fdoi%3D10.1.1.86.9087%26rep%3Drep1%26type%3Dpdf&ei=SLN9TMjvIIKnnQebi_H3AQ&usg=AFQjCNHYzNkfxUJVNVbe1-lDHV5LKOeheQI think they call it a filter lock or something...

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page