[rtems commit] libblock: Add SMP support

Sebastian Huber sebh at rtems.org
Wed Aug 14 09:05:15 UTC 2013


Module:    rtems
Branch:    master
Commit:    9de9b7d237aa65c691081cd30e55fedff2e57d6a
Changeset: http://git.rtems.org/rtems/commit/?id=9de9b7d237aa65c691081cd30e55fedff2e57d6a

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Aug 14 11:06:02 2013 +0200

libblock: Add SMP support

---

 cpukit/libblock/src/diskdevs.c |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/cpukit/libblock/src/diskdevs.c b/cpukit/libblock/src/diskdevs.c
index 96bcf88..2397c28 100644
--- a/cpukit/libblock/src/diskdevs.c
+++ b/cpukit/libblock/src/diskdevs.c
@@ -57,6 +57,8 @@ static rtems_id diskdevs_mutex;
  */
 static volatile bool diskdevs_protected;
 
+static rtems_interrupt_lock diskdevs_lock;
+
 static rtems_status_code
 disk_lock(void)
 {
@@ -435,13 +437,13 @@ rtems_disk_obtain(dev_t dev)
   rtems_disk_device *dd = NULL;
   rtems_interrupt_level level;
 
-  rtems_interrupt_disable(level);
+  rtems_interrupt_lock_acquire(&diskdevs_lock, level);
   if (!diskdevs_protected) {
     /* Frequent and quickest case */
     dd = get_disk_entry(dev, false);
-    rtems_interrupt_enable(level);
+    rtems_interrupt_lock_release(&diskdevs_lock, level);
   } else {
-    rtems_interrupt_enable(level);
+    rtems_interrupt_lock_release(&diskdevs_lock, level);
 
     sc = disk_lock();
     if (sc == RTEMS_SUCCESSFUL) {
@@ -461,10 +463,10 @@ rtems_disk_release(rtems_disk_device *dd)
   unsigned uses = 0;
   bool deleted = false;
 
-  rtems_interrupt_disable(level);
+  rtems_interrupt_lock_acquire(&diskdevs_lock, level);
   uses = --dd->uses;
   deleted = dd->deleted;
-  rtems_interrupt_enable(level);
+  rtems_interrupt_lock_release(&diskdevs_lock, level);
 
   if (uses == 0 && deleted) {
     rtems_disk_delete(dev);




More information about the vc mailing list