5
|
1 #include <stdio.h>
|
3
|
2 #include "TaskManagerImpl.h"
|
|
3
|
|
4 void
|
|
5 noaction(void)
|
|
6 {
|
|
7 }
|
|
8
|
|
9 TaskManagerImpl::TaskManagerImpl(int num)
|
|
10 {
|
|
11 machineNum = num;
|
|
12 }
|
|
13
|
|
14 HTaskPtr
|
|
15 TaskManagerImpl::create_task(int cmd, int size,
|
|
16 unsigned long long in_addr,
|
|
17 unsigned long long out_addr,
|
|
18 void (*func)(void))
|
|
19 {
|
|
20 HTaskPtr new_task;
|
|
21
|
|
22 new_task = taskInfo->get_free_task(cmd, size, in_addr, out_addr);
|
|
23
|
|
24 if (func == NULL) {
|
|
25 new_task->post_func = noaction;
|
|
26 } else {
|
|
27 new_task->post_func = func;
|
|
28 }
|
|
29
|
|
30 return new_task;
|
|
31 }
|
|
32
|
|
33 /**
|
|
34 * task の依存関係を設定
|
|
35 * master task が終わってから、slave task を実行するように
|
|
36 */
|
|
37 void
|
|
38 TaskManagerImpl::set_task_depend(HTaskPtr master, HTaskPtr slave)
|
|
39 {
|
|
40 TaskQueuePtr m, s;
|
|
41
|
|
42 m = taskInfo->get_free_taskQueue(master);
|
|
43 s = taskInfo->get_free_taskQueue(slave);
|
|
44
|
|
45 master->wait_me = append_taskQueue(master->wait_me, s);
|
|
46 slave->wait_i = append_taskQueue(slave->wait_i, m);
|
|
47 }
|
|
48
|
|
49 void
|
18
|
50 TaskManagerImpl::spawn_task(HTaskPtr task)
|
3
|
51 {
|
|
52 if (task->wait_i == NULL) {
|
|
53 taskInfo->append_activeTask(task);
|
|
54 } else {
|
|
55 taskInfo->append_waitTask(task);
|
|
56 }
|
|
57 }
|