changeset 466:4fa8760e18c2

prohibit global variable in Task....
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 01 Oct 2009 17:33:58 +0900
parents 40af9fc1d428
children 44c0bce54dcf
files TaskManager/kernel/schedule/SchedTask.cc TaskManager/kernel/schedule/SchedTask.h example/get_segment/ppe/Hello.cc example/get_segment/ppe/Hello1.cc example/get_segment/spe/Hello.cc example/get_segment/spe/Hello1.cc example/get_segment/spe/fixpic.pl
diffstat 7 files changed, 55 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/schedule/SchedTask.cc	Wed Sep 30 11:37:15 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.cc	Thu Oct 01 17:33:58 2009 +0900
@@ -6,6 +6,7 @@
 #include "DmaManager.h"
 #include "error.h"
 #include "TaskManager.h"
+#include <stdarg.h>
 
 extern Scheduler::TaskObject task_list[MAX_TASK_OBJECT];
 
@@ -49,6 +50,9 @@
     __renew_flag  = 0;
     __cur_index   = 0;
     __flag_renewTask = SCHED_TASK_NORMAL;
+    this->stdout_ = stdout;
+    this->stderr_ = stderr;
+    this->stdin_ = stdin;
 
     ex_init  = &SchedTask::ex_init_normal;
     ex_read  = &SchedTask::ex_read_normal;
@@ -609,6 +613,28 @@
     __scheduler->wait_segment(s);
 }
 
+/* system call */
+
+int 
+SchedTask::fprintf(FILE * stream, const char * format, ...)
+{
+    va_list ap;
+    va_start(ap,format);
+    int ret = vfprintf(stream,format, ap);
+    va_end(ap);
+    return ret;
+}
+
+int 
+SchedTask::printf(const char * format, ...)
+{
+    va_list ap;
+    va_start(ap,format);
+    int ret= vfprintf(stdout,format, ap);
+    va_end(ap);
+    return ret;
+}
+
 
 
 /* end */
--- a/TaskManager/kernel/schedule/SchedTask.h	Wed Sep 30 11:37:15 2009 +0900
+++ b/TaskManager/kernel/schedule/SchedTask.h	Thu Oct 01 17:33:58 2009 +0900
@@ -1,6 +1,7 @@
 #ifndef INCLUDED_SCHED_TASK
 #define INCLUDED_SCHED_TASK
 
+#include <stdio.h>
 #include "base.h"
 #include "Scheduler.h"
 #include "SchedTaskBase.h"
@@ -150,6 +151,15 @@
     void* get_output(int index) {
       return get_output(__writebuf, index);
     }
+
+    /* system call */
+
+    FILE *stdout_;
+    FILE *stderr_;
+    FILE *stdin_;
+    int fprintf(FILE * stream, const char * format, ...);
+    int printf(const char * format, ...);
+
 };
 
 const int SCHED_TASK_NORMAL = 0;
--- a/example/get_segment/ppe/Hello.cc	Wed Sep 30 11:37:15 2009 +0900
+++ b/example/get_segment/ppe/Hello.cc	Thu Oct 01 17:33:58 2009 +0900
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include "Hello.h"
 #include "Func.h"
 
@@ -35,8 +34,8 @@
 #endif
 
 
-    fprintf(stderr,"sizeof(int) = [%d] sizeof(void*)=[%d]\n", (int)sizeof(int),(int)sizeof(void*));
-    fprintf(stderr,"[%d] Main Mem %0x len %d\n", task_id, (unsigned int)next,(int)SIZE);
+    smanager->fprintf(smanager->stderr_,"sizeof(int) = [%d] sizeof(void*)=[%d]\n", (int)sizeof(int),(int)sizeof(void*));
+    smanager->fprintf(smanager->stderr_,"[%d] Main Mem %0x len %d\n", task_id, (unsigned int)next,(int)SIZE);
 
     return 0;
 }
