changeset 1007:111e313e883e

merged
author ichikitakahiro <e165713@ie.u-ryukyu.ac.jp>
date Thu, 06 Jan 2022 22:53:52 +0900
parents d3355697c87c (current diff) 088e533b5393 (diff)
children 8c7015f602cf
files src/parallel_execution/CMakeLists.txt
diffstat 5 files changed, 54 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/CMakeLists.txt	Thu Jan 06 22:53:24 2022 +0900
+++ b/src/parallel_execution/CMakeLists.txt	Thu Jan 06 22:53:52 2022 +0900
@@ -240,7 +240,7 @@
   TARGET
     gearsDirectory
   SOURCES
-    TaskManagerImpl.cbc CPUWorker.cbc SingleLinkedQueue.cbc SingleLinkedStack.cbc AtomicReference.cbc SynchronizedQueue.cbc FileSystemTree.cbc EntryTree.cbc examples/gearsDirectory/GearsDirectoryImpl.cbc examples/gearsDirectory/GearsDirectory_test.cbc compare.c
+    TaskManagerImpl.cbc CPUWorker.cbc SingleLinkedQueue.cbc SingleLinkedStack.cbc AtomicReference.cbc SynchronizedQueue.cbc FileSystemTree.cbc examples/gearsDirectory/GearsDirectoryImpl.cbc examples/gearsDirectory/GearsDirectory_test.cbc compare.c
 )
 
 GearsCommand(
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectory.h	Thu Jan 06 22:53:24 2022 +0900
+++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectory.h	Thu Jan 06 22:53:52 2022 +0900
@@ -2,6 +2,7 @@
   union Data* gearsDirectory;
   struct Integer* name;
   __code mkdir(Impl* gearsDirectory, struct Integer* name, __code next(...));
+  __code ls(Impl* gearsDirectory, struct Integer* name, __code next(...));
   __code cd2Child(Impl* gearsDirectory, struct Integer* name, __code next(...));
   __code cd2Parent(Impl* gearsDirectory, __code next(...));
   __code next(...);
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc	Thu Jan 06 22:53:24 2022 +0900
+++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.cbc	Thu Jan 06 22:53:52 2022 +0900
@@ -2,13 +2,12 @@
 #interface "GearsDirectory.h"
 #interface "Stack.h"
 #interface "FTree.h"
-#interface "ETree.h"
 #interface "Integer.h"
 #impl "GearsDirectory.h" as "GearsDirectoryImpl.h"
 
 // ----
 // typedef struct GearsDirectoryImpl <> impl GearsDirectory {
-//   struct ETree* currentDirectory;
+//   struct FTree* currentDirectory;
 //   struct Stack* directoryStack;
 // } GearsDirectoryImpl;
 // ----
@@ -18,30 +17,56 @@
     struct GearsDirectoryImpl* gears_directory_impl = new GearsDirectoryImpl();
     gearsDirectory->gearsDirectory = (union Data*)gears_directory_impl;
 
-    struct ETree* firstDirectory = createEntryTree(context, NULL);
+    struct FTree* firstDirectory = createFileSystemTree(context, NULL);
     struct FTree* iNodeTree = createFileSystemTree(context, NULL);    
     gears_directory_impl->currentDirectory = firstDirectory;
     gears_directory_impl->iNodeTree = iNodeTree;
     gears_directory_impl->directoryStack = createSingleLinkedStack(context);
+    gears_directory_impl->INodeNumber = 0;
     gearsDirectory->mkdir = C_mkdirGearsDirectoryImpl;
+    gearsDirectory->ls = C_lsGearsDirectoryImpl;
     gearsDirectory->cd2Child = C_cd2ChildGearsDirectoryImpl;
     gearsDirectory->cd2Parent = C_cd2ParentGearsDirectoryImpl;
     return gearsDirectory;
 }
 
 __code mkdir(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) {
-    struct ETree* newDirectory = createEntryTree(context, gearsDirectory->currentDirectory);
-    Node* node = new Node();
-    node->value = newDirectory;
-    node->key = name->value;
-    struct ETree* cDirectory = new ETree();
+    struct FTree* newDirectory = createFileSystemTree(context, gearsDirectory->currentDirectory);
+    Node* inode = new Node();
+    // FIXME:inode numberのselectをしないといけない
+    inode->key = gearsDirectory->INodeNumber;
+    // FIXME:確保したinode領域にnewDirectoryを置かないといけない
+    inode->value = newDirectory;
+    struct FTree* cDirectory = new FTree();
+    cDirectory = gearsDirectory->iNodeTree;
+    goto cDirectory->put(inode, mkdir2);
+}
+
+__code mkdir2(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) {
+    Node* dir = new Node();
+    dir->key = name->value;
+    dir->value = gearsDirectory->INodeNumber;
+    struct FTree* cDirectory = new FTree();
     cDirectory = gearsDirectory->currentDirectory;
-    goto cDirectory->put(node, next(...));
+    goto cDirectory->put(dir, next(...));
+}
+
+__code ls(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) {
+    Node* dir = new Node();
+    dir->key = name->value;
+    struct FTree* cDirectory = new FTree();
+    cDirectory = gearsDirectory->currentDirectory;
+    goto cDirectory->get(dir, ls2);
+}
+
+__code ls2(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) {
+    printf("%d\n", gearsDirectory->currentDirectory->fTree->Node.value->Node.key);
+    goto next(...);
 }
 
 __code cd2Child(struct GearsDirectoryImpl* gearsDirectory, struct Integer* name, __code next(...)) {
     // 現在のtreeからnode->keyがnameと一致するものをsearch
-    struct ETree* cDirectory = new ETree();
+    struct FTree* cDirectory = new FTree();
     cDirectory = gearsDirectory->currentDirectory;
     struct Node* node = new Node();
     node->key = name->value;
@@ -50,9 +75,9 @@
 
 __code cd2Child2(struct GearsDirectoryImpl* gearsDirectory, struct Node* node0, __code next(...)) {
     // treeを作る
-    // struct ETree* tree = new FileSystemTree();
+    // struct FTree* tree = new FileSystemTree();
     // currentDirectoryを作ったtreeに変更する
-    // struct ETree* parentDirectory = gearsDirectory->currentDirectory;
+    // struct FTree* parentDirectory = gearsDirectory->currentDirectory;
     // gearsDirectory->currentDirectory = tree;
     // current treeをstackにpushする
     // struct Stack* ds = gearsDirectory->directoryStack;
@@ -66,7 +91,7 @@
 __code cd2Child2_stub(struct Context* context) {
 	GearsDirectoryImpl* gearsDirectory = (GearsDirectoryImpl*)GearImpl(context, GearsDirectory, gearsDirectory);
 	enum Code next = Gearef(context, GearsDirectory)->next;
-    Node* node0 = Gearef(context, ETree)->node;
+    Node* node0 = Gearef(context, FTree)->node;
 	goto cd2Child2(context, gearsDirectory, node0, next);
 }
 
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.h	Thu Jan 06 22:53:24 2022 +0900
+++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectoryImpl.h	Thu Jan 06 22:53:52 2022 +0900
@@ -1,5 +1,6 @@
 typedef struct GearsDirectoryImpl <> impl GearsDirectory {
-  struct ETree* currentDirectory;
+  struct FTree* currentDirectory;
   struct FTree* iNodeTree;
   struct Stack* directoryStack;
+  int INodeNumber;
 } GearsDirectoryImpl;
\ No newline at end of file
--- a/src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc	Thu Jan 06 22:53:24 2022 +0900
+++ b/src/parallel_execution/examples/gearsDirectory/GearsDirectory_test.cbc	Thu Jan 06 22:53:52 2022 +0900
@@ -6,7 +6,7 @@
 __code task1(GearsDirectory* gearsDirectory){     
     Integer* name = new Integer();
     name->value = 1;
-    goto gearsDirectory->mkdir(name, task2);
+    goto gearsDirectory->mkdir(name, task5);
 }
 
 __code task1_stub(struct Context* context){
@@ -34,6 +34,17 @@
     goto task3(context, gearsDirectory);
 }
 
+__code task5(GearsDirectory* gearsDirectory){
+    Integer* name = new Integer();
+    name->value = 1;
+    goto gearsDirectory->ls(name, exit_code);
+}
+
+__code task5_stub(struct Context* context){
+    GearsDirectory* gearsDirectory = (struct GearsDirectory*)Gearef(context, GearsDirectory)->gearsDirectory;
+    goto task5(context, gearsDirectory);
+}
+
 int main(int argc, char** argv) {
     printf("main\n");
     goto task1();