Forráskód Böngészése

The global "tag table" is protected with a RW-lock too.

Cédric Augonnet 16 éve
szülő
commit
520407c4be
3 módosított fájl, 5 hozzáadás és 14 törlés
  1. 5 10
      src/core/dependencies/tags.c
  2. 0 2
      src/core/dependencies/tags.h
  3. 0 2
      src/core/workers.c

+ 5 - 10
src/core/dependencies/tags.c

@@ -24,12 +24,7 @@
 #include <starpu.h>
 
 static htbl_node_t *tag_htbl = NULL;
-static pthread_spinlock_t tag_mutex;
-
-void initialize_tag_mutex(void)
-{
-	pthread_spin_init(&tag_mutex, 0);
-}
+static pthread_rwlock_t tag_global_rwlock = PTHREAD_RWLOCK_INITIALIZER;
 
 static cg_t *create_cg(unsigned ntags, struct tag_s *tag, unsigned is_apps_cg)
 {
@@ -88,11 +83,11 @@ void starpu_tag_remove(starpu_tag_t id)
 {
 	struct tag_s *tag;
 
-	pthread_spin_lock(&tag_mutex);
+	pthread_rwlock_wrlock(&tag_global_rwlock);
 
 	tag = htbl_remove_tag(tag_htbl, id);
 
-	pthread_spin_unlock(&tag_mutex);
+	pthread_rwlock_unlock(&tag_global_rwlock);
 
 	pthread_spin_lock(&tag->lock);
 	
@@ -108,7 +103,7 @@ void starpu_tag_remove(starpu_tag_t id)
 
 static struct tag_s *gettag_struct(starpu_tag_t id)
 {
-	pthread_spin_lock(&tag_mutex);
+	pthread_rwlock_wrlock(&tag_global_rwlock);
 
 	/* search if the tag is already declared or not */
 	struct tag_s *tag;
@@ -124,7 +119,7 @@ static struct tag_s *gettag_struct(starpu_tag_t id)
 		STARPU_ASSERT(old == NULL);
 	}
 
-	pthread_spin_unlock(&tag_mutex);
+	pthread_rwlock_unlock(&tag_global_rwlock);
 
 	return tag;
 }

+ 0 - 2
src/core/dependencies/tags.h

@@ -85,8 +85,6 @@ typedef struct _cg_t {
 	pthread_cond_t cg_cond;
 } cg_t;
 
-void initialize_tag_mutex(void);
-
 void starpu_tag_declare_deps(starpu_tag_t id, unsigned ndeps, ...);
 
 void notify_dependencies(struct job_s *j);

+ 0 - 2
src/core/workers.c

@@ -151,8 +151,6 @@ void starpu_init(struct starpu_conf *user_conf)
 
 	starpu_build_topology(&config, user_conf);
 
-	initialize_tag_mutex();
-
 	/* initialize the scheduler */
 
 	/* initialize the queue containing the jobs */