From 2bf244968fb368b204e7af4b33b72d6a71a937c6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?=
Date: Wed, 24 Jul 2013 19:55:47 +0200
Subject: erts: Extend erl_driver interface with lock names
Lock and thread names are already a feature in the driver interface.
This extension will let developers read these names. Eases debugging.
---
erts/emulator/beam/erl_driver.h | 8 ++++---
erts/emulator/beam/erl_drv_thread.c | 42 +++++++++++++++++++++++++++++++++++++
2 files changed, 47 insertions(+), 3 deletions(-)
(limited to 'erts')
diff --git a/erts/emulator/beam/erl_driver.h b/erts/emulator/beam/erl_driver.h
index e280563de1..42b14cd7bc 100644
--- a/erts/emulator/beam/erl_driver.h
+++ b/erts/emulator/beam/erl_driver.h
@@ -546,6 +546,11 @@ EXTERN int erl_drv_equal_tids(ErlDrvTid tid1, ErlDrvTid tid2);
EXTERN void erl_drv_thread_exit(void *resp);
EXTERN int erl_drv_thread_join(ErlDrvTid, void **respp);
+EXTERN char* erl_drv_mutex_name(ErlDrvMutex *mtx);
+EXTERN char* erl_drv_cond_name(ErlDrvCond *cnd);
+EXTERN char* erl_drv_rwlock_name(ErlDrvRWLock *rwlck);
+EXTERN char* erl_drv_thread_name(ErlDrvTid tid);
+
/*
* Misc.
*/
@@ -681,6 +686,3 @@ EXTERN int erl_drv_getenv(char *key, char *value, size_t *value_size);
/* also in global.h, but driver's can't include global.h */
void dtrace_drvport_str(ErlDrvPort port, char *port_buf);
-
-
-
diff --git a/erts/emulator/beam/erl_drv_thread.c b/erts/emulator/beam/erl_drv_thread.c
index a49a155701..4f1bba8657 100644
--- a/erts/emulator/beam/erl_drv_thread.c
+++ b/erts/emulator/beam/erl_drv_thread.c
@@ -188,6 +188,17 @@ erl_drv_mutex_destroy(ErlDrvMutex *dmtx)
#endif
}
+
+char *
+erl_drv_mutex_name(ErlDrvMutex *dmtx)
+{
+#ifdef USE_THREADS
+ return dmtx ? dmtx->name : NULL;
+#else
+ return NULL;
+#endif
+}
+
int
erl_drv_mutex_trylock(ErlDrvMutex *dmtx)
{
@@ -258,6 +269,15 @@ erl_drv_cond_destroy(ErlDrvCond *dcnd)
#endif
}
+char *
+erl_drv_cond_name(ErlDrvCond *dcnd)
+{
+#ifdef USE_THREADS
+ return dcnd ? dcnd->name : NULL;
+#else
+ return NULL;
+#endif
+}
void
erl_drv_cond_signal(ErlDrvCond *dcnd)
@@ -331,6 +351,16 @@ erl_drv_rwlock_destroy(ErlDrvRWLock *drwlck)
#endif
}
+char *
+erl_drv_rwlock_name(ErlDrvRWLock *drwlck)
+{
+#ifdef USE_THREADS
+ return drwlck ? drwlck->name : NULL;
+#else
+ return NULL;
+#endif
+}
+
int
erl_drv_rwlock_tryrlock(ErlDrvRWLock *drwlck)
{
@@ -617,6 +647,18 @@ erl_drv_thread_create(char *name,
#endif
}
+char *
+erl_drv_thread_name(ErlDrvTid tid)
+{
+#ifdef USE_THREADS
+ struct ErlDrvTid_ *dtid = (struct ErlDrvTid_ *) tid;
+ return dtid ? dtid->name : NULL;
+#else
+ return NULL;
+#endif
+}
+
+
ErlDrvTid
erl_drv_thread_self(void)
{
--
cgit v1.2.3
From a209817dd8467a04be869541e7c31216dc4b0a12 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn-Egil=20Dahlberg?=
Date: Tue, 3 Sep 2013 17:11:24 +0200
Subject: erts: Document erl_driver interface lock names
---
erts/doc/src/erl_driver.xml | 78 ++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 77 insertions(+), 1 deletion(-)
(limited to 'erts')
diff --git a/erts/doc/src/erl_driver.xml b/erts/doc/src/erl_driver.xml
index efe0483b31..5cf0d2f47f 100644
--- a/erts/doc/src/erl_driver.xml
+++ b/erts/doc/src/erl_driver.xml
@@ -2889,8 +2889,84 @@ ERL_DRV_EXT2TERM char *buf, ErlDrvUInt len
beginning of this document.
-
+
+ char *erl_drv_cond_name(ErlDrvCond *cnd)
+ Get name of driver mutex.
+
+
+ Arguments:
+
+ cnd
+ - A pointer to an initialized condition.
+
+
+ Returns a pointer to the name of the condition.
+
+
+ This function is intended for debugging purposes only.
+
+
+
+
+
+ char *erl_drv_mutex_name(ErlDrvMutex *mtx)
+ Get name of driver mutex.
+
+
+ Arguments:
+
+ mtx
+ - A pointer to an initialized mutex.
+
+
+ Returns a pointer to the name of the mutex.
+
+
+ This function is intended for debugging purposes only.
+
+
+
+
+
+ char *erl_drv_rwlock_name(ErlDrvRWLock *rwlck)
+ Get name of driver mutex.
+
+
+ Arguments:
+
+ rwlck
+ - A pointer to an initialized r/w-lock.
+
+
+ Returns a pointer to the name of the r/w-lock.
+
+
+ This function is intended for debugging purposes only.
+
+
+
+
+
+ char *erl_drv_thread_name(ErlDrvTid tid)
+ Get name of driver mutex.
+
+
+ Arguments:
+
+ tid
+ - A thread identifier.
+
+
+ Returns a pointer to the name of the thread.
+
+
+ This function is intended for debugging purposes only.
+
+
+
+
+
SEE ALSO
driver_entry(3),
--
cgit v1.2.3