annotate example/Prime/ppe/PrintTask.cc @ 1248:d2f70da2aa19 draft

merge
author Daichi Toma <toma@cr.ie.u-ryukyu.ac.jp>
date Sat, 12 Nov 2011 15:32:41 +0900
parents 9df036b11eae
children 24d323dfebea
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include <stdio.h>
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #include "SchedTask.h"
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #include "PrintTask.h"
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 #include "Func.h"
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 SchedDefineTask1(PrintTask, print);
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 static int
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 print(SchedTask *smanager, void *rbuf, void *wbuf)
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 {
1232
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
11 long print_flag = (long)smanager->get_param(1); //プリントするかどうか
1194
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1189
diff changeset
12
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1189
diff changeset
13 if (print_flag < 0) {
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1189
diff changeset
14 return 0;
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1189
diff changeset
15 }
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1189
diff changeset
16
1232
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
17 long length = (long)smanager->get_param(0); /* 出力する範囲 */
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
18 bool *input = (bool*)smanager->get_input(rbuf, 0); /* 出力する配列 */
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
1243
9df036b11eae fix printtask
Daichi Toma <amothic@gmail.com>
parents: 1233
diff changeset
20 input[0] = false;
9df036b11eae fix printtask
Daichi Toma <amothic@gmail.com>
parents: 1233
diff changeset
21 input[1] = false;
9df036b11eae fix printtask
Daichi Toma <amothic@gmail.com>
parents: 1233
diff changeset
22
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 /* 素数の判定結果が1ならば出力する */
1232
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
24 for (long i = 0; i < length; i++) {
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
25 if ( input[i] == true ) {
1248
Daichi Toma <toma@cr.ie.u-ryukyu.ac.jp>
parents: 1243
diff changeset
26 printf("%ld\n",i);
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 }
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 }
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 return 0;
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30 }