X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs2.git;a=blobdiff_plain;f=direct%2Ftimothy_tests%2Fthreading%2Fthreading.c;fp=direct%2Ftimothy_tests%2Fthreading%2Fthreading.c;h=a9ed1bb577caddc61831af9e5da1fcecfce78cd0;hp=0000000000000000000000000000000000000000;hb=5f61aa469fb4b46a5a1f4aacbe459323b5d13edd;hpb=8a946551046502799aca7086e585f4b9e2437587 diff --git a/direct/timothy_tests/threading/threading.c b/direct/timothy_tests/threading/threading.c new file mode 100644 index 0000000..a9ed1bb --- /dev/null +++ b/direct/timothy_tests/threading/threading.c @@ -0,0 +1,81 @@ +/* + * YAFFS: Yet another FFS. A NAND-flash specific file system. + * + * Copyright (C) 2002-2010 Aleph One Ltd. + * for Toby Churchill Ltd and Brightstar Engineering + * + * Created by Timothy Manning + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include "threading.h" + +int random_seed; +int simulate_power_failure = 0; + +const struct option long_options[]={ + {"help", 0,NULL,'h'}, + {"threads", 1,NULL,'t'} +}; + +const char short_options[]="hqn:t:cv"; + + + + +void main_init(int argc, char *argv[]) +{ + int new_option; + int x=0; + int new_num_of_threads=5; + do{ + new_option=getopt_long(argc,argv,short_options,long_options,NULL); + if (0==strcmp(argv[x],"-h")){ + printf("help\n"); + printf("-h will print the commands available\n"); + printf("-c will continue after a test failes else the program will exit\n"); + printf("-v will print all messages\n"); + printf("-q quiet mode only the number of tests passed and failed will be printed\n"); + printf("-t [number] set yaffs_trace to number\n"); + printf("-n [number] sets the number of random loops to run after the the test has run\n"); + exit(0); + } else if (new_option=='t') { + new_num_of_threads=atoi(optarg); + } + }while (new_option!=-1); + number_of_threads(new_num_of_threads); + init_counter(new_num_of_threads); + +} + +int main(int argc, char *argv[]) +{ + main_init(argc,argv); + pthread_t threads[get_num_of_threads()]; + unsigned int x=0; + int output=0; + int y=0; + + for (x=0;x0){ + printf("failed to create thread %d. Error is %d\n",x,output); + } + + } + while (1){ + y=0; + printf("thread counter: %d ",get_counter(y)); + for (y=1;y