Mercurial > hg > Game > Cerium
diff TaskManager/kernel/ppe/CpuThreads.cc @ 1176:fc4a96198ed3 draft
Semaphore Syncronized queue.
author | Daichi TOMA <amothic@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Tue, 07 Jun 2011 18:07:57 +0900 |
parents | c7d737993da7 |
children | 730f5e5c8351 |
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/CpuThreads.cc Tue Jun 07 17:55:20 2011 +0900 +++ b/TaskManager/kernel/ppe/CpuThreads.cc Tue Jun 07 18:07:57 2011 +0900 @@ -25,6 +25,9 @@ delete [] threads; delete [] args; + + /* セマフォ変数の破棄 */ + sem_destroy(&sem); } void * @@ -60,6 +63,11 @@ pthread_create(&threads[i], NULL, &cpu_thread_run, (void*)&args[i]); } + /* セマフォ変数の定義 */ + sem_t sem; + + /* セマフォ変数の初期化 */ + sem_init(&sem, 0, 1); } /** @@ -74,7 +82,9 @@ CpuThreads::get_mail(int cpuid, int count, memaddr *ret) { // need synchronization + sem_wait(&sem); *ret = args[cpuid-id_offset].scheduler->mail_read_from_host(); + sem_post(&sem); return 1; } @@ -82,7 +92,9 @@ CpuThreads::has_mail(int cpuid, int count, memaddr *ret) { // need synchronization + sem_wait(&sem); return args[cpuid-id_offset].scheduler->has_mail_from_host(); + sem_post(&sem); } /** @@ -104,7 +116,9 @@ { // need synchronization + sem_wait(&sem); args[cpuid-id_offset].scheduler->mail_write_from_host(*data); + sem_post(&sem); }