| 102 |
LPVOID pData; |
LPVOID pData; |
| 103 |
unsigned char *pDataBitmap, *pDataBitmapCurrent; |
unsigned char *pDataBitmap, *pDataBitmapCurrent; |
| 104 |
|
|
| 105 |
|
// workers |
| 106 |
|
unsigned int workers = 3; |
| 107 |
|
unsigned int worker_index, worker_rows, worker_startrow; |
| 108 |
|
|
| 109 |
// fractal calculation |
// fractal calculation |
| 110 |
int x, y; |
int x, y; |
| 111 |
char bgr[3]; |
char bgr[3]; |
| 153 |
} |
} |
| 154 |
*/ |
*/ |
| 155 |
|
|
| 156 |
|
// calculate segments of bitmap for worker threads/processes |
| 157 |
|
worker_rows = YSIZE / workers; |
| 158 |
|
printf("rows for each worker: %i\n", worker_rows); |
| 159 |
|
for (worker_index = 0; worker_index < workers; worker_index++) { |
| 160 |
|
|
| 161 |
|
// number of row to start for each worker |
| 162 |
|
worker_startrow = worker_index * worker_rows; |
| 163 |
|
|
| 164 |
|
// recalculate number of rows for last worker if (YSIZE mod workers) != 0 |
| 165 |
|
if (worker_index == workers - 1) { |
| 166 |
|
worker_rows = YSIZE - worker_startrow; |
| 167 |
|
printf("rows for last worker: %i\n", worker_rows); |
| 168 |
|
} |
| 169 |
|
} |
| 170 |
|
|
| 171 |
// calculate fractal |
// calculate fractal |
| 172 |
for (y=YSIZE-1; y>=0; y--) { |
for (y=YSIZE-1; y>=0; y--) { |
| 173 |
for (x=0; x<XSIZE; x++) { |
for (x=0; x<XSIZE; x++) { |