Skip to content

Commit

Permalink
Remove volatile in yarn.c.
Browse files Browse the repository at this point in the history
A user indicated that volatile was needed for the threads global in
yarn.c for an HP system.  If that is the case, then there is a bug
in the HP pthread library.  Testing by other users suggested that
there is not a bug.  In any case, pigz will not try to work around
such bugs with volatile, since volatile in general won't solve such
problems anyway.
  • Loading branch information
madler committed Jan 7, 2012
1 parent 72a6b3e commit 91f06f9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
2 changes: 1 addition & 1 deletion pigz.c
Expand Up @@ -130,7 +130,7 @@
Add --rsyncable functionality
2.2.1 1 Jan 2012 Fix bug in --rsyncable buffer management
2.2.2 1 Jan 2012 Fix another bug in --rsyncable buffer management
2.2.3 xx Jan 2012 -
2.2.3 xx Jan 2012 Remove volatile in yarn.c
*/

#define VERSION "pigz 2.2.3\n"
Expand Down
17 changes: 8 additions & 9 deletions yarn.c
@@ -1,6 +1,6 @@
/* yarn.c -- generic thread operations implemented using pthread functions
* Copyright (C) 2008, 2011 Mark Adler
* Version 1.2 19 Dec 2011 Mark Adler
* Copyright (C) 2008 Mark Adler
* Version 1.1 26 Oct 2008 Mark Adler
* For conditions of distribution and use, see copyright notice in yarn.h
*/

Expand All @@ -13,7 +13,6 @@
1.0 19 Oct 2008 First version
1.1 26 Oct 2008 No need to set the stack size -- remove
Add yarn_abort() function for clean-up on error exit
1.2 19 Dec 2011 Make the "threads" list head global variable volatile
*/

/* for thread portability */
Expand Down Expand Up @@ -186,7 +185,7 @@ local lock threads_lock = {
PTHREAD_COND_INITIALIZER,
0 /* number of threads exited but not joined */
};
local volatile thread *threads = NULL; /* list of extant threads */
local thread *threads = NULL; /* list of extant threads */

/* structure in which to pass the probe and its payload to ignition() */
struct capsule {
Expand All @@ -205,7 +204,7 @@ local void reenter(void *dummy)
/* find this thread in the threads list by matching the thread id */
me = pthread_self();
possess(&(threads_lock));
prior = (thread **)&(threads);
prior = &(threads);
while ((match = *prior) != NULL) {
if (pthread_equal(match->id, me))
break;
Expand All @@ -218,7 +217,7 @@ local void reenter(void *dummy)
match->done = 1;
if (threads != match) {
*prior = match->next;
match->next = (thread *)threads;
match->next = threads;
threads = match;
}

Expand Down Expand Up @@ -279,7 +278,7 @@ thread *launch(void (*probe)(void *), void *payload)

/* put the thread in the threads list for join_all() */
th->done = 0;
th->next = (thread *)threads;
th->next = threads;
threads = th;
release(&(threads_lock));
return th;
Expand All @@ -296,7 +295,7 @@ void join(thread *ally)

/* find the thread in the threads list */
possess(&(threads_lock));
prior = (thread **)&(threads);
prior = &(threads);
while ((match = *prior) != NULL) {
if (match == ally)
break;
Expand Down Expand Up @@ -332,7 +331,7 @@ int join_all(void)
wait_for(&(threads_lock), NOT_TO_BE, 0);

/* find the first thread marked done (should be at or near the top) */
prior = (thread **)&(threads);
prior = &(threads);
while ((match = *prior) != NULL) {
if (match->done)
break;
Expand Down
4 changes: 2 additions & 2 deletions yarn.h
@@ -1,6 +1,6 @@
/* yarn.h -- generic interface for thread operations
* Copyright (C) 2008, 2011 Mark Adler
* Version 1.2 19 Dec 2011 Mark Adler
* Copyright (C) 2008 Mark Adler
* Version 1.1 26 Oct 2008 Mark Adler
*/

/*
Expand Down

0 comments on commit 91f06f9

Please sign in to comment.