IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Oct 4, 2011, 12:15:49 PM (15 years ago)
Author:
bills
Message:

Per suggestion from Paul Price. Declare pending and done pointers volatile since they can
be changed by multiple threads.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psThread.c

    r28405 r32481  
    3636static pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER; // Mutex for locking threads
    3737
    38 static psList *pending = NULL;          // queue of pending jobs
    39 static psList *done = NULL;             // queue of done jobs
     38static volatile psList *pending = NULL; // queue of pending jobs
     39static volatile psList *done = NULL;    // queue of done jobs
    4040static pthread_t *threads = NULL;       // array of the POSIX thread handles
    4141static psArray *pool = NULL;            // array of defined threads
     
    116116            done = psListAlloc(NULL);
    117117        }
    118         psListAdd(done, PS_LIST_TAIL, job);
     118        psListAdd((psList *)done, PS_LIST_TAIL, job);
    119119        psFree(job);
    120120        return task->function(job);
     
    125125        pending = psListAlloc(NULL);
    126126    }
    127     psListAdd(pending, PS_LIST_TAIL, job);
     127    psListAdd((psList *)pending, PS_LIST_TAIL, job);
    128128    psFree(job);
    129129    psThreadUnlock();
     
    139139    }
    140140
    141     psThreadJob *job = psListGetAndRemove(pending, PS_LIST_HEAD);
     141    psThreadJob *job = psListGetAndRemove((psList *)pending, PS_LIST_HEAD);
    142142    return job;
    143143}
     
    150150    }
    151151
    152     psThreadJob *job = psListGetAndRemove(done, PS_LIST_HEAD);
     152    psThreadJob *job = psListGetAndRemove((psList *) done, PS_LIST_HEAD);
    153153    return job;
    154154}
     
    253253            done = psListAlloc(NULL);
    254254        }
    255         psListAdd(done, PS_LIST_TAIL, job);
     255        psListAdd((psList *)done, PS_LIST_TAIL, job);
    256256        psFree(job);
    257257
Note: See TracChangeset for help on using the changeset viewer.