Mercurial > hg > Game > Cerium
comparison TaskManager/Cell/SpeThreads.cc @ 244:e9735a64cd90 draft
mail modify
author | e065746@localhost.localdomain |
---|---|
date | Sun, 31 May 2009 20:08:42 +0900 |
parents | b56fb6ac2fc4 |
children | 0c9c9906d777 |
comparison
equal
deleted
inserted
replaced
243:c4918a1fb6c9 | 244:e9735a64cd90 |
---|---|
8 { | 8 { |
9 unsigned int mail = MY_SPE_COMMAND_EXIT; | 9 unsigned int mail = MY_SPE_COMMAND_EXIT; |
10 int ret; | 10 int ret; |
11 | 11 |
12 for (int i = 0; i < spe_num; i++) { | 12 for (int i = 0; i < spe_num; i++) { |
13 send_mail(i, &mail, 1); | 13 send_mail(i, 1, &mail); |
14 } | 14 } |
15 | 15 |
16 for (int i = 0; i < spe_num; i++) { | 16 for (int i = 0; i < spe_num; i++) { |
17 pthread_join(threads[i], NULL); | 17 pthread_join(threads[i], NULL); |
18 ret = spe_context_destroy(spe_ctx[i]); | 18 ret = spe_context_destroy(spe_ctx[i]); |
105 &spe_thread_run, (void*)&args[i]); | 105 &spe_thread_run, (void*)&args[i]); |
106 #endif | 106 #endif |
107 } | 107 } |
108 } | 108 } |
109 | 109 |
110 | |
110 /** | 111 /** |
111 * SPE からのメールを受信する。 | 112 * SPE からのメールを受信する。 |
112 * | 113 * |
113 * @param [speid] SPE ID | 114 * @param [speid] SPE ID |
114 * | 115 * |
115 * @return Received 32-bit mailbox messages | 116 * @return Received 32-bit mailbox messages |
116 * if ([ret] < 0) no data read | 117 * if ([ret] < 0) no data read |
117 */ | 118 */ |
118 int | 119 int |
119 SpeThreads::get_mail(int speid) | 120 SpeThreads::get_mail(int speid, int count, unsigned int* ret) |
121 { | |
122 while(spe_out_mbox_status(spe_ctx[speid]) < count); | |
123 return spe_out_mbox_read(spe_ctx[speid], ret, count); | |
124 } | |
125 | |
126 int | |
127 SpeThreads::check_mail(int speid, int count, unsigned int* ret) | |
120 { | 128 { |
121 unsigned int ret = (unsigned int)(-1); | 129 if (spe_out_mbox_status(spe_ctx[speid]) >= count) { |
122 | 130 return spe_out_mbox_read(spe_ctx[speid], ret, count); |
123 spe_out_mbox_read(spe_ctx[speid], &ret, 1); | 131 } else { |
124 return ret; | 132 return 0; |
133 } | |
125 } | 134 } |
126 | 135 |
127 /** | 136 /** |
128 * Inbound Mailbox | 137 * Inbound Mailbox |
129 * メール送信 PPE -> SPE | 138 * メール送信 PPE -> SPE |
137 * @param [speid] SPE ID | 146 * @param [speid] SPE ID |
138 * @param [data] Send 32-bit mailbox messages | 147 * @param [data] Send 32-bit mailbox messages |
139 * @param [num] The number of messages | 148 * @param [num] The number of messages |
140 */ | 149 */ |
141 void | 150 void |
142 SpeThreads::send_mail(int speid, unsigned int *data, int num) | 151 SpeThreads::send_mail(int speid, int num, unsigned int *data) |
143 { | 152 { |
144 while (spe_in_mbox_status(spe_ctx[speid]) < num); | 153 spe_in_mbox_write(spe_ctx[speid], data, num, SPE_MBOX_ALL_BLOCKING); |
145 spe_in_mbox_write(spe_ctx[speid], data, num, SPE_MBOX_ANY_NONBLOCKING); | |
146 } | 154 } |
155 | |
156 void | |
157 SpeThreads::add_output_tasklist(int command, void *buff, int alloc_size) | |
158 { | |
159 /* | |
160 * output TaskList が無ければ新しく作る | |
161 * あれば TaskList に allocate した Task を追加 | |
162 * command に対応した Task の初期化を実行する | |
163 * SPE に data が書き出し終わった後に PPE 側で初期化 | |
164 */ | |
165 | |
166 } |