changeset 1820:ff4e06001518 draft

change method read() to pread()
author Masataka Kohagura <e085726@ie.u-ryukyu.ac.jp>
date Fri, 13 Dec 2013 17:11:28 +0900
parents ce1a5624395e
children 4251e9b607b4
files example/fileread/d.txt example/fileread/main.cc example/fileread/ppe/Read.cc
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/example/fileread/d.txt	Fri Dec 13 17:07:33 2013 +0900
+++ b/example/fileread/d.txt	Fri Dec 13 17:11:28 2013 +0900
@@ -1,4 +1,4 @@
-abaacabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababcaa
+firstabaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaababcaa
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabababcabb
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
--- a/example/fileread/main.cc	Fri Dec 13 17:07:33 2013 +0900
+++ b/example/fileread/main.cc	Fri Dec 13 17:11:28 2013 +0900
@@ -91,9 +91,9 @@
         read->set_param(0,(long)task_number);  //生成するTaskが何番目か
         read->set_param(1,(long)DIVISION_SIZE);  //1つのタスクが読み込む量
         if(left_size <= DIVISION_SIZE){
-            read->set_param(2,(long)left_size);  //生成するTaskが何番目か
+            read->set_param(2,(long)left_size);
         }else{
-            read->set_param(2,(long)DIVISION_SIZE);  //生成するTaskが何番目か
+            read->set_param(2,(long)DIVISION_SIZE);
         }
         read->spawn();
 
--- a/example/fileread/ppe/Read.cc	Fri Dec 13 17:07:33 2013 +0900
+++ b/example/fileread/ppe/Read.cc	Fri Dec 13 17:11:28 2013 +0900
@@ -23,10 +23,12 @@
     long read_size = (long)s->get_param(2);
 
     char text[(long)read_size];
+    text[(long)read_size + 1] = '\0';
 
-    lseek(*fd, division_size* task_number,SEEK_SET);   //lseekでどこから読み込むのか指定
-    read(*fd,text,(long)read_size);
+    //lseek(*fd, division_size* task_number,SEEK_SET);   //lseekでどこから読み込むのか指定
+    //read(*fd,text,(long)read_size);
 
+    pread(*fd, text, (long)read_size , division_size*task_number);
     s->printf("[start task No. %d]\n",task_number);
     s->printf("%s\n",text);