From d2f5446ee57cfe23699f053110b5a27651260677 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Sat, 14 Sep 2019 02:21:59 +0000 Subject: [PATCH] source change for consistency --- moo/kernel/Process.moo | 4 ++-- moo/kernel/System.moo | 24 +++++++++++++++++++++++- moo/kernel/test-002.moo | 6 +++--- moo/kernel/test-010.moo | 4 ++-- 4 files changed, 30 insertions(+), 8 deletions(-) diff --git a/moo/kernel/Process.moo b/moo/kernel/Process.moo index 485187b..011c75a 100644 --- a/moo/kernel/Process.moo +++ b/moo/kernel/Process.moo @@ -297,7 +297,7 @@ class SemaphoreHeap(Object) | top | top := self.arr at: 0. - self deleteAt: 0. + self removeAt: 0. ^top } @@ -314,7 +314,7 @@ class SemaphoreHeap(Object) ^if (aSemaphore youngerThan: item) { self siftUp: anIndex } else { self siftDown: anIndex }. } - method deleteAt: anIndex + method removeAt: anIndex { | item xitem | diff --git a/moo/kernel/System.moo b/moo/kernel/System.moo index 1550cc2..d44e169 100644 --- a/moo/kernel/System.moo +++ b/moo/kernel/System.moo @@ -13,6 +13,7 @@ class System(Apex) var(#class) asyncsg. var(#class) gcfin_sem. var(#class) gcfin_should_exit := false. + var(#class) shr. pooldic Log { @@ -28,6 +29,16 @@ class System(Apex) FATAL := 16. } + method(#class) _initialize + { + self.shr := Dictionary new. + } + + method(#class) _cleanup + { + self.shr := nil. + } + method(#class) addAsyncSemaphore: sem { ^self.asyncsg addSemaphore: sem @@ -55,6 +66,8 @@ class System(Apex) self error: ('Cannot find the class - ' & class_name). }. + self _initialize. + // start the gc finalizer process and os signal handler process //[ self __gc_finalizer ] fork. //[ self __os_sig_handler ] fork. @@ -70,7 +83,6 @@ class System(Apex) ] ensure: [ self _setSig: 16rFF. - //// System logNl: '======= END of startup ==============='. ]. ^ret. @@ -206,6 +218,7 @@ class System(Apex) self.gcfin_sem signal. // wake the gcfin process. self _halting. // inform VM that it should get ready for halting. + self _cleanup. ]. } @@ -224,6 +237,15 @@ class System(Apex) method(#class,#primitive) return: object to: context. // ======================================================================================= + method(#class) registerSignalHandler: block + { + self.shr add: block. + } + + method(#class) removeSignalHandler: block + { + } + method(#class) sleepForSecs: secs { // ----------------------------------------------------- diff --git a/moo/kernel/test-002.moo b/moo/kernel/test-002.moo index 14c3177..a3475aa 100644 --- a/moo/kernel/test-002.moo +++ b/moo/kernel/test-002.moo @@ -77,9 +77,9 @@ class MyObject(Object) ]. '--------------------------' dump. - sempq deleteAt: 40. - sempq deleteAt: 50. - sempq deleteAt: 100. + sempq removeAt: 40. + sempq removeAt: 50. + sempq removeAt: 100. a := -100. [sempq size > 0] whileTrue: [ diff --git a/moo/kernel/test-010.moo b/moo/kernel/test-010.moo index 70a9136..2575b23 100644 --- a/moo/kernel/test-010.moo +++ b/moo/kernel/test-010.moo @@ -227,8 +227,8 @@ class MyObject(TestObject) ]. '--------------------------' dump. - sempq deleteAt: 40. - sempq deleteAt: 50. + sempq removeAt: 40. + sempq removeAt: 50. [sempq size > 0] whileTrue: [ | sem |