rwlock allows for parallel execution of get_cu_from_native_addr().
Signed-off-by: Tomek Grabiec <[email protected]>
---
jit/cu-mapping.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/jit/cu-mapping.c b/jit/cu-mapping.c
index 7c13e13..5e59ee3 100644
--- a/jit/cu-mapping.c
+++ b/jit/cu-mapping.c
@@ -41,7 +41,7 @@
* is fast.
*/
struct radix_tree *cu_map;
-pthread_mutex_t cu_map_mutex = PTHREAD_MUTEX_INITIALIZER;
+pthread_rwlock_t cu_map_rwlock = PTHREAD_RWLOCK_INITIALIZER;
#define BITS_PER_LEVEL 6
@@ -69,18 +69,18 @@ int add_cu_mapping(struct compilation_unit *cu)
{
int result;
- pthread_mutex_lock(&cu_map_mutex);
+ pthread_rwlock_wrlock(&cu_map_rwlock);
result = radix_tree_insert(cu_map, cu_key(cu), cu);
- pthread_mutex_unlock(&cu_map_mutex);
+ pthread_rwlock_unlock(&cu_map_rwlock);
return result;
}
void remove_cu_mapping(struct compilation_unit *cu)
{
- pthread_mutex_lock(&cu_map_mutex);
+ pthread_rwlock_wrlock(&cu_map_rwlock);
radix_tree_remove(cu_map, cu_key(cu));
- pthread_mutex_unlock(&cu_map_mutex);
+ pthread_rwlock_unlock(&cu_map_rwlock);
}
struct compilation_unit *get_cu_from_native_addr(unsigned long addr)
@@ -88,9 +88,9 @@ struct compilation_unit *get_cu_from_native_addr(unsigned
long addr)
struct compilation_unit *cu;
unsigned long method_addr;
- pthread_mutex_lock(&cu_map_mutex);
+ pthread_rwlock_rdlock(&cu_map_rwlock);
cu = radix_tree_lookup_prev(cu_map, addr_key(addr));
- pthread_mutex_unlock(&cu_map_mutex);
+ pthread_rwlock_unlock(&cu_map_rwlock);
if (cu == NULL)
return NULL;
--
1.6.0.6
------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, &
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com
_______________________________________________
Jatovm-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jatovm-devel