57
|
1 #include <stdio.h>
|
|
2 #include <stdlib.h>
|
|
3 #include "CellTaskListInfo.h"
|
|
4
|
60
|
5 #define NEXT_ADDR(addr, size) \
|
|
6 (TaskListPtr)((int)(addr) + (size))
|
|
7
|
57
|
8 int
|
|
9 CellTaskListInfo::extend_pool(int num)
|
|
10 {
|
60
|
11 TaskListPtr q = NULL;
|
57
|
12 int unit_size;
|
|
13
|
109
|
14 unit_size = (ROUND_UP_ALIGN(sizeof(TaskList), DEFAULT_ALIGNMENT));
|
|
15 posix_memalign((void**)&q, DEFAULT_ALIGNMENT, unit_size*(num+1));
|
57
|
16
|
|
17 if (q == NULL) {
|
|
18 return -1;
|
|
19 }
|
|
20
|
|
21 q->next = taskListPool;
|
|
22 taskListPool = q;
|
|
23
|
|
24 /* Connect all free pack_list in the pool */
|
60
|
25 q = NEXT_ADDR(taskListPool, unit_size); // q = taskListPool + 1;
|
|
26 for (; --num > 0; q = NEXT_ADDR(q, unit_size)) {
|
|
27 q->next = NEXT_ADDR(q, unit_size); // q->next = q + 1;
|
57
|
28 }
|
|
29 q->next = freeTaskList;
|
|
30 freeTaskList = NEXT_ADDR(taskListPool, unit_size);
|
|
31
|
|
32 return 0;
|
|
33 }
|