annotate TaskManager/kernel/ppe/HTaskInfo.cc @ 47:8266445bdac2

*** empty log message ***
author gongo
date Fri, 15 Feb 2008 13:09:58 +0900
parents f154d9d07a42
children 90523ccc4dff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
46
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
1 #include <stdio.h>
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
2 #include <stdlib.h>
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
3 #include "HTaskInfo.h"
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
4
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
5 HTaskInfo::HTaskInfo(void)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
6 :htaskPool(NULL), freeHTask(NULL) {}
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
7
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
8 HTaskInfo::~HTaskInfo(void) { destroy(); }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
9
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
10 int
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
11 HTaskInfo::init(int num)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
12 {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
13 if (htaskPool == NULL) {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
14 return extend_pool(num);
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
15 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
16 return 0;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
17 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
18
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
19 /**
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
20 * Fix me
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
21 * extend できる限界を設定するべき?
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
22 */
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
23 int
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
24 HTaskInfo::extend_pool(int num)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
25 {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
26 HTaskPtr q = NULL;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
27
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
28 q = (HTaskPtr)malloc(sizeof(HTask)*(num+1));
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
29
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
30 if (q == NULL) {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
31 return -1;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
32 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
33 q->next = htaskPool;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
34 htaskPool = q;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
35
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
36 /* Connect all free queue in the pool */
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
37 for (q = htaskPool + 1; --num > 0; q++) {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
38 q->next = q + 1;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
39 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
40 q->next = freeHTask;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
41 freeHTask = htaskPool + 1;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
42
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
43 return 0;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
44 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
45
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
46 HTaskPtr
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
47 HTaskInfo::create(int cmd, int size,
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
48 unsigned long long in_addr,
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
49 unsigned long long out_addr)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
50 {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
51 HTaskPtr q;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
52
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
53 if (freeHTask == NULL) {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
54 extend_pool(100);
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
55 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
56
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
57 q = freeHTask;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
58 freeHTask = freeHTask->next;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
59
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
60 q->command = cmd;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
61 q->in_addr = in_addr;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
62 q->out_addr = out_addr;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
63 q->in_size = size;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
64 q->wait_me = NULL;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
65 q->wait_i = NULL;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
66 q->post_func = NULL;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
67
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
68 return q;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
69 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
70
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
71 void
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
72 HTaskInfo::free(HTaskPtr q)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
73 {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
74 q->next = freeHTask;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
75 freeHTask = q;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
76 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
77
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
78 void
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
79 HTaskInfo::destroy(void)
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
80 {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
81 HTaskPtr q;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
82
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
83 for (q = htaskPool; q; q = q->next) {
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
84 free(q);
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
85 }
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
86 freeHTask = htaskPool = NULL;
f154d9d07a42 *** empty log message ***
gongo
parents:
diff changeset
87 }