annotate src/context.h @ 93:7d0ec88cdd22

fix read interface
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Sat, 19 Oct 2019 18:44:57 +0900
parents bc5bcfd2f6d6
children d876c9a65239
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
1 /* Context definition for llrb example */
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
2 // #ifdef CBC_CONTEXT_H does not work well
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
3 #define CBC_CONTEXT_H
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
4 // #include <stdlib.h>
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
5 // #include <pthread.h>
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
6 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
7 #include <cuda.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
8 #include <driver_types.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
9 #include <cuda_runtime.h>
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
10 #include "helper_cuda.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
11 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
12
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
13 #include "types.h"
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
14 #include "use_context_numbers.h"
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
15 #include "fs.h"
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
16 #include "defs.h"
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
17
62
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
18 #ifdef XV6KERNEL
53
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
19 #define calloc(a,b) kmalloc((a)*(b))
435bfab09924 fix cmakefiles
kono
parents: 52
diff changeset
20 #define free(a) kfree(a)
62
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
21 #else
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
22 #define calloc(a,b) malloc((a)*(b))
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
23 #define free(a) free(a)
a28580a75faa fix build fs.img
anatofuz
parents: 53
diff changeset
24 #endif
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
25
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
26 #define ALLOCATE_SIZE 20000000
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
27 #define NEW(type) (type*)(calloc(1, sizeof(type)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
28 #define NEWN(n, type) (type*)(calloc(n, sizeof(type)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
29
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
30 #define ALLOC_DATA(cbc_context, dseg) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
31 Meta* meta = (Meta*)cbc_context->heap;\
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
32 meta->type = D_##dseg;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
33 meta->size = sizeof(dseg);\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
34 meta->len = 1;\
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
35 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
36 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(dseg); (dseg *)cbc_context->data[D_##dseg]; })
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
37
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
38 #define ALLOC_DATA_TYPE(cbc_context, dseg, t) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
39 Meta* meta = (Meta*)cbc_context->heap;\
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
40 meta->type = D_##t;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
41 meta->size = sizeof(t);\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
42 meta->len = 1;\
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
43 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
44 cbc_context->data[D_##dseg] = cbc_context->heap; cbc_context->heap += sizeof(t); (t *)cbc_context->data[D_##dseg]; })
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
45
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
46 #define ALLOCATE(cbc_context, t) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
47 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
48 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
49 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
50 cbc_context->heap += sizeof(t); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
51 meta->type = D_##t; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
52 meta->size = sizeof(t); \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
53 meta->len = 1;\
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
54 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
55
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
56 #define ALLOCATE_ARRAY(cbc_context, t, length) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
57 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
58 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
59 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
60 cbc_context->heap += sizeof(t)*length; \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
61 meta->type = D_##t; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
62 meta->size = sizeof(t)*length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
63 meta->len = length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
64 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
65
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
66 #define ALLOCATE_PTR_ARRAY(cbc_context, dseg, length) ({\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
67 Meta* meta = (Meta*)cbc_context->heap;\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
68 cbc_context->heap += sizeof(Meta);\
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
69 union Data* data = cbc_context->heap; \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
70 cbc_context->heap += sizeof(dseg *)*length; \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
71 meta->type = D_##dseg; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
72 meta->size = sizeof(dseg *)*length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
73 meta->len = length; \
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
74 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
75
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
76 #define ALLOCATE_DATA_GEAR(cbc_context, t) ({ \
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
77 union Data* data = ALLOCATE(cbc_context, t); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
78 Meta* meta = GET_META(data); \
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
79 meta->wait = createSynchronizedQueue(cbc_context); \
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
80 data; })
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
81
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
82 #define ALLOC(cbc_context, t) (&ALLOCATE(cbc_context, t)->t)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
83
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
84 #define GET_META(dseg) ((Meta*)(((void*)dseg) - sizeof(Meta)))
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
85 #define GET_TYPE(dseg) (GET_META(dseg)->type)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
86 #define GET_SIZE(dseg) (GET_META(dseg)->size)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
87 #define GET_LEN(dseg) (GET_META(dseg)->len)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
88 #define GET_WAIT_LIST(dseg) (GET_META(dseg)->wait)
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
89
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
90 #define Gearef(cbc_context, t) (&(cbc_context)->data[D_##t]->t)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
91
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
92 // (SingleLinkedStack *)cbc_context->data[D_Stack]->Stack.stack->Stack.stack
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
93
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
94 #define GearImpl(cbc_context, intf, name) (Gearef(cbc_context, intf)->name->intf.name)
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
95
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
96 #include "c/enumCode.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
97
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
98 enum Relational {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
99 EQ,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
100 GT,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
101 LT,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
102 };
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
103
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
104 #include "c/enumData.h"
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
105 #define NDIRECT 12 //fs.h
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
106
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
107 struct Context {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
108 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
109 struct Worker* worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
110 struct TaskManager* taskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
111 int codeNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
112 __code (**code) (struct Context*);
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
113 union Data **data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
114 void* heapStart;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
115 void* heap;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
116 long heapLimit;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
117 int dataNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
118
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
119 // task parameter
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
120 int idgCount; //number of waiting dataGear
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
121 int idg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
122 int maxIdg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
123 int odg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
124 int maxOdg;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
125 int gpu; // GPU task
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
126 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
127 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
128 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
129 int num_exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
130 CUmodule module;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
131 CUfunction function;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
132 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
133 /* multi dimension parameter */
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
134 int iterate;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
135 struct Iterator* iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
136 enum Code before;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
137 };
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
138
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
139 typedef int Int;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
140 #ifndef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
141 typedef unsigned long long CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
142 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
143 union Data {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
144 struct Meta {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
145 enum DataType type;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
146 long size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
147 long len;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
148 struct Queue* wait; // tasks waiting this dataGear
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
149 } Meta;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
150 struct Context Context;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
151 struct Timer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
152 union Data* timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
153 enum Code start;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
154 enum Code end;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
155 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
156 } Timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
157 struct TimerImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
158 double time;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
159 } TimerImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
160 struct LoopCounter {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
161 int i;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
162 } LoopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
163 struct TaskManager {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
164 union Data* taskManager;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
165 enum Code spawn; // start NEW cbc_context on the worker
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
166 enum Code spawnTasks; // start NEW tasks on the worker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
167 enum Code shutdown;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
168 enum Code incrementTaskCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
169 enum Code decrementTaskCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
170 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
171 enum Code next1;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
172 enum Code setWaitTask;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
173 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
174 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
175 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
176 } TaskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
177 struct TaskManagerImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
178 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
179 int numWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
180 int sendCPUWorkerIndex;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
181 int sendGPUWorkerIndex;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
182 int taskCount;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
183 // pthread_mutex_t mutex;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
184 struct Queue* activeQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
185 struct Worker** workers;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
186 struct Element* taskList;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
187 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
188 int cpu;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
189 int gpu;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
190 int io;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
191 int maxCPU;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
192 } TaskManagerImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
193 struct Worker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
194 union Data* worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
195 enum Code taskReceive;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
196 enum Code shutdown;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
197 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
198 struct Queue* tasks;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
199 // pthread_t thread;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
200 struct TaskManager* taskManager;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
201 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
202 } Worker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
203 struct CPUWorker {
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
204 // pthread_mutex_t mutex;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
205 // pthread_cond_t cond;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
206 struct Context* cbc_context;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
207 int id;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
208 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
209 } CPUWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
210 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
211 struct CUDAWorker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
212 CUdevice device;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
213 CUcbc_context cuCtx;
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
214 struct Context* cbc_context;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
215 int id;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
216 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
217 int deviceNum;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
218 struct Queue* tasks;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
219 int runFlag;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
220 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
221 int numStream;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
222 struct Executor* executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
223 CUstream *stream;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
224 } CUDAWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
225 #else
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
226 struct CUDAWorker {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
227 } CUDAWorker;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
228 #endif
92
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
229 struct CbCSysFile {
91
b5ddf6fb0a6d use CbCFile instead of File struct Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
230 struct file *f;
b5ddf6fb0a6d use CbCFile instead of File struct Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
231 int n;
b5ddf6fb0a6d use CbCFile instead of File struct Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
232 char *p;
92
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
233 struct UInteger* num;
91
b5ddf6fb0a6d use CbCFile instead of File struct Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
234 enum Code next;
b5ddf6fb0a6d use CbCFile instead of File struct Interface
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 87
diff changeset
235 enum Code read;
92
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
236 enum Code cbc_file_ret;
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
237 } CbCSysFile;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
238 struct Main {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
239 enum Code code;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
240 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
241 struct Queue* args;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
242 } Main;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
243 // Queue Interface
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
244 struct Queue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
245 union Data* queue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
246 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
247 enum Code whenEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
248 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
249 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
250 enum Code take;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
251 enum Code isEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
252 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
253 } Queue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
254 struct SingleLinkedQueue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
255 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
256 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
257 } SingleLinkedQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
258 struct SynchronizedQueue {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
259 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
260 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
261 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
262 } SynchronizedQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
263 // Stack Interface
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
264 struct Stack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
265 union Data* stack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
266 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
267 union Data* data1;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
268 enum Code whenEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
269 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
270 enum Code push;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
271 enum Code pop;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
272 enum Code pop2;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
273 enum Code isEmpty;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
274 enum Code get;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
275 enum Code get2;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
276 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
277 } Stack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
278 // Stack implementations
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
279 struct SingleLinkedStack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
280 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
281 } SingleLinkedStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
282 struct ArrayStack {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
283 int size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
284 int limit;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
285 struct Element* array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
286 } ArrayStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
287 // Stack implementation end
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
288 struct Element {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
289 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
290 struct Element* next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
291 } Element;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
292 struct Array {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
293 int prefix;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
294 Int* array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
295 } Array;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
296 struct Tree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
297 union Data* tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
298 struct Node* node;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
299 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
300 enum Code get;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
301 enum Code remove;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
302 enum Code clear;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
303 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
304 } Tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
305 struct RedBlackTree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
306 struct Node* root;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
307 struct Node* current; // reading node of original tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
308 struct Node* previous; // parent of reading node of original tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
309 struct Node* newNode; // writing node of new tree
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
310 struct Node* parent;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
311 struct Node* grandparent;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
312 struct Stack* nodeStack;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
313 enum Code findNodeNext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
314 int result;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
315 } RedBlackTree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
316 struct RotateTree {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
317 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
318 struct RedBlackTree* traverse;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
319 struct Tree* tree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
320 } RotateTree;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
321 struct Node {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
322 int key; // comparable data segment
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
323 union Data* value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
324 struct Node* left;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
325 struct Node* right;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
326 // need to balancing
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
327 enum Color {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
328 Red,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
329 Black,
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
330 // Red eq 0,Black eq 1. enum name convert intager.
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
331 } color;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
332 } Node;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
333 struct Atomic {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
334 union Data* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
335 union Data** ptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
336 union Data* oldData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
337 union Data* newData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
338 enum Code checkAndSet;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
339 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
340 enum Code fail;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
341 } Atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
342 struct AtomicReference {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
343 } AtomicReference;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
344 struct Semaphore {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
345 union Data* semaphore;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
346 enum Code p;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
347 enum Code v;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
348 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
349 } Semaphore;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
350 struct SemaphoreImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
351 int value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
352 struct Lock* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
353 struct Queue* waitThreadQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
354 } SemaphoreImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
355 struct Allocate {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
356 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
357 long size;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
358 } Allocate;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
359 struct Integer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
360 int value;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
361 } Integer;
92
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
362 struct UInteger {
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
363 unsigned int value;
bc5bcfd2f6d6 rename CbCFile to CbCSysFile
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 91
diff changeset
364 } UInteger;
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
365 struct SortArray {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
366 struct Integer *array; //Array arrayじゃできない?
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
367 int loopCounter;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
368 int block;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
369 int first;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
370 int prefix;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
371 } SortArray;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
372 struct Iterator {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
373 union Data* iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
374 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
375 int numGPU;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
376 enum Code exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
377 enum Code barrier;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
378 enum Code whenWait;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
379 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
380 } Iterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
381 struct MultiDimIterator {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
382 int x;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
383 int y;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
384 int z;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
385 int count;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
386 int counterX;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
387 int counterY;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
388 int counterZ;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
389 } MultiDimIterator;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
390 struct MultiDim {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
391 int x;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
392 int y;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
393 int z;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
394 } MultiDim;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
395 struct Executor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
396 union Data* executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
397 struct Context* task;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
398 enum Code read;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
399 enum Code exec;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
400 enum Code write;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
401 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
402 } Executor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
403 #ifdef USE_CUDAWorker
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
404 struct CUDAExecutor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
405 CUdeviceptr** kernelParams;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
406 struct CUDABuffer* buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
407 int maxThreadPerBlock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
408 int maxThreadPerBlockX;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
409 int maxThreadPerBlockY;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
410 int maxThreadPerBlockZ;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
411 struct Timer* timer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
412 } CUDAExecutor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
413 struct CUDABuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
414 int inputLen;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
415 int outputLen;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
416 union Data** inputData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
417 union Data** outputData;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
418 } CUDABuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
419 CUdeviceptr CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
420 #else
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
421 struct CUDAExecutor {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
422 } CUDAExecutor;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
423 struct CUDABuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
424 } CUDABuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
425 CUdeviceptr CUdeviceptr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
426 #endif
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
427 Int Int;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
428 struct Memory {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
429 union Data* adr;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
430 int length;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
431 union Data* body;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
432 int hash;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
433 } Memory;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
434 struct Buffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
435 union Data* buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
436 union Data* data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
437 enum Code put;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
438 enum Code take;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
439 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
440 } Buffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
441 struct BoundedBuffer {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
442 struct Element* top;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
443 struct Element* last;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
444 struct Semaphore* fullCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
445 struct Semaphore* emptyCount;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
446 struct Semaphore* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
447 } BoundedBuffer;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
448 struct Lock {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
449 union Data* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
450 enum Code doLock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
451 enum Code doUnlock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
452 enum Code next;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
453 } Lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
454 struct LockImpl {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
455 Int* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
456 struct Queue* waitThreadQueue;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
457 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
458 struct Context* lockContext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
459 } LockImpl;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
460 struct SpinLock {
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
461 volatile Int* lock;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
462 struct Atomic* atomic;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
463 struct Context* lockContext;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
464 } SpinLock;
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
465 /* CbCxv6 cbc_context*/
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
466 struct Inode {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
467 uint dev; // Device number
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
468 uint inum; // Inode number
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
469 int ref; // Reference count
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
470 int flags; // I_BUSY, I_VALID
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
471
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
472 short type; // copy of disk inode
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
473 short major;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
474 short minor;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
475 short nlink;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
476 uint size;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
477 uint addrs[NDIRECT+1];
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
478 } Inode;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
479 struct Uinteger {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
480 uint value;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
481 } Uinteger;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
482 struct Short {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
483 short value;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
484 } Short;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
485 struct String {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
486 char* string;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
487 } String;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
488 // fs.h ---
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
489 struct SuperBlock {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
490 uint size; // Size of file system image (blocks)
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
491 uint nblocks; // Number of data blocks
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
492 uint ninodes; // Number of inodes.
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
493 uint nlog; // Number of log blocks
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
494 } SuperBlock;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
495 struct Dinode {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
496 short type; // copy of disk inode
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
497 short major;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
498 short minor;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
499 short nlink;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
500 uint size;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
501 uint addrs[NDIRECT+1];
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
502 } Dinode;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
503 struct Dirent {
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
504 ushort inum;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
505 char name[DIRSIZ];
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
506 } Dirent;
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
507 // --- fs.h
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
508 }; // union Data end this is necessary for cbc_context generator
51
fadfd62d6b14 define filesystem DataGeas and ommit stdlib.h
anatofuz
parents: 47
diff changeset
509
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
510 typedef union Data Data;
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
511
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
512 #include "c/typedefData.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
513
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
514 #include "c/extern.h"
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
515
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
516 extern __code start_code(struct Context* cbc_context);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
517 extern __code exit_code(struct Context* cbc_context);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
518 extern __code meta(struct Context* cbc_context, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
519 //extern __code par_meta(struct Context* cbc_context, enum Code spawns, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
520 extern __code parGotoMeta(struct Context* cbc_context, enum Code next);
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
521 extern void initContext(struct Context* cbc_context);
41
087d7b61c86b cbc cmake version
kono
parents:
diff changeset
522
52
214d21c891c7 rename to cbc
kono
parents: 51
diff changeset
523 // #endif