A little question about SMP synchronization
Hi all!
I need to synchronize some kernel routines in accessing a shared variable. I would use semaphores (like sema_init(), down_interruptible(), up(), etc.). In order to make it work also on SMP architectures, should I use spinlocks too? Or are semaphores sufficient? Thank you and sorry for bad english |
kernel primitives are SMP-aware
Hi -
The short answer is that, with current versions of Linux (certainly 2.6.x) you can safely use either kernel spinlocks or kernel semaphores with a multi-CPU (or multi-core) SMP system. the same restrictions now apply for SMP as for uniprocessors: if you cannot block, then you need a spinlock. Otherwise, you can (and usually should) use kernel semaphores. Much more detailed info can be found in this excellent article from Linux Magazine: Concurrency in the Kernel, Linux Magazine, November 2005 http://www.linux-mag.com/content/view/2360/0/1/6/ 'Hope that helps .. PSM |
Thank you for aswering, it was very helpful. The article covers almost everything I need to know for now, but...
Quote:
|
All times are GMT -5. The time now is 03:55 PM. |