Index: uspace/lib/cpp/include/impl/mutex.hpp
===================================================================
--- uspace/lib/cpp/include/impl/mutex.hpp	(revision 53c6e6ae0bade2436fdb9440f0b9afa41b74a07e)
+++ uspace/lib/cpp/include/impl/mutex.hpp	(revision b4b961b71faa4aa5bccb32fe671391962d367f71)
@@ -642,6 +642,34 @@
     }
 
+    namespace aux
+    {
+        template<class L>
+        int try_lock_tail(int idx, L& l)
+        {
+            if (!l.try_lock())
+                return idx;
+            else
+                return -1;
+        }
+
+        template<class L1, class... L2>
+        int try_lock_tail(int idx, L1& l1, L2&... ls)
+        {
+            if (!l1.try_lock())
+                return idx;
+
+            auto ret = try_lock_tail(idx + 1, ls...);
+            if (ret != -1)
+                l1.unlock();
+
+            return ret;
+        }
+    }
+
     template<class L1, class L2, class... L3>
-    int try_lock(L1& l1, L2& l2, L3&... ls);
+    int try_lock(L1& l1, L2& l2, L3&... ls)
+    {
+        return aux::try_lock_tail(0, l1, l2, ls...);
+    }
 
     namespace aux
