--- joko/Uni/BSArch/04/bmp_fractal.c 2006/07/01 11:58:49 1.4 +++ joko/Uni/BSArch/04/bmp_fractal.c 2006/07/01 12:19:46 1.5 @@ -5,7 +5,7 @@ * Uebung 4.4 */ -// $Id: bmp_fractal.c,v 1.4 2006/07/01 11:58:49 joko Exp $ +// $Id: bmp_fractal.c,v 1.5 2006/07/01 12:19:46 joko Exp $ #include #include @@ -102,6 +102,10 @@ LPVOID pData; unsigned char *pDataBitmap, *pDataBitmapCurrent; + // workers + unsigned int workers = 3; + unsigned int worker_index, worker_rows, worker_startrow; + // fractal calculation int x, y; char bgr[3]; @@ -149,6 +153,21 @@ } */ + // calculate segments of bitmap for worker threads/processes + worker_rows = YSIZE / workers; + printf("rows for each worker: %i\n", worker_rows); + for (worker_index = 0; worker_index < workers; worker_index++) { + + // number of row to start for each worker + worker_startrow = worker_index * worker_rows; + + // recalculate number of rows for last worker if (YSIZE mod workers) != 0 + if (worker_index == workers - 1) { + worker_rows = YSIZE - worker_startrow; + printf("rows for last worker: %i\n", worker_rows); + } + } + // calculate fractal for (y=YSIZE-1; y>=0; y--) { for (x=0; x