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:
Petar Kapriš 2025-10-13 21:01:47 +02:00
parent 9b19884286
commit 270c00cefc

View file

@ -99,7 +99,6 @@ 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); pthread_mutex_unlock(&pixmapMutex);
@ -109,7 +108,7 @@ void draw_mandelbrot(struct threadInfo *info)
// enter a wait state // enter a wait state
} }
pthread_mutex_unlock(&pixmapMutex); 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;