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

19
visor.c
View file

@ -99,17 +99,16 @@ void draw_mandelbrot(struct threadInfo *info)
for (int i = a; i < b; i++) {
double yRange = (double) i / h * 2.0 - 1.0;
double y = centerY+yRange*scale;
for (int j = 0; j < w; j++) {
pthread_mutex_lock(&pixmapMutex);
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_lock(&pixmapMutex);
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);
for (int j = 0; j < w; j++) {
double xRange = (double) j / w * 2.0 - 1.0;
double x = centerX+xRange*scale;