(Process) : Fix process clean up procedure. Increment the process reference count for each thread.
@@ -688,11 +688,12 @@ | ||
688 | 688 | return 0; |
689 | 689 | } |
690 | 690 | |
691 | - // Add this thread to this process and memorize the user stack address. | |
691 | + // Add this thread to this process. | |
692 | 692 | ++threadCount; |
693 | 693 | thread->process = this; |
694 | 694 | thread->userStack = userStack; |
695 | 695 | threadList.addLast(thread); |
696 | + addRef(); | |
696 | 697 | return thread; |
697 | 698 | } |
698 | 699 |
@@ -711,6 +712,8 @@ | ||
711 | 712 | threadList.remove(thread); |
712 | 713 | --threadCount; |
713 | 714 | waitPoint.wakeup(); |
715 | + | |
716 | + release(); | |
714 | 717 | } |
715 | 718 | |
716 | 719 | IThread* Process:: |
@@ -908,17 +911,7 @@ | ||
908 | 911 | |
909 | 912 | exitValue = status; |
910 | 913 | |
911 | - for (SyscallProxy* proxy(syscallTable); | |
912 | - proxy < &syscallTable[INTERFACE_POINTER_MAX]; | |
913 | - ++proxy) | |
914 | - { | |
915 | - proxy->addRef(); | |
916 | - while (0 < proxy->release()) | |
917 | - ; | |
918 | - } | |
919 | - | |
920 | - // Cancel all the threads. Note do not release threads here as they are | |
921 | - // stored in syscallTable. | |
914 | + // Cancel all the threads. | |
922 | 915 | Thread* thread; |
923 | 916 | List<Thread, &Thread::linkProcess>::Iterator iter = threadList.begin(); |
924 | 917 | while ((thread = iter.next())) |
@@ -948,7 +941,7 @@ | ||
948 | 941 | // NOT REACHED HERE |
949 | 942 | } |
950 | 943 | |
951 | - // Cancel all the threads | |
944 | + // Cancel all the threads. | |
952 | 945 | Monitor::Synchronized method(monitor); |
953 | 946 | Thread* thread; |
954 | 947 | List<Thread, &Thread::linkProcess>::Iterator iter = threadList.begin(); |
@@ -956,9 +949,8 @@ | ||
956 | 949 | { |
957 | 950 | ASSERT(thread != Thread::getCurrentThread()); |
958 | 951 | thread->setCancelState(ICurrentThread::CANCEL_ENABLE); |
959 | - thread->setCancelType(ICurrentThread::CANCEL_ASYNCHRONOUS); | |
952 | + thread->setCancelType(ICurrentThread::CANCEL_DEFERRED); | |
960 | 953 | thread->cancel(); |
961 | - thread->release(); | |
962 | 954 | } |
963 | 955 | } |
964 | 956 |
@@ -178,10 +178,8 @@ | ||
178 | 178 | esCreateInstance(CLSID_FatFileSystem, IFileSystem::iid())); |
179 | 179 | fatFileSystem->mount(disk); |
180 | 180 | { |
181 | - Handle<IContext> root; | |
181 | + Handle<IContext> root = fatFileSystem->getRoot(); | |
182 | 182 | |
183 | - root = fatFileSystem->getRoot(); | |
184 | - | |
185 | 183 | nameSpace->bind("file", root); |
186 | 184 | |
187 | 185 | // start event manager process. |
@@ -205,12 +203,14 @@ | ||
205 | 203 | consoleProcess->kill(); |
206 | 204 | eventProcess->kill(); |
207 | 205 | |
208 | - freeSpace = fatFileSystem->getFreeSpace(); | |
209 | - totalSpace = fatFileSystem->getTotalSpace(); | |
210 | - esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace); | |
206 | + esSleep(10000000); | |
211 | 207 | } |
208 | + | |
209 | + freeSpace = fatFileSystem->getFreeSpace(); | |
210 | + totalSpace = fatFileSystem->getTotalSpace(); | |
211 | + esReport("Free space %lld, Total space %lld\n", freeSpace, totalSpace); | |
212 | + | |
212 | 213 | fatFileSystem->dismount(); |
213 | 214 | fatFileSystem = 0; |
214 | - | |
215 | 215 | esSleep(10000000); |
216 | 216 | } |