|
@@ -15,10 +15,11 @@
|
|
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
|
|
* See the GNU Lesser General Public License in COPYING.LGPL for more details.
|
|
*/
|
|
*/
|
|
|
|
|
|
-#include "starpu_top_message_queue.h"
|
|
|
|
-#include <string.h>
|
|
|
|
-#include <stdio.h>
|
|
|
|
-#include <stdlib.h>
|
|
|
|
|
|
+#include "starpu_top_message_queue.h"
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <common/utils.h>
|
|
|
|
|
|
//this global queue is used both by API and by network threads
|
|
//this global queue is used both by API and by network threads
|
|
struct _starpu_top_message_queue* _starpu_top_mt = NULL;
|
|
struct _starpu_top_message_queue* _starpu_top_mt = NULL;
|
|
@@ -29,11 +30,11 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
|
|
char* msg)
|
|
char* msg)
|
|
{
|
|
{
|
|
struct _starpu_top_message_queue_item* p = (struct _starpu_top_message_queue_item *) malloc( 1 * sizeof(*p) );
|
|
struct _starpu_top_message_queue_item* p = (struct _starpu_top_message_queue_item *) malloc( 1 * sizeof(*p) );
|
|
- pthread_mutex_lock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
|
|
if( NULL == p )
|
|
if( NULL == p )
|
|
{
|
|
{
|
|
fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
|
|
fprintf(stderr, "IN %s, %s: malloc() failed\n", __FILE__, "list_add");
|
|
- pthread_mutex_unlock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -43,7 +44,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
|
|
if( NULL == s )
|
|
if( NULL == s )
|
|
{
|
|
{
|
|
printf("Queue not initialized\n");
|
|
printf("Queue not initialized\n");
|
|
- pthread_mutex_unlock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
else if( NULL == s->head && NULL == s->tail )
|
|
else if( NULL == s->head && NULL == s->tail )
|
|
@@ -51,7 +52,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
|
|
/* printf("Empty list, adding p->num: %d\n\n", p->num); */
|
|
/* printf("Empty list, adding p->num: %d\n\n", p->num); */
|
|
sem_post(&(s->semaphore));
|
|
sem_post(&(s->semaphore));
|
|
s->head = s->tail = p;
|
|
s->head = s->tail = p;
|
|
- pthread_mutex_unlock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
else
|
|
else
|
|
@@ -61,7 +62,7 @@ struct _starpu_top_message_queue* _starpu_top_message_add(struct _starpu_top_mes
|
|
s->tail->next = p;
|
|
s->tail->next = p;
|
|
s->tail = p;
|
|
s->tail = p;
|
|
}
|
|
}
|
|
- pthread_mutex_unlock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
|
|
return s;
|
|
return s;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -77,7 +78,7 @@ char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
|
|
printf("List is null\n");
|
|
printf("List is null\n");
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
- pthread_mutex_lock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_LOCK(&(s->mutex));
|
|
h = s->head;
|
|
h = s->head;
|
|
p = h->next;
|
|
p = h->next;
|
|
char* value = h->message;
|
|
char* value = h->message;
|
|
@@ -88,7 +89,7 @@ char* _starpu_top_message_remove(struct _starpu_top_message_queue* s)
|
|
if( NULL == s->head )
|
|
if( NULL == s->head )
|
|
//the element tail was pointing to is free(), so we need an update
|
|
//the element tail was pointing to is free(), so we need an update
|
|
s->tail = s->head;
|
|
s->tail = s->head;
|
|
- pthread_mutex_unlock(&(s->mutex));
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_UNLOCK(&(s->mutex));
|
|
return value;
|
|
return value;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -104,6 +105,6 @@ struct _starpu_top_message_queue* _starpu_top_message_queue_new(void)
|
|
|
|
|
|
p->head = p->tail = NULL;
|
|
p->head = p->tail = NULL;
|
|
sem_init(&(p->semaphore),0,0);
|
|
sem_init(&(p->semaphore),0,0);
|
|
- pthread_mutex_init(&(p->mutex), NULL);
|
|
|
|
|
|
+ _STARPU_PTHREAD_MUTEX_INIT(&(p->mutex), NULL);
|
|
return p;
|
|
return p;
|
|
}
|
|
}
|