From: Nicholas Nethercote Date: Tue, 27 Sep 2005 20:28:00 +0000 (+0000) Subject: Remove ancient unused test files. X-Git-Tag: svn/VALGRIND_3_1_0~433 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f339e45fe3f51c2bb4842df89513aeaff9ee0bfe;p=thirdparty%2Fvalgrind.git Remove ancient unused test files. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4795 --- diff --git a/configure.in b/configure.in index 6f20474ff9..07ed51635e 100644 --- a/configure.in +++ b/configure.in @@ -462,7 +462,6 @@ AC_OUTPUT( docs/xml/Makefile tests/Makefile tests/vg_regtest - tests/unused/Makefile include/Makefile auxprogs/Makefile coregrind/Makefile diff --git a/tests/Makefile.am b/tests/Makefile.am index 8897d822be..4b2e2f5a5d 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,6 +1,4 @@ -SUBDIRS = . unused - noinst_SCRIPTS = \ vg_regtest \ filter_addresses \ diff --git a/tests/unused/Makefile.am b/tests/unused/Makefile.am deleted file mode 100644 index 3124b062f2..0000000000 --- a/tests/unused/Makefile.am +++ /dev/null @@ -1,20 +0,0 @@ - -EXTRA_DIST = \ - oneparam.c \ - pth_signal2.c \ - pth_threadpool.c \ - pth_cancel1.c \ - pth_pause.c \ - pth_semaphore1.c \ - pth_signal_gober.c \ - pth_signal1.c \ - pth_sigpending.c \ - pth_simple_mutex.c \ - pth_simple_threads.c \ - pth_yield.c \ - signal1.c \ - signal3.c \ - sigwait_all.c \ - twoparams.c \ - twoparams.s \ - blocked_syscall.c diff --git a/tests/unused/blocked_syscall.c b/tests/unused/blocked_syscall.c deleted file mode 100644 index 53af388f03..0000000000 --- a/tests/unused/blocked_syscall.c +++ /dev/null @@ -1,32 +0,0 @@ - -#include -#include -#include -#include - -int fds[2]; - -void the_sighandler ( int signo ) -{ - int nw; - // assert(signo == SIGUSR1); - printf("sighandler running; should unblock now\n"); - nw = write(fds[1], "zzz", 1); - // assert(nw == 1); -} - -int main ( void ) -{ - char buf[10]; - int res, nr; - void* oldsh = signal(SIGUSR1, the_sighandler); - assert(oldsh != SIG_ERR); - printf("pid = %d\n", getpid()); - res = pipe(fds); - assert (res == 0); - printf("doing read(); this should block\n"); - nr = read(fds[0], buf, 1); - /* blocks */ - printf("read returned %d\n", nr); - return 0; -} diff --git a/tests/unused/oneparam.c b/tests/unused/oneparam.c deleted file mode 100644 index 648e304b40..0000000000 --- a/tests/unused/oneparam.c +++ /dev/null @@ -1,10 +0,0 @@ - -/* general simple function to use as a template for assembly hacks */ - -void fooble ( int* a ) -{ - a[0] = 33; - a[1] = 44; - a[2] = 55; - a[3] = 66; -} diff --git a/tests/unused/pth_cancel1.c b/tests/unused/pth_cancel1.c deleted file mode 100644 index 62047395b5..0000000000 --- a/tests/unused/pth_cancel1.c +++ /dev/null @@ -1,274 +0,0 @@ -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * cancel.c -- - * - * Demonstrates pthread cancellation. - * - */ - -#include -#include -#include -#include - -#include - -#define NUM_THREADS 3 -#define MESSAGE_MAX_LEN 80 - -int count=NUM_THREADS; /* number of threads active */ -pthread_mutex_t lock=PTHREAD_MUTEX_INITIALIZER; /* mutual exclusion - for count */ -pthread_cond_t init_done=PTHREAD_COND_INITIALIZER; /* signaled by - each thread after - completing initial- - ization */ -int id_arg[3] = {0,1,2}; - -/* - * Cleanup routine: last_breath() - */ -void last_breath(char *messagep) -{ - printf("\n\n%s last_breath() cleanup routine: free'ing %p\n\n", - messagep, messagep); - - free(messagep); -} - -/* - * print_count() - */ -void print_count(char *messagep, int id, int i) -{ - int last_type,tmp_type; - - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &last_type); - switch(id) { - case 0: - printf("%s %4d\n", messagep, i); - break; - case 1: - printf("%s \t%4d\n", messagep, i); - break; - case 2: - printf("%s \t\t%4d\n", messagep, i); - break; - } - pthread_setcanceltype(last_type, &tmp_type); -} - -/* - * bullet_proof() - */ -void *bullet_proof(void *id_p) -{ - int i=0, last_state; - int *my_id = id_p; - char *messagep; - - - messagep = (char *)malloc(MESSAGE_MAX_LEN); - sprintf(messagep, "Bullet Proof, thread #%d: ", *my_id); - - printf("%s\tI'm Alive, setting general cancellation OFF\n", - messagep); - - /* push last_breath() routine onto stack */ - pthread_cleanup_push( (void *)last_breath, (void *)messagep ); - - /* We turn off general cancelability here ... */ - pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &last_state); - - pthread_mutex_lock(&lock); - { - printf("\n%s signaling main that my init is done\n", messagep); - count -= 1; - /* signal to program that entering loop */ - pthread_cond_signal(&init_done); - pthread_mutex_unlock(&lock); - } - - /* loop forever until picked off with a cancel */ - for(i = 0; i < 10000000; i++) { - if (i%10000 == 0) - print_count(messagep, *my_id, i); - if (i%100000 == 0) { - printf("\n%s This is the thread that never ends... #%d\n", - messagep, i); - } - } - - /* Never get this far */ - - /* This pop is required by the standard, every push must have a pop - in the same lexical block. */ - pthread_cleanup_pop(0); - - return(NULL); -} - -/* - * ask_for_it() - */ -void *ask_for_it(void *id_p) -{ - int i=0, last_state, last_type; - int *my_id = id_p; - char *messagep; - - - messagep = (char *)malloc(MESSAGE_MAX_LEN); - sprintf(messagep, "Ask For It, thread #%d: ", *my_id); - - /* push last_breath() routine onto stack */ - pthread_cleanup_push( (void *)last_breath, (void *)messagep); - - /* We can turn on general cancelability here. Disable async cancellation */ - printf("%s\tI'm Alive, setting deferred cancellation ON\n", - messagep); - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &last_type); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &last_state); - - pthread_mutex_lock(&lock); - { - printf("\n%s signaling main that my init is done\n", messagep); - count -= 1; - /* signal to program that entering loop */ - pthread_cond_signal(&init_done); - pthread_mutex_unlock(&lock); - } - - /* loop forever until picked off with a cancel */ - for(;;i++) { - if (i%10000 == 0) - print_count(messagep, *my_id, i); - if (i%100000 == 0) { - printf("\n%s\t%d Look, I'll tell you when you can cancel me.\n", - messagep, i); - } - pthread_testcancel(); - } - - /* never get this far */ - - /* This pop is required by the standard, every push must have a pop - in the same lexical block. */ - pthread_cleanup_pop(0); - - return(NULL); -} - -/* - * sitting_duck() - */ -void *sitting_duck(void *id_p) -{ - int i=0, last_state, last_type, last_tmp; - int *my_id = id_p; - char *messagep; - - - messagep = (char *)malloc(MESSAGE_MAX_LEN); - sprintf(messagep, "Sitting Duck, thread #%d: ", *my_id); - - /* push last_breath() routine onto stack */ - pthread_cleanup_push( (void *)last_breath, (void *)messagep); - - pthread_mutex_lock(&lock); - { - printf("\n%s signaling main that my init is done\n", messagep); - count -= 1; - /* signal to program that entering loop */ - pthread_cond_signal(&init_done); - pthread_mutex_unlock(&lock); - } - - /* Now, we're safe to turn on async cancellability */ - printf("%s\tI'm Alive, setting async cancellation ON\n", - messagep); - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &last_type); - pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &last_state); - - /* loop forever until picked off with a cancel */ - for(;;i++) { - if (i%1000 == 0) - print_count(messagep, *my_id, i++); - if (i%10000 == 0) { - pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, &last_tmp); - printf("\n%s\tHum, nobody here but us chickens. %d\n", messagep,i); - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &last_tmp); - } - } - - /* never get this far */ - - /* This pop is required by the standard, every push must have a pop - in the same lexical block. */ - pthread_cleanup_pop(0); - - return(NULL); -} - -extern int -main(void) -{ - int i; - void *statusp; - pthread_t threads[NUM_THREADS]; - - - /* spawn the threads */ - pthread_create(&(threads[0]), - NULL, - ask_for_it, - (void *) &(id_arg[0])); - - pthread_create(&(threads[1]), - NULL, - sitting_duck, - (void *) &(id_arg[1])); - - pthread_create(&(threads[2]), - NULL, - bullet_proof, - (void *) &(id_arg[2])); - - printf("main(): %d threads created\n", NUM_THREADS); - - pthread_mutex_lock(&lock); - - /* wait until all threads have entered loops */ - while (count != 0) { - pthread_cond_wait(&init_done, &lock); - } - - pthread_mutex_unlock(&lock); - - printf("main(): all threads have signaled that ready\n"); - - /* cancel each thread */ - for (i=0; i -#include -#include -#include -#include - -void hdlr ( int sig ) -{ - printf("signal %d arrived\n", sig); -} - -int main ( void ) -{ - int res; - /* Force use of libpthread here */ - pthread_testcancel(); - - printf("installing handler\n"); - signal(SIGINT, hdlr); - printf("installing handler done; please do Control-C\n"); - - res = pause(); - printf("pause done; res = %d, errno = %d\n", res, errno); - - printf("bye\n"); - - return 0; -} diff --git a/tests/unused/pth_semaphore1.c b/tests/unused/pth_semaphore1.c deleted file mode 100644 index 17181561e5..0000000000 --- a/tests/unused/pth_semaphore1.c +++ /dev/null @@ -1,70 +0,0 @@ - -/* Dining philosophers, using semaphores. From the Ben-Ari book. */ - -#include -#include -#include -#include - -#define N_PHILOSOPHERS 5 - -sem_t room; -sem_t forc[N_PHILOSOPHERS]; -pthread_t tid[N_PHILOSOPHERS]; - -void eat ( int i ) -{ - printf("%d -> begin eat\n", i); - i += 17; - i *= 10000; - while (i > 0) i--; - printf("%d -> end eat\n", i); -} - -void think ( int i ) -{ - printf("%d -> begin think\n", i); - i += 23; - i *= 9000; - while (i > 0) i--; - printf("%d -> end think\n", i); -} - -void* philosopher ( void* vi ) -{ - int i = (int)vi; - int res; - int rounds; - for (rounds = 0; rounds < 10; rounds++) { - think(i); - res = sem_wait(&room); assert(res == 0); - res = sem_wait(&forc[i]); assert(res == 0); - res = sem_wait(&forc[(i+1) % N_PHILOSOPHERS]); assert(res == 0); - eat(i); - res = sem_post(&forc[i]); assert(res == 0); - res = sem_post(&forc[(i+1) % N_PHILOSOPHERS]); assert(res == 0); - res = sem_post(&room); assert(res == 0); - } - return NULL; -} - -int main ( void ) -{ - int i, res; - - res = sem_init(&room, 0, 4); assert(res == 0); - for (i = 0; i < N_PHILOSOPHERS; i++) { - res = sem_init ( &forc[i], 0, 1 ); - assert(res == 0); - } - - for (i = 0; i < N_PHILOSOPHERS; i++) { - res = pthread_create ( &tid[i], NULL, philosopher, (void*)i ); - assert(res == 0); - } - for (i = 0; i < N_PHILOSOPHERS; i++) { - res = pthread_join ( tid[i], NULL ); - assert(res == 0); - } - return 0; -} diff --git a/tests/unused/pth_signal1.c b/tests/unused/pth_signal1.c deleted file mode 100644 index 40634122c2..0000000000 --- a/tests/unused/pth_signal1.c +++ /dev/null @@ -1,141 +0,0 @@ -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * sig.c - * - * Simple example of pthreads and signals. - */ - -#include -#include -#include -#include -#include - -#include - -#define MAX_NUM_THREADS 10 - - -void *catch_usr1(void *p) -{ - int signo=SIGUSR1; - /* struct sigaction action; */ - int caught; - sigset_t sigs_to_catch; - - /* Identify our thread */ - printf("\ncatchit() signal %d processing running as thread 0x%x \n", - signo, (int)pthread_self()); - printf("Someone please send pid %d a SIGUSR1\n", getpid()); - - /* - * We inherited a thread sigmask with all the signals - * blocked. So, we can wait on whatever signals we're - * interested in and (as long as no other thread waits - * for them) we'll be sure return from sigwait() to - * handle it. - */ - - /* set this thread's signal mask to block out all other signals */ - sigemptyset(&sigs_to_catch); - sigaddset(&sigs_to_catch, signo); - - sigwait(&sigs_to_catch, &caught); - - printf("\ncatchit() signal %d processing thread caught signal %d\n", - signo, caught); - - return(NULL); -} - -void bugcatcher(int sig) -{ - printf("The BUGCATCHER caught signal %d in thread 0x%x\n", - sig, (int)pthread_self()); - pthread_exit(0); -} - -void *cause_sig_sync(void *p) -{ - int i, id; - sigset_t sigs_to_catch; - - /* Identify our thread */ - printf("cause_sig_sync() running in thread 0x%x\n", (int)pthread_self()); - - /* set this thread's signal mask to block out all other signals */ - sigemptyset(&sigs_to_catch); - sigaddset(&sigs_to_catch, SIGSEGV); - sigaddset(&sigs_to_catch, SIGBUS); - pthread_sigmask(SIG_UNBLOCK, &sigs_to_catch, NULL); - - /* Loop simulating useful processing in this thread */ - for(i=1;i==i;i++) { - printf("printing count: %4d\r",i); - if (i%100 == 0) { - id = *(int *)p; /* Guaranteed bad address */ - } - } - - return(NULL); -} - -extern int -main(void) -{ - int i; - pthread_t threads[MAX_NUM_THREADS]; - int num_threads = 0; - sigset_t sigs_to_block; - struct sigaction action; - - - /* Identify our thread */ - printf("main() running in thread 0x%x\n", (int)pthread_self()); - - /* - * Set this thread's signal mask to block out all other signals - * Other threads will inherit the mask - */ - sigfillset(&sigs_to_block); - pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL); - - /* Set signal handler for catching SIGSEGV and SIGBUS */ - action.sa_handler=bugcatcher; - sigaction(SIGSEGV, &action, NULL); - sigaction(SIGBUS, &action, NULL); - - /* spawn the threads */ - - /* Make sure we can catch synchronous signals as exceptions */ - pthread_create(&threads[num_threads++], - NULL, - cause_sig_sync, - NULL); - - /* Rather than install the action/handler for the process, - we create a thread to wait for the signal */ - pthread_create(&threads[num_threads++], - NULL, - catch_usr1, - NULL); - - printf("main()\t\t\t\t%d threads created\n",num_threads); - - /* wait until all threads have finished */ - for (i = 0; i < num_threads; i++) { - pthread_join(threads[i], NULL); - printf("main()\t\tjoined to thread %d \n", i); - } - - printf("main()\t\tall %d threads have finished. \n", num_threads); - - return 0; -} - diff --git a/tests/unused/pth_signal2.c b/tests/unused/pth_signal2.c deleted file mode 100644 index 9e6f24ee70..0000000000 --- a/tests/unused/pth_signal2.c +++ /dev/null @@ -1,138 +0,0 @@ -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * stat_sigwait.c - * - * Simple example of pthreads and signals. - */ - -#include -#include -#include -#include -#include -#include - -#include - -#define MAX_NUM_THREADS 10 - -pthread_mutex_t stats_lock = PTHREAD_MUTEX_INITIALIZER; -int mean, samples, total; - -void *report_stats(void *p) -{ - int caught, i; - sigset_t sigs_to_catch; - - /* Identify our thread */ - printf("\nreport_stats() started.\n"); - - /* - * We inherited a thread sigmask with all the signals - * blocked. So, we can wait on whatever signals we're - * interested in and (as long as no other thread waits - * for them) we'll be sure return from sigwait() to - * handle it. - */ - - /* set this thread's signal mask to block out SIGUSR1 */ - sigemptyset(&sigs_to_catch); - sigaddset(&sigs_to_catch, SIGUSR1); - - for (;;) { - sigwait(&sigs_to_catch, &caught); - - pthread_mutex_lock(&stats_lock); - mean = total/samples; - printf("\nreport_stats(): mean = %d, samples = %d\n", mean, samples); - pthread_mutex_unlock(&stats_lock); - - /* Delay for a while so it's obvious whether or not SIGUSR1 is - still blocked here (it should be). */ - // for (i = 0; i < 100000; i++) ; - - } - return NULL; -} -/* - * worker_thread -- - * - * Don't read too much into what this thread does. It's - * a very simpleminded example. The only interesting thing - * it does is write to the global statistics data-- which - * means the thread processing the signal has to protect - * against simultaneous access. - */ -void *worker_thread(void *p) -{ - time_t now; - for (;;) { - - sleep(1 + (*(int*)p) % 2 ); - - now = time(NULL); - - pthread_mutex_lock(&stats_lock); - total+=((int)now)%60; /* probably not the safest thing to do but - it's just an example */ - samples++; - pthread_mutex_unlock(&stats_lock); - } - /* Won't get here. */ - return NULL; -} - -extern int -main(void) -{ - int i; - pthread_t threads[MAX_NUM_THREADS]; - int num_threads = 0; - sigset_t sigs_to_block; - - - /* Identify our thread */ - printf("main() (pid %d) running in thread 0x%x\n", - getpid(), (int)pthread_self()); - - /* - * Set this thread's signal mask to block SIGUSR1 - * Other threads will inherit the mask - */ - sigemptyset(&sigs_to_block); - sigaddset(&sigs_to_block, SIGUSR1); - pthread_sigmask(SIG_BLOCK, &sigs_to_block, NULL); - - /* spawn statistics reporting thread */ - pthread_create(&threads[num_threads++], - NULL, - report_stats, - NULL); - - /* spawn the threads */ - for (i=num_threads; i -#include -#include -#include - -/* thread function from Galaxy Communicator library */ -static void *__Gal_SignalHandler(void *arg) -{ - sigset_t set; - int sig; - int res; - - sigfillset(&set); - - while(1) { - res = sigwait(&set, &sig); - printf("Received signal number %d\n", sig); - } -} - -/* function from my code */ -static void signal_handler(int i) -{ - // nop -} - -/* function from my code */ -static void *serve(void *arg) -{ - sigset_t sig; - sigemptyset(&sig); - sigaddset(&sig, SIGUSR1); - pthread_sigmask(SIG_UNBLOCK, &sig, NULL); - - for(;;) { - /* somewhere in here, deeply buried within libcapi20, is a select(), - that I am interrupting by sending SIGUSR1 to this thread */ - } -} - -int main( void ) -{ - pthread_t sig_thread, serve_thread; - pthread_attr_t sig_attr; - struct sigaction sigact; - - /* from Galaxy Communicator library */ - pthread_attr_init(&sig_attr); - pthread_attr_setdetachstate(&sig_attr, PTHREAD_CREATE_DETACHED); - pthread_create(&sig_thread, &sig_attr, __Gal_SignalHandler, NULL); - - /* from my code */ - sigemptyset(&sigact.sa_mask); - sigact.sa_handler = signal_handler; - sigact.sa_flags = 0; - sigaction(SIGUSR1, &sigact, NULL); - pthread_create(&serve_thread, NULL, serve, NULL); - - /* happens within my code */ - for(;;) { - pthread_kill(serve_thread, SIGUSR1); - sleep(1); - } - return 0; -} diff --git a/tests/unused/pth_sigpending.c b/tests/unused/pth_sigpending.c deleted file mode 100644 index 05bdbb014b..0000000000 --- a/tests/unused/pth_sigpending.c +++ /dev/null @@ -1,55 +0,0 @@ - -#include -#include -#include -#include -#include -#include - -int show ( void ) -{ - int res, i, ret; - sigset_t pend; - res = sigpending(&pend); - printf("pending signals:\n"); - assert(res == 0); - ret = 0; - for (i = 1; i < 64; i++) { - if (sigismember(&pend,i)) { - printf(" sig %d now pending\n", i); - ret = 1; - } - } - return ret; -} - -void hdlr ( int sig ) -{ - printf("signal %d arrived (unexpectedly!)\n", sig); -} - -int main ( void ) -{ - int res; - sigset_t set; - /* Force use of libpthread here */ - pthread_testcancel(); - - printf("installing handler\n"); - signal(SIGINT, hdlr); - /* and block it ... */ - sigemptyset(&set); - sigaddset(&set, SIGINT); - res = pthread_sigmask(SIG_BLOCK, &set, NULL); - assert(res == 0); - printf("installing handler done; please do Control-C\n"); - - while (1) { - res = show(); - if (res) break; - sleep(1); - } - printf("control-C now pending -- bye\n"); - - return 0; -} diff --git a/tests/unused/pth_simple_mutex.c b/tests/unused/pth_simple_mutex.c deleted file mode 100644 index fe2162b99c..0000000000 --- a/tests/unused/pth_simple_mutex.c +++ /dev/null @@ -1,105 +0,0 @@ -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * simple_mutex.c - * - * Simple multi-threaded example with a mutex lock. - */ -#include -#include -#include -#include - -void do_one_thing(int *); -void do_another_thing(int *); -void do_wrap_up(int, int); - -int r1 = 0, r2 = 0, r3 = 0; -pthread_mutex_t r3_mutex=PTHREAD_MUTEX_INITIALIZER; - -extern int -main(int argc, char **argv) -{ - pthread_t thread1, thread2; - - if (argc > 1) - r3 = atoi(argv[1]); - - if (pthread_create(&thread1, - NULL, - (void *) do_one_thing, - (void *) &r1) != 0) - perror("pthread_create"),exit(1); - - if (pthread_create(&thread2, - NULL, - (void *) do_another_thing, - (void *) &r2) != 0) - perror("pthread_create"),exit(1); - - if (pthread_join(thread1, NULL) != 0) - perror("pthread_join"), exit(1); - - if (pthread_join(thread2, NULL) != 0) - perror("pthread_join"), exit(1); - - do_wrap_up(r1, r2); - - return 0; -} - -void do_one_thing(int *pnum_times) -{ - int i, j, x; - - pthread_mutex_lock(&r3_mutex); - if(r3 > 0) { - x = r3; - r3--; - } else { - x = 1; - } - pthread_mutex_unlock(&r3_mutex); - - for (i = 0; i < 4; i++) { - printf("doing one thing\n"); - for (j = 0; j < 100000; j++) x = x + i; - (*pnum_times)++; - } - -} - -void do_another_thing(int *pnum_times) -{ - int i, j, x; - - pthread_mutex_lock(&r3_mutex); - if(r3 > 0) { - x = r3; - r3--; - } else { - x = 1; - } - pthread_mutex_unlock(&r3_mutex); - - for (i = 0; i < 4; i++) { - printf("doing another \n"); - for (j = 0; j < 100000; j++) x = x + i; - (*pnum_times)++; - } - -} - -void do_wrap_up(int one_times, int another_times) -{ - int total; - - total = one_times + another_times; - printf("All done, one thing %d, another %d for a total of %d\n", - one_times, another_times, total); -} diff --git a/tests/unused/pth_simple_threads.c b/tests/unused/pth_simple_threads.c deleted file mode 100644 index e42ae26b7e..0000000000 --- a/tests/unused/pth_simple_threads.c +++ /dev/null @@ -1,44 +0,0 @@ - -#include -#include - -int r1 = 0, r2 = 0; - -void do_one_thing ( int* ntimes ) -{ - int i, j, x; - for (i = 0; i < 4; i++) { - printf ("doing one thing\n"); - for (j = 0; j < 100000; j++) x = x + i; - (*ntimes)++; - } -} - -void do_another_thing ( int* ntimes ) -{ - int i, j, x; - for (i = 0; i < 4; i++) { - printf ("doing another\n"); - for (j = 0; j < 100000; j++) x = x + i; - (*ntimes)++; - } -} - -void do_wrap_up ( int one_times, int another_times ) -{ - int total = one_times + another_times; - printf("wrap up: one thing %d, another %d, total %d\n", - one_times, another_times, total ); -} - -int main ( void ) -{ - pthread_t t1, t2; - pthread_create( &t1, NULL, (void*)do_one_thing, (void*)&r1 ); - pthread_create( &t2, NULL, (void*)do_another_thing, (void*)&r2 ); - // while (1) {} - pthread_join(t1, NULL); - pthread_join(t2, NULL); - do_wrap_up(r1,r2); - return 0; -} diff --git a/tests/unused/pth_threadpool.c b/tests/unused/pth_threadpool.c deleted file mode 100644 index 2da1950195..0000000000 --- a/tests/unused/pth_threadpool.c +++ /dev/null @@ -1,395 +0,0 @@ -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * tpool.c -- - * - * Example thread pooling library - */ - -#include -#include -#include -#include -#include - -#include - - -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * tpool.h -- - * - * Structures for thread pool - */ - -typedef struct tpool_work { - void (*routine)(); - void *arg; - struct tpool_work *next; -} tpool_work_t; - -typedef struct tpool { - /* pool characteristics */ - int num_threads; - int max_queue_size; - int do_not_block_when_full; - /* pool state */ - pthread_t *threads; - int cur_queue_size; - tpool_work_t *queue_head; - tpool_work_t *queue_tail; - int queue_closed; - int shutdown; - /* pool synchronization */ - pthread_mutex_t queue_lock; - pthread_cond_t queue_not_empty; - pthread_cond_t queue_not_full; - pthread_cond_t queue_empty; -} *tpool_t; - -void tpool_init( - tpool_t *tpoolp, - int num_threads, - int max_queue_size, - int do_not_block_when_full); - -int tpool_add_work( - tpool_t tpool, - void (*routine)(), - void *arg); - -int tpool_destroy( - tpool_t tpool, - int finish); - - -/*-- end of tpool.h ----------------------------------*/ - - -void *tpool_thread(void *); - -void tpool_init(tpool_t *tpoolp, - int num_worker_threads, - int max_queue_size, - int do_not_block_when_full) -{ - int i, rtn; - tpool_t tpool; - - /* allocate a pool data structure */ - if ((tpool = (tpool_t )malloc(sizeof(struct tpool))) == NULL) - perror("malloc"), exit(1); - - /* initialize th fields */ - tpool->num_threads = num_worker_threads; - tpool->max_queue_size = max_queue_size; - tpool->do_not_block_when_full = do_not_block_when_full; - if ((tpool->threads = - (pthread_t *)malloc(sizeof(pthread_t)*num_worker_threads)) - == NULL) - perror("malloc"), exit(1); - tpool->cur_queue_size = 0; - tpool->queue_head = NULL; - tpool->queue_tail = NULL; - tpool->queue_closed = 0; - tpool->shutdown = 0; - if ((rtn = pthread_mutex_init(&(tpool->queue_lock), NULL)) != 0) - fprintf(stderr,"pthread_mutex_init %s\n",strerror(rtn)), exit(1); - if ((rtn = pthread_cond_init(&(tpool->queue_not_empty), NULL)) != 0) - fprintf(stderr,"pthread_cond_init %s\n",strerror(rtn)), exit(1); - if ((rtn = pthread_cond_init(&(tpool->queue_not_full), NULL)) != 0) - fprintf(stderr,"pthread_cond_init %s\n",strerror(rtn)), exit(1); - if ((rtn = pthread_cond_init(&(tpool->queue_empty), NULL)) != 0) - fprintf(stderr,"pthread_cond_init %s\n",strerror(rtn)), exit(1); - - /* create threads */ - for (i = 0; i != num_worker_threads; i++) { - if ((rtn = pthread_create( &(tpool->threads[i]), - NULL, - tpool_thread, - (void *)tpool)) != 0) - fprintf(stderr,"pthread_create %d\n",rtn), exit(1); - } - - *tpoolp = tpool; -} - -int tpool_add_work( - tpool_t tpool, - void (*routine)(), - void *arg) -{ - int rtn; - tpool_work_t *workp; - - if ((rtn = pthread_mutex_lock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_lock %d\n",rtn), exit(1); - - /* no space and this caller doesn't want to wait */ - if ((tpool->cur_queue_size == tpool->max_queue_size) && - tpool->do_not_block_when_full) { - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - - return -1; - } - - while( (tpool->cur_queue_size == tpool->max_queue_size) && - (!(tpool->shutdown || tpool->queue_closed)) ) { - - if ((rtn = pthread_cond_wait(&(tpool->queue_not_full), - &(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_cond_waitA %d\n",rtn), exit(1); - - } - - /* the pool is in the process of being destroyed */ - if (tpool->shutdown || tpool->queue_closed) { - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - - return -1; - } - - - /* allocate work structure */ - if ((workp = (tpool_work_t *)malloc(sizeof(tpool_work_t))) == NULL) - perror("malloc"), exit(1); - workp->routine = routine; - workp->arg = arg; - workp->next = NULL; - - printf("adder: adding an item %d\n", workp->routine); - - if (tpool->cur_queue_size == 0) { - tpool->queue_tail = tpool->queue_head = workp; - - printf("adder: queue == 0, waking all workers\n"); - - if ((rtn = pthread_cond_broadcast(&(tpool->queue_not_empty))) != 0) - fprintf(stderr,"pthread_cond_signal %d\n",rtn), exit(1);; - } else { - tpool->queue_tail->next = workp; - tpool->queue_tail = workp; - } - - tpool->cur_queue_size++; - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - return 1; -} - -int tpool_destroy(tpool_t tpool, - int finish) -{ - int i,rtn; - tpool_work_t *cur_nodep; - - - if ((rtn = pthread_mutex_lock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_lock %d\n",rtn), exit(1); - - /* Is a shutdown already in progress? */ - if (tpool->queue_closed || tpool->shutdown) { - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - return 0; - } - - tpool->queue_closed = 1; - - /* If the finish flag is set, wait for workers to - drain queue */ - if (finish == 1) { - while (tpool->cur_queue_size != 0) { - if ((rtn = pthread_cond_wait(&(tpool->queue_empty), - &(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_cond_waitB %d\n",rtn), exit(1); - } - } - - tpool->shutdown = 1; - - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - - - /* Wake up any workers so they recheck shutdown flag */ - if ((rtn = pthread_cond_broadcast(&(tpool->queue_not_empty))) != 0) - fprintf(stderr,"pthread_cond_broadcast %d\n",rtn), exit(1); - if ((rtn = pthread_cond_broadcast(&(tpool->queue_not_full))) != 0) - fprintf(stderr,"pthread_cond_broadcast %d\n",rtn), exit(1); - - - /* Wait for workers to exit */ - for(i=0; i < tpool->num_threads; i++) { - if ((rtn = pthread_join(tpool->threads[i],NULL)) != 0) - fprintf(stderr,"pthread_join %d\n",rtn), exit(1); - } - - /* Now free pool structures */ - free(tpool->threads); - while(tpool->queue_head != NULL) { - cur_nodep = tpool->queue_head->next; - tpool->queue_head = tpool->queue_head->next; - free(cur_nodep); - } - free(tpool); -} - -void *tpool_thread(void *arg) -{ - tpool_t tpool = (tpool_t)arg; - int rtn; - tpool_work_t *my_workp; - - for(;;) { - - - - /* Check queue for work */ - if ((rtn = pthread_mutex_lock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_lock %d\n",rtn), exit(1); - - while ((tpool->cur_queue_size == 0) && (!tpool->shutdown)) { - - - printf("worker %d: I'm sleeping again\n", pthread_self()); - - if ((rtn = pthread_cond_wait(&(tpool->queue_not_empty), - &(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_cond_waitC %d\n",rtn), exit(1); - - } - sleep(1); - - printf("worker %d: I'm awake\n", pthread_self()); - - /* Has a shutdown started while i was sleeping? */ - if (tpool->shutdown == 1) { - - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - pthread_exit(NULL); - } - - - /* Get to work, dequeue the next item */ - my_workp = tpool->queue_head; - tpool->cur_queue_size--; - if (tpool->cur_queue_size == 0) - tpool->queue_head = tpool->queue_tail = NULL; - else - tpool->queue_head = my_workp->next; - - printf("worker %d: dequeuing item %d\n", pthread_self(), my_workp->next); - - /* Handle waiting add_work threads */ - if ((!tpool->do_not_block_when_full) && - (tpool->cur_queue_size == (tpool->max_queue_size - 1))) - - if ((rtn = pthread_cond_broadcast(&(tpool->queue_not_full))) != 0) - fprintf(stderr,"pthread_cond_broadcast %d\n",rtn), exit(1); - - /* Handle waiting destroyer threads */ - if (tpool->cur_queue_size == 0) - - if ((rtn = pthread_cond_signal(&(tpool->queue_empty))) != 0) - fprintf(stderr,"pthread_cond_signal %d\n",rtn), exit(1); - - if ((rtn = pthread_mutex_unlock(&(tpool->queue_lock))) != 0) - fprintf(stderr,"pthread_mutex_unlock %d\n",rtn), exit(1); - - /* Do this work item */ - (*(my_workp->routine))(my_workp->arg); - free(my_workp); - } - return(NULL); -} - - -/******************************************************** - * An example source module to accompany... - * - * "Using POSIX Threads: Programming with Pthreads" - * by Brad nichols, Dick Buttlar, Jackie Farrell - * O'Reilly & Associates, Inc. - * - ******************************************************** - * tpool.c -- - * - * Example caller for thread pooling library - */ - -char *s1[20]={ "STRING 0", - "STRING 1", - "STRING 2", - "STRING 3", - "STRING 4", - "STRING 5", - "STRING 6", - "STRING 7", - "STRING 8", - "STRING 9", - "STRING 10", - "STRING 11", - "STRING 12", - "STRING 13", - "STRING 14", - "STRING 15", - "STRING 16", - "STRING 17", - "STRING 18", - "STRING 19"}; - -void r1(char * printstring) -{ - int i, x; - - printf("%s START\n", printstring); - - for (i = 0; i < 1000000; i++) { - x = x +i; - } - - printf("%s DONE\n", printstring); -} - -extern int -main(void) -{ - extern char *s1[]; - - pthread_t t1,t2; - int i; - - tpool_t test_pool; - - tpool_init(&test_pool, 10, 20, 0); - - sleep(1); - - for ( i = 0; i < 5; i++) { - printf("tpool_add_work returned %d\n", - tpool_add_work(test_pool, r1, s1[i])); - - } - - printf("main: all work queued\n"); - - tpool_destroy(test_pool, 1); - - return 0; - -} diff --git a/tests/unused/pth_yield.c b/tests/unused/pth_yield.c deleted file mode 100644 index 0b708ba063..0000000000 --- a/tests/unused/pth_yield.c +++ /dev/null @@ -1,44 +0,0 @@ - -#include -#include - -#define __USE_GNU -#include - -void do_one_thing ( void* v ) -{ - int i, j, res; - for (i = 0; i < 10; i++) { - for (j = 0; j < 10; j++) { - printf("a "); fflush(stdout); - } - printf("\naaaaaaa-yielding\n"); - res = pthread_yield(); - assert(res == 0); - } -} - -void do_another_thing ( void* v ) -{ - int i, j, res; - for (i = 0; i < 10; i++) { - for (j = 0; j < 10; j++) { - printf("b "); fflush(stdout); - } - printf("\nbbbbbbb-yielding\n"); - res = pthread_yield(); - assert(res == 0); - } -} - - -int main ( void ) -{ - pthread_t t1, t2; - pthread_create( &t1, NULL, (void*)do_one_thing, NULL ); - pthread_create( &t2, NULL, (void*)do_another_thing, NULL ); - pthread_join(t1, NULL); - pthread_join(t2, NULL); - printf("bye!\n"); - return 0; -} diff --git a/tests/unused/signal1.c b/tests/unused/signal1.c deleted file mode 100644 index 059d7cb87b..0000000000 --- a/tests/unused/signal1.c +++ /dev/null @@ -1,25 +0,0 @@ - -#include -#include - -/* spurious comment only here to test cvs mail notifications. */ - -volatile int spin; - -void sig_hdlr ( int signo ) -{ - printf ( "caught signal\n" ); - spin = 0; - printf ( "signal returns\n" ); -} - -int main ( void ) -{ - spin = 1; - printf ( "installing sig handler\n" ); - signal(SIGINT, sig_hdlr); - printf ( "entering busy wait\n" ); - while (spin) { }; - printf ( "exited\n" ); - return 0; -} diff --git a/tests/unused/signal3.c b/tests/unused/signal3.c deleted file mode 100644 index 6c1cc68c4f..0000000000 --- a/tests/unused/signal3.c +++ /dev/null @@ -1,34 +0,0 @@ - -#include -#include -#include -#include - -void hdp_tick ( int sigNo ) -{ - int j; - printf("tick "); fflush(stdout); - for (j = 0; j < 10 * 5000; j++) ; - printf("tock\n"); -} - -void hdp_init_profiling ( void ) -{ - struct itimerval value; - int ret; - - value.it_interval.tv_sec = 0; - value.it_interval.tv_usec = 50 * 1000; - value.it_value = value.it_interval; - - signal(SIGPROF, hdp_tick); - ret = setitimer(ITIMER_PROF, &value, NULL); - assert(ret == 0); -} - -int main ( void ) -{ - hdp_init_profiling(); - while (1) {} - return 0; -} diff --git a/tests/unused/sigwait_all.c b/tests/unused/sigwait_all.c deleted file mode 100644 index 27a5be7210..0000000000 --- a/tests/unused/sigwait_all.c +++ /dev/null @@ -1,23 +0,0 @@ - -#include -#include -#include - - -int main ( void ) -{ - int res, sig; - sigset_t set; - sigfillset(&set); - - /* block all signals */ - pthread_sigmask(SIG_BLOCK, &set, NULL); - - printf("send me a signal, any signal\n"); - - /* Wait for any signal in the set */ - res = sigwait(&set, &sig); - - printf("sigwait returned, res = %d, sig = %d\n", res, sig); - return 0; -} diff --git a/tests/unused/twoparams.c b/tests/unused/twoparams.c deleted file mode 100644 index 91c966a268..0000000000 --- a/tests/unused/twoparams.c +++ /dev/null @@ -1,7 +0,0 @@ - -/* general simple function to use as a template for assembly hacks */ - -int fooble ( int a, int b ) -{ - return a - b; -} diff --git a/tests/unused/twoparams.s b/tests/unused/twoparams.s deleted file mode 100644 index 5adfec50f1..0000000000 --- a/tests/unused/twoparams.s +++ /dev/null @@ -1,17 +0,0 @@ - .file "twoparams.c" - .version "01.01" -gcc2_compiled.: -.text - .align 4 -.globl fooble - .type fooble,@function -fooble: - pushl %ebp - movl %esp, %ebp - movl 8(%ebp), %eax - subl 12(%ebp), %eax - popl %ebp - ret -.Lfe1: - .size fooble,.Lfe1-fooble - .ident "GCC: (GNU) 2.96 20000731 (Red Hat Linux 7.1 2.96-98)"