Mercurial > hg > Members > shinya > pyrect
changeset 66:c657ca0f0b30
remove paralle-code (that have to need more improvement.)
author | Ryoma SHINYA <shinya@firefly.cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 06 Nov 2010 00:55:01 +0900 |
parents | 020ba001c58a |
children | b02b321d0e06 |
files | pyrect/translator/template/grep.c |
diffstat | 1 files changed, 1 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/pyrect/translator/template/grep.c Fri Nov 05 01:39:42 2010 +0900 +++ b/pyrect/translator/template/grep.c Sat Nov 06 00:55:01 2010 +0900 @@ -1,46 +1,3 @@ -/* -typedef struct _thread_arg { - unsigned char *buf; - int len; - int match; -} thread_arg_t; - -void* thread_dfa(void *arg) { - thread_arg_t* targ = (thread_arg_t*)arg; - targ->match = DFA(targ->buf, targ->len); - return NULL; -} - -int paradfa(unsigned char *text, int len) { - pthread_t hundle[THREAD_NUM]; - thread_arg_t targ[THREAD_NUM]; - - if (len + REG_MAX_LEN <= REG_MAX_LEN) - return dfa(text, len); - - int i, t_len = (len + THREAD_NUM - 1) / THREAD_NUM; - for (i = 0; i < THREAD_NUM; i++) { - targ[i].buf = text + (unsigned char)(i * t_len); - targ[i].len = t_len + REG_MAX_LEN; - } - targ[THREAD_NUM - 1].len = len - (t_len * (THREAD_NUM - 1)); - - for (i = 0; i < THREAD_NUM; i++) { - pthread_create(&hundle[i], NULL, (void *)thread_dfa, (void *)&targ[i]); - } - - for (i = 0; i < THREAD_NUM; i++) { - pthread_join(hundle[i], NULL); - } - - for (i = 0; i < THREAD_NUM; i++) { - if (targ[i].match) return 1; - } - return 0; -} - -*/ - void print_line(unsigned char *beg, unsigned char *end) { fwrite(beg, sizeof(char), (end - beg + 1), stdout); } @@ -70,6 +27,7 @@ dfa(beg, beg, end); munmap(file_mmap, size); + pthread_exit(NULL); return; }