changeset 1078:6dabcd1a9ccf draft

add MAIN MEM MALLOC
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sat, 18 Dec 2010 09:43:08 +0900
parents 325b6c6d7d65
children 7823233584da
files TaskManager/Fifo/FifoTaskManagerImpl.cc
diffstat 1 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/Fifo/FifoTaskManagerImpl.cc	Fri Dec 17 02:23:09 2010 +0900
+++ b/TaskManager/Fifo/FifoTaskManagerImpl.cc	Sat Dec 18 09:43:08 2010 +0900
@@ -13,7 +13,7 @@
 
 extern  QueueInfo<TaskList> *taskListPool;
 
-// static void send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s);
+static void send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s);
 
 FifoTaskManagerImpl::~FifoTaskManagerImpl()
 {
@@ -182,10 +182,7 @@
         } else if (data == (memaddr)MY_SPE_COMMAND_EXIT) {
             __debug_ppe("mail_check(): Task List finish COMMAND\n");
 	} else if (data == (memaddr)MY_SPE_COMMAND_MALLOC) {
-	    // MY_SPE_COMMAND_MALLOC   PPE からのmain memory request
-	    // 本来は呼ばれないはず...
-	    get_scheduler()->printf("error: MY_SPE_COMMAND_MALLOC from PPE\n");
-	    // send_alloc_reply(this, 0, mainScheduler);
+	    send_alloc_reply(this, 0, mainScheduler);
         } else if (data != (memaddr)MY_SPE_NOP) {
             __debug_ppe("mail_check(): recv from 0x%x\n", data);
 	    // post_func を先に実行しないと、systask_finish が active_queue
@@ -209,6 +206,36 @@
 	others->polling();
 }
 
+static void
+send_alloc_reply(FifoTaskManagerImpl *tm, int id, MainScheduler *s)
+{
+
+    /**
+     * info[0] = alloc_id; (CellScheduler::mainMem_alloc 参照)
+     * info[1] = alloc_addr;
+     */
+    memaddr alloc_info[2];
+    long alloc_size;
+    long command;
+    
+    alloc_info[0] = s->mail_read_from_host();
+    alloc_info[1] = s->mail_read_from_host();
+    command = (long)alloc_info[0];
+    alloc_size = (long)alloc_info[1];
+
+    
+    alloc_info[1] = (memaddr)tm->allocate(alloc_size);
+    //__debug_ppe("[PPE] MALLOCED 0x%lx from [SPE %d]\n", alloc_info[1],id);
+    // 今のところ何もしてない。どうも、この allocate を free 
+    // するのは、SPE task が返した値を見て行うらしい。それは、
+    // 忘れやすいのではないか?
+    // s->add_output_tasklist(command, alloc_info[1], alloc_size);
+
+    s->mail_write_from_host(alloc_info[0]);
+    s->mail_write_from_host(alloc_info[1]);
+}
+
+
 void
 FifoTaskManagerImpl::print_arch()
 {