All pastes #437205 Raw Edit

Stuff

public c v1 · immutable
·published 2007-04-12 22:33 UTC
rendered paste body
// Create Threads (interleaved reader/writer/reader/wr... etc.)        int rC = 0;                     // reader thread count        int wC = 0;                     // writer thread count        while ((rC + wC) < (readers + writers))        {                if ((rC + wC) % 2 == C_CREATE_READ)                {                        pthread_create(&threads[rC], NULL, trreader, NULL);                        rC++;                }                else if((rC + wC) % 2 == C_CREATE_WRITE)                {                        int pos = readers + wC;                        pthread_create(&threads[pos], NULL, trwriter, NULL);                        wC++;                }        }