Make polling by workers rarer
Previously workers would poll for the availability of the drawing board after every drawn pixel. Now they do it after every line, which was originally the plan.
This commit is contained in:
parent
9b19884286
commit
270c00cefc
1 changed files with 9 additions and 10 deletions
19
visor.c
19
visor.c
|
@ -99,17 +99,16 @@ void draw_mandelbrot(struct threadInfo *info)
|
||||||
for (int i = a; i < b; i++) {
|
for (int i = a; i < b; i++) {
|
||||||
double yRange = (double) i / h * 2.0 - 1.0;
|
double yRange = (double) i / h * 2.0 - 1.0;
|
||||||
double y = centerY+yRange*scale;
|
double y = centerY+yRange*scale;
|
||||||
for (int j = 0; j < w; j++) {
|
pthread_mutex_lock(&pixmapMutex);
|
||||||
pthread_mutex_lock(&pixmapMutex);
|
if (!pixmapAvailable) {
|
||||||
if (!pixmapAvailable) {
|
|
||||||
pthread_mutex_unlock(&pixmapMutex);
|
|
||||||
return;
|
|
||||||
// after this, the thread will again enter the
|
|
||||||
// loop in the writer_thread function, and
|
|
||||||
// enter a wait state
|
|
||||||
}
|
|
||||||
pthread_mutex_unlock(&pixmapMutex);
|
pthread_mutex_unlock(&pixmapMutex);
|
||||||
|
return;
|
||||||
|
// after this, the thread will again enter the
|
||||||
|
// loop in the writer_thread function, and
|
||||||
|
// enter a wait state
|
||||||
|
}
|
||||||
|
pthread_mutex_unlock(&pixmapMutex);
|
||||||
|
for (int j = 0; j < w; j++) {
|
||||||
double xRange = (double) j / w * 2.0 - 1.0;
|
double xRange = (double) j / w * 2.0 - 1.0;
|
||||||
double x = centerX+xRange*scale;
|
double x = centerX+xRange*scale;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue