diff TaskManager/kernel/schedule/SchedTask.h @ 366:09f33c51a204

rename include/TaskManager/* and add memory
author aaa
date Mon, 27 Jul 2009 15:51:18 +0900
parents include/TaskManager/SchedTask.h@b89ba1d96fff
children eab18aa0c7f6
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/schedule/SchedTask.h	Mon Jul 27 15:51:18 2009 +0900
@@ -0,0 +1,159 @@
+#ifndef INCLUDED_SCHED_TASK
+#define INCLUDED_SCHED_TASK
+
+#include "base.h"
+#include "Scheduler.h"
+#include "SchedTaskBase.h"
+#include "ListData.h"
+#include "TaskGroup.h"
+
+class SchedTask : public SchedTaskBase {
+public:
+    /* constructor */
+    SchedTask();
+    virtual ~SchedTask();
+
+    BASE_NEW_DELETE(SchedTask);
+
+    SchedTask *smanager;
+
+private:
+    /* variables */
+
+    // Task を実行するスケジューラ自身
+    Scheduler *__scheduler;
+
+    // 現在スケジューラが実行している TaskList と、このタスクに対応する Task
+    TaskListPtr __list;
+    TaskPtr __task;
+
+    // read/write 用の ListData
+    ListDataPtr __inListData;
+    ListDataPtr __outListData;
+
+    /**
+     * read データ、write 用のバッファ
+     * readbuf には タスク登録時に設定した入力データが入っている。
+     * writebuf にデータを描き込んでおくと、
+     * タスク登録時に設定した出力先に書き込む
+     */
+    void *__readbuf;
+    void *__writebuf;
+
+    // Task の、Tasklist での位置。(task = &list[cur_index-1])
+    int __cur_index;
+
+    // タスク内で生成されたタスクのグループ
+    TaskGroup *__taskGroup;
+
+    // このタスク内で生成されたタスクの数
+    int __renew_flag;
+
+    // このタスクが SPE 内で生成されたタスクか否か 1: Yes, 0: No
+    int __flag_renewTask;
+
+    // タスクがメインメモリ側で生成されたものか、
+    // SPE で生成されたものかによって、データの扱いが変わってくる。
+    // そのために if (__flag_renewTask) を連発するのはよくないので
+    // 関数ポインタで持っておく
+    void (SchedTask::*ex_init)();
+    void (SchedTask::*ex_read)();
+    void (SchedTask::*ex_exec)();
+    void (SchedTask::*ex_write)();
+    SchedTaskBase* (SchedTask::*ex_next)();
+   
+    /* functions */
+
+    // override
+    void read();
+    void exec();
+    void write();
+    SchedTaskBase* next(Scheduler *, SchedTaskBase *);
+
+    // ここをユーザが継承して
+    // それぞれのタスクに対応した処理を記述する
+    virtual int run(SchedTask* smanager, void* r, void *w) { return 0; }
+    virtual int run(void* r, void *w) { return 0; }
+
+    int (SchedTask::*run_func)(void* r, void *w);
+    int (SchedTask::*run_func1)(SchedTask* smanager, void* r, void *w);
+
+    //---  System API ---
+    SchedTask* get_nextTask(TaskListPtr list);
+    
+    /**
+     * PPE で生成されたタスクに対する
+     * __init__, read,exec,write,next の付属(?)処理
+     */
+    void ex_init_normal();
+    void ex_read_normal();
+    void ex_exec_normal();
+    void ex_write_normal();
+    SchedTaskBase* ex_next_normal();
+
+    /**
+     * SPE で生成されたタスクに対する
+     * __inti__, ead,exec,write,next の付属(?)処理
+     */
+    void ex_init_renew();
+    void ex_read_renew();
+    void ex_exec_renew();
+    void ex_write_renew();
+    SchedTaskBase* ex_next_renew();
+
+public:
+    /* functions */
+
+    void __setRenew();
+    void __init__(TaskListPtr _list, TaskPtr _task, int index,
+		  ListDataPtr rbuf, ListDataPtr wbuf, Scheduler* sc);
+
+    //---  User API ---
+    int get_cpuid();
+
+    void* get_input(void *buff, int index);
+    void* get_output(void *buff, int index);
+    uint32 get_inputAddr(int index);
+    uint32 get_outputAddr(int index);
+    int get_inputSize(int index);
+    int get_outputSize(int index);
+    int get_param(int index);
+
+    TaskPtr create_task(int cmd);
+    void wait_task(TaskPtr waitTask);
+
+    void* global_alloc(int id, int size);
+    void* global_get(int id);
+    void global_free(int id);
+
+    void mainMem_alloc(int id, int size);
+    void mainMem_wait();
+    void* mainMem_get(int id);
+
+    void *allocate(int size);
+
+    void dma_load(void *buf, uint32 addr, uint32 size, uint32 mask);
+    void dma_store(void *buf,uint32 addr, uint32 size, uint32 mask);
+    void dma_wait(uint32 mask);
+    void show_dma_wait();
+    
+    /*!
+      SPU用の get_input, get_output
+     */
+
+    void* get_input(int index) {
+      return get_input(__readbuf, index);
+    }
+    
+    void* get_output(int index) {
+      return get_output(__writebuf, index);
+    }     
+};
+
+const int SCHED_TASK_NORMAL = 0;
+const int SCHED_TASK_RENEW  = 1;
+
+extern SchedTask* createSchedTask(TaskPtr);
+
+#endif
+