--- a/example/get_segment/ppe/Hello1.cc	Wed Sep 30 11:37:15 2009 +0900
+++ b/example/get_segment/ppe/Hello1.cc	Thu Oct 01 17:33:58 2009 +0900
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include "Hello1.h"
 #include "Func.h"
 
@@ -35,8 +34,8 @@
 #endif
 
 
-    fprintf(stderr,"Hello1 sizeof(int) = [%d] sizeof(void*)=[%d]\n", (int)sizeof(int),(int)sizeof(void*));
-    fprintf(stderr,"[%d] Main Mem %0x len %d\n", task_id, (unsigned int)next,(int)SIZE);
+    smanager->fprintf(smanager->stderr_,"Hello1 sizeof(int) = [%d] sizeof(void*)=[%d]\n", (int)sizeof(int),(int)sizeof(void*));
+    smanager->fprintf(smanager->stderr_,"[%d] Main Mem %0x len %d\n", task_id, (unsigned int)next,(int)SIZE);
 
     return 0;
 }
--- a/example/get_segment/spe/Hello.cc	Wed Sep 30 11:37:15 2009 +0900
+++ b/example/get_segment/spe/Hello.cc	Thu Oct 01 17:33:58 2009 +0900
@@ -13,8 +13,8 @@
     unsigned int pc;
     __asm__ __volatile__("ai %0,$0,0 ### here" : "=r" (pc));
 
-    fprintf(stderr,"[%d] Hello, World!! Seg1 \n", task_id);
-    fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello);
+    smanager->fprintf(smanager->stderr_,"[%d] Hello, World!! Seg1 \n", task_id);
+    smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello);
 
     return 0;
 }
--- a/example/get_segment/spe/Hello1.cc	Wed Sep 30 11:37:15 2009 +0900
+++ b/example/get_segment/spe/Hello1.cc	Thu Oct 01 17:33:58 2009 +0900
@@ -1,4 +1,3 @@
-#include <stdio.h>
 #include "Hello1.h"
 #include "Func.h"
 
@@ -14,8 +13,8 @@
     __asm__ __volatile__("ai %0,$0,0 ### here" : "=r" (pc));
 
 
-    fprintf(stderr,"[%d] Hello, World Seg 2!!\n", task_id);
-    fprintf(stderr,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello1);
+    smanager->fprintf(smanager->stderr_,"[%d] Hello, World Seg 2!!\n", task_id);
+    smanager->fprintf(smanager->stderr_,"pc=0x%0x 0x%0x\n",pc, (unsigned int)&runTask_Hello1);
 
     return 0;
 }
--- a/example/get_segment/spe/fixpic.pl	Wed Sep 30 11:37:15 2009 +0900
+++ b/example/get_segment/spe/fixpic.pl	Thu Oct 01 17:33:58 2009 +0900
@@ -54,18 +54,18 @@
 		s/brsl/brasl/ ||
 		s/br/bra/ ;
           }
-       } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) {
-          my $name = $2;
-          if (! defined $local{$name} || defined $weak{$name} ) {
+#       } elsif(/\s(lqr)\s+(\$\d+),([^\s]+)/) {
+#          my $name = $2;
+#          if (! defined $local{$name} || defined $weak{$name} ) {
 #	    s/lqr/lqd/;
-          }
-       } elsif(/\s(ila)\s+(\$\d+),([^\s]+)/) {
-          my $name = $3;
-          if (! defined $local{$name} || defined $weak{$name} ) {
-	    $_ = $_;
-	  } else {
-	    $_ = "\tai\t$2,\$0,$3-.\n";
-          }
+#          }
+#       } elsif(/\s(ila)\s+(\$\d+),([^\s]+)/) {
+#          my $name = $3;
+#          if (! defined $local{$name} || defined $weak{$name} ) {
+#	    $_ = $_;
+#	  } else {
+#	    $_ = "\tai\t$2,\$0,$3-.\n";
+#          }
        }
     }
     print ;