#include <uart_host.h>
#endif
-pthread_mutex_t mut;
+static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
static volatile int cpt = 0;
static struct termios oldterm;
#endif
}
+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;
+}
+
void host_wait_ms(int ms)
{
struct timeval tv, tv2, diff;
pthread_t parent_id, child_id, child2_id, child3_id;
int ret;
- pthread_mutex_init(&mut, NULL);
-
parent_id = pthread_self();
pthread_mutex_lock(&mut);
return 0;
}
-void hostsim_exit(void)
+int hostsim_exit(void)
{
#ifdef CONFIG_MODULE_UART
tcsetattr(0, TCSANOW, &oldterm);
#endif
+ exit(0);
+ return 0;
}
#endif /* HOST_VERSION */