Re: [PATCH 0/3] more threaded delta patches

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Sep 10, 2007 at 02:40:50AM -0400, Jeff King wrote:

> So your locking scheme doesn't work, because signaling a thread with
> "ready" doesn't necessarily mean you're getting the same thread that you
> just gave data to. I think you could do it with another signal from the
> requesting thread to the provider that says "I got the work you
> assigned". The provider would wait on that mutex before allowing the
> next request.

And here's a patch implementing that. It seems to clear up the problem I
was having.

---
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 42698d2..76334c7 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1586,6 +1586,7 @@ struct thread_params {
 static pthread_mutex_t data_request  = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t data_ready    = PTHREAD_MUTEX_INITIALIZER;
 static pthread_mutex_t data_provider = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t data_acquired = PTHREAD_MUTEX_INITIALIZER;
 static struct thread_params *data_requester;
 
 static void *threaded_find_deltas(void *arg)
@@ -1597,6 +1598,7 @@ static void *threaded_find_deltas(void *arg)
 		data_requester = me;
 		pthread_mutex_unlock(&data_provider);
 		pthread_mutex_lock(&data_ready);
+		pthread_mutex_unlock(&data_acquired);
 
 		if (!me->list_size)
 			return NULL;
@@ -1648,6 +1650,7 @@ static void ll_find_deltas(struct object_entry **list, unsigned list_size,
 		data_requester->list = list;
 		data_requester->list_size = sublist_size;
 		pthread_mutex_unlock(&data_ready);
+		pthread_mutex_lock(&data_acquired);
 
 		list += sublist_size;
 		list_size -= sublist_size;
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux