Limit the maximum number of threads on stream 0 to 1 again as stream 1 data always appear after a chunk of stream 0 data.

This commit is contained in:
Con Kolivas 2011-02-09 10:45:03 +11:00
parent 8ee9ef64f5
commit 0b0f6db606
2 changed files with 9 additions and 5 deletions

1
rzip.h
View file

@ -278,6 +278,7 @@ struct stream {
long uthread_no; long uthread_no;
long unext_thread; long unext_thread;
long base_thread; long base_thread;
int total_threads;
}; };
struct stream_info { struct stream_info {

View file

@ -843,7 +843,7 @@ void *open_stream_in(int f, int n)
if (unlikely(!sinfo)) if (unlikely(!sinfo))
return NULL; return NULL;
total_threads = control.threads * 2; total_threads = control.threads + 1;
threads = calloc(sizeof(pthread_t), total_threads); threads = calloc(sizeof(pthread_t), total_threads);
if (unlikely(!threads)) if (unlikely(!threads))
return NULL; return NULL;
@ -867,11 +867,14 @@ void *open_stream_in(int f, int n)
return NULL; return NULL;
} }
sinfo->s[0].total_threads = 1;
sinfo->s[1].total_threads = control.threads;
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
uchar c; uchar c;
i64 v1, v2; i64 v1, v2;
sinfo->s[i].base_thread = control.threads * i; sinfo->s[i].base_thread = i;
sinfo->s[i].uthread_no = sinfo->s[i].base_thread; sinfo->s[i].uthread_no = sinfo->s[i].base_thread;
sinfo->s[i].unext_thread = sinfo->s[i].base_thread; sinfo->s[i].unext_thread = sinfo->s[i].base_thread;
@ -1202,7 +1205,7 @@ fill_another:
s->uthread_no, c_len, stream); s->uthread_no, c_len, stream);
create_pthread(&threads[s->uthread_no], NULL, ucompthread, (void *)s->uthread_no); create_pthread(&threads[s->uthread_no], NULL, ucompthread, (void *)s->uthread_no);
if (++s->uthread_no == s->base_thread + control.threads) if (++s->uthread_no == s->base_thread + s->total_threads)
s->uthread_no = s->base_thread; s->uthread_no = s->base_thread;
/* Reached the end of this stream, no more data to read in, otherwise /* Reached the end of this stream, no more data to read in, otherwise
@ -1217,7 +1220,7 @@ fill_another:
goto fill_different_stream; goto fill_different_stream;
} }
if (s->uthread_no != s->unext_thread && if (s->uthread_no != s->unext_thread &&
!ucthread[s->uthread_no].busy && threads_busy < control.threads) !ucthread[s->uthread_no].busy && threads_busy < s->total_threads)
goto fill_another; goto fill_another;
out: out:
s = ret_s; s = ret_s;
@ -1240,7 +1243,7 @@ out:
* ucompthread, we reset it regardless. */ * ucompthread, we reset it regardless. */
init_sem(&ucthread[s->unext_thread].ready); init_sem(&ucthread[s->unext_thread].ready);
if (++s->unext_thread == s->base_thread + control.threads) if (++s->unext_thread == s->base_thread + s->total_threads)
s->unext_thread = s->base_thread; s->unext_thread = s->base_thread;
return 0; return 0;