39 #ifdef EXECUTE_THREADED
79 static n_int global_cycle = 1;
80 static n_int execution_cycle = 0;
85 static HANDLE *thread = 0L;
86 static DWORD *threadId = 0L;
90 static pthread_t *thread = 0L;
96 static n_int execution_thread_size = 4;
98 static void execute_wait_ns(
void)
104 struct timespec tim, tim2;
107 (void)nanosleep(&tim , &tim2);
112 static void execute_add_generic(
execute_function *
function,
void * general_data,
void * read_data,
void * write_data,
n_int count,
n_int size)
114 #ifndef EXECUTE_THREADED
121 if (
function(general_data, (
void *)&location[loop * size], 0L) == -1)
130 function(general_data,read_data,write_data);
136 while (loop < execution_thread_size)
138 if (execution[loop].state ==
ES_DONE)
145 new_object->
count = count;
146 new_object->
size = size;
147 execution[loop].
executed = new_object;
154 }
while (global_cycle);
160 execute_add_generic(
function, general_data, read_data, write_data, 1, 0);
165 execute_add_generic(
function, general_data, read_data, 0L, count, size);
170 #ifdef EXECUTE_THREADED
173 if (execution_cycle == 0)
182 #ifdef EXECUTE_THREADED
187 while (loop < execution_thread_size)
189 CloseHandle(thread[loop]);
199 #ifdef EXECUTE_THREADED
200 execution_thread_size = value;
208 #ifdef EXECUTE_THREADED
209 return execution_thread_size;
215 #ifdef EXECUTE_THREADED
217 static void execute_thread_generic(
void *
id)
239 while (loop < object->count)
260 while (loop < execution_thread_size)
262 if (execution[loop].state !=
ES_DONE)
273 }
while (global_cycle);
279 static DWORD WINAPI execute_thread_win( LPVOID lpParam )
282 hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
283 if( hStdout == INVALID_HANDLE_VALUE )
285 execute_thread_generic((
void *)lpParam);
291 static void * execute_thread_posix(
void *
id)
293 execute_thread_generic(
id);
302 #ifdef EXECUTE_THREADED
304 n_byte2 master_random[2] = {0xf672, 0x3e71};
308 thread = (HANDLE*)
io_new(execution_thread_size *
sizeof(HANDLE));
310 thread = (pthread_t*)
io_new(execution_thread_size *
sizeof(pthread_t));
315 (void)
SHOW_ERROR(
"Threads failed to allocate");
320 threadId = (DWORD*)
io_new(execution_thread_size *
sizeof(DWORD));
324 (void)
SHOW_ERROR(
"ThreadIds failed to allocate");
337 (void)
SHOW_ERROR(
"Execution thread failed to allocate");
341 io_erase((
n_byte*)thread, execution_thread_size *
sizeof(HANDLE));
342 io_erase((
n_byte*)threadId, execution_thread_size *
sizeof(DWORD));
344 io_erase((
n_byte*)thread, execution_thread_size *
sizeof(pthread_t));
348 while (loop < execution_thread_size)
350 execution[loop].
random[0] = master_random[1];
351 execution[loop].
random[1] = master_random[0];
356 threadId[loop] = loop;
357 thread[loop] = CreateThread(NULL, 0, execute_thread_win, &execution[loop], 0, &threadId[loop]);
359 pthread_create(&thread[loop], 0L, execute_thread_posix, &execution[loop]);