Mercurial > hg > Game > Cerium
comparison TaskManager/kernel/ppe/CpuThreads.cc @ 1522:027d99ecb50e draft
run example/many_task
author | Yuhi TOMARI <yuhi@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 13 Nov 2012 16:16:29 +0900 |
parents | 8d6fee66ff65 |
children | 32305a19a380 |
comparison
equal
deleted
inserted
replaced
1521:9ae6eedd3ee3 | 1522:027d99ecb50e |
---|---|
8 #include "MainScheduler.h" | 8 #include "MainScheduler.h" |
9 #include "SysFunc.h" | 9 #include "SysFunc.h" |
10 #include "SchedNop.h" | 10 #include "SchedNop.h" |
11 #include "SpeTaskManagerImpl.h" | 11 #include "SpeTaskManagerImpl.h" |
12 #include "CellScheduler.h" | 12 #include "CellScheduler.h" |
13 | 13 #include <fcntl.h> |
14 | 14 |
15 SchedExternTask(ShowTime); | 15 SchedExternTask(ShowTime); |
16 SchedExternTask(StartProfile); | 16 SchedExternTask(StartProfile); |
17 | 17 |
18 | 18 |
38 for (int i = 0; i < cpu_num; i++) { | 38 for (int i = 0; i < cpu_num; i++) { |
39 pthread_join(threads[i], NULL); | 39 pthread_join(threads[i], NULL); |
40 } | 40 } |
41 | 41 |
42 for (int i = 0; i < cpu_num; i++) { | 42 for (int i = 0; i < cpu_num; i++) { |
43 delete args[i].scheduler; | 43 delete args[i].scheduler; |
44 } | 44 } |
45 | 45 |
46 delete [] threads; | 46 delete [] threads; |
47 delete [] args; | 47 delete [] args; |
48 #ifdef __CERIUM_GPU__ | 48 #ifdef __CERIUM_GPU__ |
63 manager->set_scheduler(c_scheduler); | 63 manager->set_scheduler(c_scheduler); |
64 | 64 |
65 SchedRegister(ShowTime); | 65 SchedRegister(ShowTime); |
66 SchedRegister(StartProfile); | 66 SchedRegister(StartProfile); |
67 | 67 |
68 argt->wait->sem_v(); //準備完了したスレッドができるたびに+1していく | 68 argt->wait->sem_v(); //準備完了したスレッドができるたびに+1していく |
69 | 69 |
70 c_scheduler->run(new SchedNop()); | 70 c_scheduler->run(new SchedNop()); |
71 c_scheduler->finish(); | 71 c_scheduler->finish(); |
72 | 72 |
73 return NULL; | 73 return NULL; |
89 args[i].wait = wait; | 89 args[i].wait = wait; |
90 args[i].useRefDma = use_refdma; | 90 args[i].useRefDma = use_refdma; |
91 } | 91 } |
92 | 92 |
93 for (int i = 0; i < cpu_num; i++) { | 93 for (int i = 0; i < cpu_num; i++) { |
94 pthread_create(&threads[i], NULL, | 94 pthread_create(&threads[i], NULL, |
95 &cpu_thread_run, (void*)&args[i]); | 95 &cpu_thread_run, (void*)&args[i]); |
96 } | 96 } |
97 | 97 |
98 for (int i = 0; i < cpu_num; i++) { | 98 for (int i = 0; i < cpu_num; i++) { |
99 wait->sem_p(); | 99 wait->sem_p(); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 /** | 103 /** |
104 * このCPU からのメールを受信する。 | 104 * このCPU からのメールを受信する。 |
108 * @return Received 32-bit mailbox messages | 108 * @return Received 32-bit mailbox messages |
109 * if ([ret] < 0) no data read | 109 * if ([ret] < 0) no data read |
110 */ | 110 */ |
111 int | 111 int |
112 CpuThreads::get_mail(int cpuid, int count, memaddr *ret) | 112 CpuThreads::get_mail(int cpuid, int count, memaddr *ret) |
113 { | 113 { |
114 #ifdef __CERIUM_GPU__ | 114 #ifdef __CERIUM_GPU__ |
115 if (is_gpu(cpuid)) return gpu->get_mail(cpuid, count, ret); | 115 if (is_gpu(cpuid)) return gpu->get_mail(cpuid, count, ret); |
116 #endif | 116 #endif |
117 *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); | 117 *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); |
118 return 1; | 118 return 1; |
127 if (args[cpuid-id_offset].scheduler->has_mail_from_host() != 0) { | 127 if (args[cpuid-id_offset].scheduler->has_mail_from_host() != 0) { |
128 return get_mail(cpuid,count,ret); | 128 return get_mail(cpuid,count,ret); |
129 } else { | 129 } else { |
130 return 0; //mailがないとき0を返す | 130 return 0; //mailがないとき0を返す |
131 } | 131 } |
132 | 132 |
133 } | 133 } |
134 /** | 134 /** |
135 * Inbound Mailbox | 135 * Inbound Mailbox |
136 * メール送信 Front End -> CPU | 136 * メール送信 Front End -> CPU |
137 * | 137 * |