+static int lock_count = 0;
+
+void hostsim_lock(void)
+{
+ if (lock_count++)
+ return;
+ pthread_mutex_lock(&mut);
+}
+
+void hostsim_unlock(void)
+{
+ if (lock_count-- == 1)
+ pthread_mutex_unlock(&mut);
+}
+
+int hostsim_islocked(void)
+{
+ return lock_count;
+}
+