annotate TaskManager/kernel/ppe/TaskManager.cc @ 20:31a7ff27ee20

*** empty log message ***
author gongo
date Sun, 10 Feb 2008 13:46:26 +0900
parents 0c9341da4522
children db136fb5c21d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
1 #include "TaskManager.h"
14
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
2 #include "SymTable.h"
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
4 TaskManager::TaskManager(int num)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
5 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
6 machineNum = num;
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
7 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
8
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
9 /**
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
10 * create_impl(int);
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
11 *
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
12 * [cell版] ../../Cell/SpeTaskManagerImpl.cpp
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
13 * [fifo版] ../../Fifo/FifoTaskManagerImpl.cpp
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
14 * で定義されています。コンパイル時に
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
15 *
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
16 * % make cell ってすると cell 版が、
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
17 * % make fifo ってすると fifo 版 がリンクされるようにしているので
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
18 * それに応じて create_impl が返す値を変えています。
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
19 * cell だったら SpeManagerImpl, fifo だったら FifoManagerImpl です。
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
20 *
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
21 * 今までは ifdef CELL とか書いてましたわ。どっちがいいかね
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
22 *
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
23 * てか、普通に TaskManagerImpl に関数持たせた方が早いか・・・?
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
24 */
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
25 extern TaskManagerImpl* create_impl(int);
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
26
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
27 void
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
28 TaskManager::init(void)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
29 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
30 m_impl = create_impl(machineNum);
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
31 m_impl->init();
14
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
32
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
33 symtb = new SymTable;
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
34 symtb->init();
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
35 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
36
20
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
37 void
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
38 TaskManager::finish(void)
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
39 {
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
40 delete m_impl;
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
41 delete symtb;
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
42 }
31a7ff27ee20 *** empty log message ***
gongo
parents: 18
diff changeset
43
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
44 /**
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
45 * @param command Task executes method number
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
46 * @param in_size Size of data
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
47 * @param in_addr Input address of data
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
48 * @param out_addr Output address of data
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
49 * @param func When this task ends, func execute.
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
50 *
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
51 * @return this task
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
52 */
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
53
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
54 HTaskPtr
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
55 TaskManager::create_task(int cmd, int size, unsigned long long in_addr,
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
56 unsigned long long out_addr, void (*func)(void))
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
57 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
58 return m_impl->create_task(cmd, size, in_addr, out_addr, func);
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
59 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
60
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
61 void
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
62 TaskManager::set_task_depend(HTaskPtr master, HTaskPtr slave)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
63 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
64 m_impl->set_task_depend(master, slave);
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
65 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
66
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
67 void
18
0c9341da4522 *** empty log message ***
gongo
parents: 14
diff changeset
68 TaskManager::spawn_task(HTaskPtr task)
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
69 {
18
0c9341da4522 *** empty log message ***
gongo
parents: 14
diff changeset
70 m_impl->spawn_task(task);
3
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
71 }
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
72
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
73 void
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
74 TaskManager::run(void)
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
75 {
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
76 m_impl->run();
2356238ebea7 *** empty log message ***
gongo
parents:
diff changeset
77 }
14
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
78
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
79 /**
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
80 * initialize task だから(?)、
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
81 * read/write/post/func はなしって最初から決めうちだけど
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
82 * いいのかな。いいのか?
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
83 */
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
84 void
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
85 TaskManager::set_init_task(const char *sym)
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
86 {
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
87 HTaskPtr init;
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
88 int init_fd;
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
89
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
90 init_fd = open(sym);
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
91 init = m_impl->create_task(init_fd, 0, 0, 0, 0);
18
0c9341da4522 *** empty log message ***
gongo
parents: 14
diff changeset
92 spawn_task(init);
14
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
93 }
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
94
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
95
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
96
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
97 // ここは、バイナリから自動的に読めるとうれしいけど
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
98 // どうやるんだろうね。ユーザに追加させるのはめんどくさい
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
99 void
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
100 TaskManager::set_symbol(const char *sym, void *addr)
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
101 {
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
102 symtb->set_symbol(sym, addr);
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
103 }
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
104
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
105 /**
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
106 * open というか、今は topen (task open) ? 違うな
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
107 */
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
108 int
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
109 TaskManager::open(const char *sym)
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
110 {
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
111 return symtb->get_fd(sym);
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
112 }
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
113
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
114 void*
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
115 TaskManager::get_address(int fd)
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
116 {
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
117 return symtb->get_address(fd);
41ccd4b38184 *** empty log message ***
gongo
parents: 3
diff changeset
118 }