163 |
unsigned char *pDataBitmap, *pDataBitmapCurrent; |
unsigned char *pDataBitmap, *pDataBitmapCurrent; |
164 |
|
|
165 |
// workers |
// workers |
166 |
int workers = 10; |
int workers = 5; |
167 |
int worker_index, worker_rows, worker_startrow; |
int worker_index, worker_rows, worker_startrow; |
168 |
HANDLE *worker_handles; |
HANDLE *worker_handles; |
169 |
//struct WorkerArguments *worker_args; |
//struct WorkerArguments *worker_args; |
217 |
if ((worker_handles = malloc(workers * sizeof worker_handles[0])) == NULL) |
if ((worker_handles = malloc(workers * sizeof worker_handles[0])) == NULL) |
218 |
perror("malloc"), exit(1); |
perror("malloc"), exit(1); |
219 |
|
|
|
/* |
|
220 |
// allocate memory for table of all worker arguments |
// allocate memory for table of all worker arguments |
221 |
if ((worker_args = malloc(workers * sizeof worker_args[0])) == NULL) |
if ((worker_args = malloc(workers * sizeof worker_args[0])) == NULL) |
222 |
perror("malloc"), exit(1); |
perror("malloc"), exit(1); |
223 |
*/ |
|
224 |
// allocate memory for table of all worker arguments |
// allocate memory for table of all worker arguments |
225 |
worker_args = (PWORKERARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, workers * sizeof(WORKERARGS)); |
/* |
226 |
|
worker_args = (PWORKERARGS) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, workers * sizeof(WORKERARGS)); |
227 |
|
|
228 |
|
if (worker_args == NULL) { |
229 |
|
printErrorAndExit("Failed to allocate on heap", GetLastError()); |
230 |
|
} |
231 |
|
*/ |
232 |
|
|
233 |
// calculate segments of bitmap for worker threads/processes and start them |
// calculate segments of bitmap for worker threads/processes and start them |
234 |
worker_rows = YSIZE / workers; |
worker_rows = YSIZE / workers; |
294 |
printErrorAndExit("Error at CloseHandle", err); |
printErrorAndExit("Error at CloseHandle", err); |
295 |
} |
} |
296 |
|
|
297 |
|
/* |
298 |
|
if (HeapFree(GetProcessHeap(), HEAP_ZERO_MEMORY | HEAP_NO_SERIALIZE, worker_args) != TRUE) { |
299 |
|
printErrorAndExit("Call to HeapFree has failed", GetLastError()); |
300 |
|
} |
301 |
|
*/ |
302 |
|
|
303 |
|
|
304 |
|
return 0; |
305 |
|
|
306 |
} |
} |