From 270c00cefc3392781170e52dfa61b39ae8cb15d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petar=20Kapri=C5=A1?= Date: Mon, 13 Oct 2025 21:01:47 +0200 Subject: [PATCH] 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. --- visor.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/visor.c b/visor.c index b882987..3bf4951 100644 --- a/visor.c +++ b/visor.c @@ -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;