moved gcfin_should_exit from Processor to System
This commit is contained in:
parent
87cf4f4b6a
commit
652f13246f
@ -421,7 +421,7 @@ class SemaphoreHeap(Object)
|
||||
|
||||
class(#final,#limited) ProcessScheduler(Object)
|
||||
{
|
||||
var(#get) active, gcfin_should_exit := false, total_count := 0.
|
||||
var(#get) active, total_count := 0.
|
||||
var(#get) runnable_count := 0.
|
||||
var runnable_head, runnable_tail.
|
||||
var(#get) suspended_count := 0.
|
||||
|
@ -11,6 +11,8 @@
|
||||
class System(Apex)
|
||||
{
|
||||
var(#class) asyncsg.
|
||||
var(#class) gcfin_sem.
|
||||
var(#class) gcfin_should_exit := false.
|
||||
|
||||
pooldic Log
|
||||
{
|
||||
@ -74,12 +76,13 @@ class System(Apex)
|
||||
|
||||
method(#class) __gc_finalizer
|
||||
{
|
||||
| tmp gc gcfin_sem |
|
||||
| tmp gc |
|
||||
|
||||
gc := false.
|
||||
gcfin_sem := Semaphore new.
|
||||
|
||||
gcfin_sem signalOnGCFin. // tell VM to signal this semaphore when it schedules gc finalization.
|
||||
self.gcfin_should_exit := false.
|
||||
self.gcfin_sem := Semaphore new.
|
||||
self.gcfin_sem signalOnGCFin. // tell VM to signal this semaphore when it schedules gc finalization.
|
||||
|
||||
[
|
||||
while (true)
|
||||
@ -95,7 +98,8 @@ class System(Apex)
|
||||
}.
|
||||
|
||||
//if (Processor total_count == 1)
|
||||
if (Processor gcfin_should_exit)
|
||||
//if (Processor gcfin_should_exit)
|
||||
if (self.gcfin_should_exit)
|
||||
{
|
||||
// exit from this loop when there are no other processes running except this finalizer process
|
||||
if (gc)
|
||||
@ -113,10 +117,10 @@ class System(Apex)
|
||||
gc := false.
|
||||
}.
|
||||
|
||||
gcfin_sem wait.
|
||||
self.gcfin_sem wait.
|
||||
}
|
||||
] ensure: [
|
||||
gcfin_sem unsignal.
|
||||
self.gcfin_sem unsignal.
|
||||
System logNl: 'End of GC finalization process ' & (thisProcess id) asString.
|
||||
].
|
||||
}
|
||||
@ -172,9 +176,12 @@ class System(Apex)
|
||||
/* TODO: end redo */
|
||||
|
||||
caller terminate.
|
||||
(Processor _processById: 1) resume. //<---- i shouldn't do ths. but, this system causes VM assertion failure. fix it....
|
||||
|
||||
System logNl: '>>>>End of OS signal handler process ' & (thisProcess id) asString.
|
||||
|
||||
//(Processor _processById: 1) resume. //<---- i shouldn't do ths. but, this system causes VM assertion failure. fix it....
|
||||
self.gcfin_should_exit := true.
|
||||
self.gcfin_sem signal. // wake the gcfin process.
|
||||
].
|
||||
}
|
||||
|
||||
|
@ -4900,7 +4900,7 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo)
|
||||
{
|
||||
MOO_ASSERT (moo, proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNABLE));
|
||||
MOO_ASSERT (moo, proc == moo->processor->runnable.first);
|
||||
moo->processor->gcfin_should_exit = moo->_true; /* prepare to inform the gc finalizer process */
|
||||
moo->_system->cvar[2] = moo->_true; /* set gcfin_should_exit in System to true. if the postion of the class variable changes, the index must get changed, too. */
|
||||
switch_to_process_from_nil (moo, proc); /* sechedule the gc finalizer process */
|
||||
}
|
||||
}
|
||||
|
@ -397,7 +397,7 @@ static kernel_class_info_t kernel_classes[] =
|
||||
{ 6,
|
||||
{ 'S','y','s','t','e','m' },
|
||||
0,
|
||||
1, /* asyncsg */
|
||||
3, /* asyncsg, gcfin_sem, gcfin_should_exit*/
|
||||
0,
|
||||
0,
|
||||
MOO_OBJ_TYPE_OOP,
|
||||
@ -552,7 +552,6 @@ static int ignite_2 (moo_t* moo)
|
||||
if (!tmp) return -1;
|
||||
moo->processor = (moo_oop_process_scheduler_t)tmp;
|
||||
moo->processor->active = moo->nil_process;
|
||||
moo->processor->gcfin_should_exit = moo->_false;
|
||||
moo->processor->total_count = MOO_SMOOI_TO_OOP(0);
|
||||
moo->processor->runnable.count = MOO_SMOOI_TO_OOP(0);
|
||||
moo->processor->suspended.count = MOO_SMOOI_TO_OOP(0);
|
||||
|
@ -866,14 +866,13 @@ struct moo_semaphore_group_t
|
||||
moo_oop_t sem_count; /* the total number of semaphores in the group */
|
||||
};
|
||||
|
||||
#define MOO_PROCESS_SCHEDULER_NAMED_INSTVARS 9
|
||||
#define MOO_PROCESS_SCHEDULER_NAMED_INSTVARS 8
|
||||
typedef struct moo_process_scheduler_t moo_process_scheduler_t;
|
||||
typedef struct moo_process_scheduler_t* moo_oop_process_scheduler_t;
|
||||
struct moo_process_scheduler_t
|
||||
{
|
||||
MOO_OBJ_HEADER;
|
||||
moo_oop_process_t active; /* pointer to an active process in the runnable process list */
|
||||
moo_oop_t gcfin_should_exit; /* Boolean */
|
||||
moo_oop_t total_count; /* SmallIntger, total number of processes - runnable/running/suspended */
|
||||
|
||||
struct
|
||||
|
Loading…
Reference in New Issue
Block a user