annotate example/Prime/spe/PrintTask.cc @ 1233:247da1f5e625 draft

fix
author Daichi Toma <amothic@gmail.com>
date Tue, 18 Oct 2011 12:25:08 +0900
parents 2dfac651288e
children 9df036b11eae
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: 1171
diff changeset
12
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1171
diff changeset
13 if (print_flag < 0) {
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1171
diff changeset
14 return 0;
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1171
diff changeset
15 }
7909536bf611 fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents: 1171
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
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 /* 素数の判定結果が1ならば出力する */
1232
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
21 for (long i = 0; i < length; i++) {
2dfac651288e fix Prime
Daichi Toma <amothic@gmail.com>
parents: 1194
diff changeset
22 if ( input[i] == true ) {
1233
Daichi Toma <amothic@gmail.com>
parents: 1232
diff changeset
23 printf("%ld ",i);
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
24 }
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 }
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26 printf("\n");
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27 return 0;
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 }