annotate TaskManager/kernel/ppe/MailManager.cc @ 662:6dd6145eb1a5 draft

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 02 Dec 2009 20:44:01 +0900
parents 470db907a460 aefb5ee6fcd0
children cc1b7333de92
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
1 #include <stdlib.h>
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
2 #include "MailManager.h"
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
3
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
4 void
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
5 MailManager::calc_mask(unsigned int qsize)
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
6 {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
7 mask = 1;
651
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
8 while(qsize>mask) {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
9 mask <<= 1;
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
10 }
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
11 size = mask;
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
12 mask--;
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
13 }
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
14
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
15 MailManager::MailManager(unsigned int qsize) {
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
16 calc_mask(qsize);
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
17 queue = New(memaddr,size);
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
18 }
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
19
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
20 MailManager::~MailManager() { free(queue); }
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
21
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
22 int
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
23 MailManager::count()
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
24 {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
25 return (write+size-read)&mask;
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
26 }
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
27
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
28 void
651
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
29 MailManager::extend()
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
30 {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
31 memaddr *newq = New(memaddr,size*2);
660
470db907a460 vectorize word_count.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 651
diff changeset
32 unsigned int i = 0;
651
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
33 while(i<size) {
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
34 newq[i++] = queue[read++];
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
35 read &= mask;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
36 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
37 read = 0; write = i;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
38 calc_mask(size*2);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
39 free(queue);
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
40 queue = newq;
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
41 }
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
42
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 649
diff changeset
43 void
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
44 MailManager::send(memaddr data)
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
45 {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
46 queue[write++] = data;
649
026e9e7f1402 MailManager Fifo fix
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 647
diff changeset
47 write &= mask;
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
48 if (write==read) {
652
aefb5ee6fcd0 fix on Mac OS X
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 651
diff changeset
49 extend();
194
gongo@localhost.localdomain
parents: 50
diff changeset
50 }
50
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
51 }
7927e00fb8e2 *** empty log message ***
gongo
parents:
diff changeset
52
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
53 memaddr
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
54 MailManager::recv()
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
55 {
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
56 memaddr data;
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
57 if (count()>0) {
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
58 data = queue[read++];
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
59 read &= mask;
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
60 } else {
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
61 data = 0;
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
62 }
647
7ba4ad4538b1 MailManager rewrite. not yet worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 644
diff changeset
63 return data;
643
2a611e8d8788 minor fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
64 }
2a611e8d8788 minor fix.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 640
diff changeset
65
640
ecf056ddd21a SimpeTask on Cell worked.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 603
diff changeset
66 /* end */