clean up
This commit is contained in:
parent
72d57d8db8
commit
d95e6f35c1
|
@ -25,7 +25,6 @@
|
||||||
|
|
||||||
READ_ONLY Scheme_Object *scheme_always_ready_evt;
|
READ_ONLY Scheme_Object *scheme_always_ready_evt;
|
||||||
THREAD_LOCAL_DECL(Scheme_Object *scheme_system_idle_channel);
|
THREAD_LOCAL_DECL(Scheme_Object *scheme_system_idle_channel);
|
||||||
extern int scheme_assert_atomic;
|
|
||||||
|
|
||||||
static Scheme_Object *make_sema(int n, Scheme_Object **p);
|
static Scheme_Object *make_sema(int n, Scheme_Object **p);
|
||||||
static Scheme_Object *semap(int n, Scheme_Object **p);
|
static Scheme_Object *semap(int n, Scheme_Object **p);
|
||||||
|
@ -94,7 +93,7 @@ void scheme_init_sema(Scheme_Env *env)
|
||||||
scheme_add_global_constant("make-semaphore",
|
scheme_add_global_constant("make-semaphore",
|
||||||
scheme_make_prim_w_arity(make_sema,
|
scheme_make_prim_w_arity(make_sema,
|
||||||
"make-semaphore",
|
"make-semaphore",
|
||||||
0, 2),
|
0, 1),
|
||||||
env);
|
env);
|
||||||
scheme_add_global_constant("semaphore?",
|
scheme_add_global_constant("semaphore?",
|
||||||
scheme_make_folding_prim(semap,
|
scheme_make_folding_prim(semap,
|
||||||
|
@ -244,12 +243,7 @@ static Scheme_Object *make_sema(int n, Scheme_Object **p)
|
||||||
} else
|
} else
|
||||||
v = 0;
|
v = 0;
|
||||||
|
|
||||||
s = scheme_make_sema(v);
|
return scheme_make_sema(v);
|
||||||
|
|
||||||
if (n > 1)
|
|
||||||
SCHEME_CPTR_FLAGS(s) |= 0x1;
|
|
||||||
|
|
||||||
return s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Scheme_Object *make_sema_repost(int n, Scheme_Object **p)
|
static Scheme_Object *make_sema_repost(int n, Scheme_Object **p)
|
||||||
|
@ -322,10 +316,6 @@ void scheme_post_sema(Scheme_Object *o)
|
||||||
} else
|
} else
|
||||||
consumed = 0;
|
consumed = 0;
|
||||||
|
|
||||||
if (!consumed)
|
|
||||||
if (SCHEME_CPTR_FLAGS(o) & 0x1)
|
|
||||||
printf("here\n");
|
|
||||||
|
|
||||||
w->in_line = 0;
|
w->in_line = 0;
|
||||||
w->prev = NULL;
|
w->prev = NULL;
|
||||||
w->next = NULL;
|
w->next = NULL;
|
||||||
|
@ -644,8 +634,6 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
} else
|
} else
|
||||||
start_pos = 0;
|
start_pos = 0;
|
||||||
|
|
||||||
scheme_assert_atomic++;
|
|
||||||
|
|
||||||
/* Initial poll */
|
/* Initial poll */
|
||||||
while (1) {
|
while (1) {
|
||||||
i = 0;
|
i = 0;
|
||||||
|
@ -673,14 +661,11 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
if (!scheme_current_thread->next)
|
if (!scheme_current_thread->next)
|
||||||
break;
|
break;
|
||||||
else {
|
else {
|
||||||
--scheme_assert_atomic;
|
|
||||||
if (!scheme_wait_until_suspend_ok()) {
|
if (!scheme_wait_until_suspend_ok()) {
|
||||||
scheme_assert_atomic++;
|
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
/* there may have been some action on one of the waitables;
|
/* there may have been some action on one of the waitables;
|
||||||
try again */
|
try again */
|
||||||
scheme_assert_atomic++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -732,9 +717,7 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
|
|
||||||
scheme_main_was_once_suspended = 0;
|
scheme_main_was_once_suspended = 0;
|
||||||
|
|
||||||
scheme_assert_atomic--;
|
|
||||||
scheme_block_until(out_of_line, NULL, (Scheme_Object *)a, (float)0.0);
|
scheme_block_until(out_of_line, NULL, (Scheme_Object *)a, (float)0.0);
|
||||||
scheme_assert_atomic++;
|
|
||||||
|
|
||||||
--scheme_current_thread->suspend_break;
|
--scheme_current_thread->suspend_break;
|
||||||
} else {
|
} else {
|
||||||
|
@ -744,9 +727,7 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
old_nkc = (scheme_current_thread->running & MZTHREAD_NEED_KILL_CLEANUP);
|
old_nkc = (scheme_current_thread->running & MZTHREAD_NEED_KILL_CLEANUP);
|
||||||
if (!old_nkc)
|
if (!old_nkc)
|
||||||
scheme_current_thread->running += MZTHREAD_NEED_KILL_CLEANUP;
|
scheme_current_thread->running += MZTHREAD_NEED_KILL_CLEANUP;
|
||||||
scheme_assert_atomic--;
|
|
||||||
scheme_weak_suspend_thread(scheme_current_thread);
|
scheme_weak_suspend_thread(scheme_current_thread);
|
||||||
scheme_assert_atomic++;
|
|
||||||
if (!old_nkc && (scheme_current_thread->running & MZTHREAD_NEED_KILL_CLEANUP))
|
if (!old_nkc && (scheme_current_thread->running & MZTHREAD_NEED_KILL_CLEANUP))
|
||||||
scheme_current_thread->running -= MZTHREAD_NEED_KILL_CLEANUP;
|
scheme_current_thread->running -= MZTHREAD_NEED_KILL_CLEANUP;
|
||||||
}
|
}
|
||||||
|
@ -794,9 +775,7 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
get_outof_line(semas[i], ws[i]);
|
get_outof_line(semas[i], ws[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme_assert_atomic--;
|
|
||||||
scheme_thread_block(0); /* ok if it returns multiple times */
|
scheme_thread_block(0); /* ok if it returns multiple times */
|
||||||
scheme_assert_atomic++;
|
|
||||||
scheme_current_thread->ran_some = 1;
|
scheme_current_thread->ran_some = 1;
|
||||||
/* [but why would it return multiple times?! there must have been a reason...] */
|
/* [but why would it return multiple times?! there must have been a reason...] */
|
||||||
} else {
|
} else {
|
||||||
|
@ -838,8 +817,6 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme_assert_atomic--;
|
|
||||||
|
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
scheme_thread_block(0); /* dies or suspends */
|
scheme_thread_block(0); /* dies or suspends */
|
||||||
scheme_current_thread->ran_some = 1;
|
scheme_current_thread->ran_some = 1;
|
||||||
|
@ -847,8 +824,6 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
|
|
||||||
if (i < n)
|
if (i < n)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
scheme_assert_atomic++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Otherwise: !syncing and someone stole the post, or we were
|
/* Otherwise: !syncing and someone stole the post, or we were
|
||||||
|
@ -879,7 +854,6 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
get_outof_line(semas[j], ws[j]);
|
get_outof_line(semas[j], ws[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
scheme_assert_atomic--;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,8 +878,7 @@ int scheme_wait_semas_chs(int n, Scheme_Object **o, int just_try, Syncing *synci
|
||||||
}
|
}
|
||||||
/* Back to top of loop to sync again */
|
/* Back to top of loop to sync again */
|
||||||
}
|
}
|
||||||
} else
|
}
|
||||||
scheme_assert_atomic--;
|
|
||||||
v = i + 1;
|
v = i + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -128,8 +128,6 @@ extern int scheme_jit_malloced;
|
||||||
# define scheme_jit_malloced 0
|
# define scheme_jit_malloced 0
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
int scheme_assert_atomic;
|
|
||||||
|
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
/* local variables and prototypes */
|
/* local variables and prototypes */
|
||||||
/*========================================================================*/
|
/*========================================================================*/
|
||||||
|
@ -2624,9 +2622,6 @@ static void do_swap_thread()
|
||||||
swapping = 1;
|
swapping = 1;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (scheme_assert_atomic)
|
|
||||||
*(long *)0x0 = 1;
|
|
||||||
|
|
||||||
if (!swap_no_setjmp && SETJMP(scheme_current_thread)) {
|
if (!swap_no_setjmp && SETJMP(scheme_current_thread)) {
|
||||||
/* We're back! */
|
/* We're back! */
|
||||||
/* See also initial swap in in start_child() */
|
/* See also initial swap in in start_child() */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user