annotate example/Prime/ppe/PrintTask.cc @ 1189:898fdcf53c31 draft

add SemMailManager
author Daichi TOMA
date Fri, 08 Jul 2011 18:34:18 +0900
parents d910c8377a09
children 7909536bf611
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 {
1189
898fdcf53c31 add SemMailManager
Daichi TOMA
parents: 1171
diff changeset
11 int length = (long)smanager->get_param(0); /* 出力する範囲 */
1171
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 int *input = (int*)smanager->get_input(rbuf, 0); /* 出力する配列 */
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 /* 素数の判定結果が1ならば出力する */
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15 for (int i = 0; i < length; i++) {
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 if ( input[i] == 1 ) {
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 printf("%d ",i);
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 }
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 printf("\n");
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21 return 0;
d910c8377a09 add prime example
Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
22 }