Mercurial > hg > Game > Cerium
changeset 1857:7122e6edce5e draft
add Read.cc & Read.h
author | Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 22 Dec 2013 23:12:35 +0900 |
parents | 429cf7e669a1 |
children | 45139c74dad1 |
files | example/regex_mas/ppe/Read.cc example/regex_mas/ppe/Read.h |
diffstat | 2 files changed, 43 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/example/regex_mas/ppe/Read.cc Sun Dec 22 23:12:35 2013 +0900 @@ -0,0 +1,36 @@ +#include <stdio.h> +#include <string.h> +#include <unistd.h> +#include <sys/stat.h> +#include <iostream> +#include <vector> +#include <cstdlib> + +#include "SchedTask.h" +#include "Print.h" +#include "Func.h" + +/* これは必須 */ +SchedDefineTask1(TASK_READ,Read_task); + +static int +Read_task(SchedTask *s, void *rbuf, void *wbuf) +{ + int *fd = (int *)s->get_input(rbuf,0); ///ファイルディスクリプタの受取 + + long task_number = (long)s->get_param(0); //何番目のtaskか + long division_size = (long)s->get_param(1); + long read_size = (long)s->get_param(2); + + char *readtext = (char*)s->get_output(wbuf,0); + + char *text = (char*)s->allocate(sizeof(char)*read_size + 1); + //char text[(long)read_size]; + text[(long)read_size + 1] = '\0'; + + pread(*fd, text, (long)read_size , division_size*task_number); + + readtext = text; + + return 0; +}