make come and flee more atomic

profiler and mememory checker are working properly now (and together)
This commit is contained in:
Paul Driver 2018-04-02 18:38:24 -07:00
parent 3b7e9eca0b
commit cd342ab1c1

View File

@ -5,6 +5,8 @@
#include "all.h"
#include <pthread.h>
static c3_o _ct_lop_o;
/* u3t_push(): push on trace stack.
*/
void
@ -106,6 +108,18 @@ u3t_heck(u3_atom cog)
}
}
#if 0
static void
_ct_sane(u3_noun lab)
{
if ( u3_nul != lab ) {
c3_assert(c3y == u3du(lab));
c3_assert(c3y == u3ud(u3h(lab)));
_ct_sane(u3t(lab));
}
}
#endif
#if 1
/* _t_samp_process(): process raw sample data from live road.
*/
@ -186,6 +200,12 @@ _t_samp_process(u3_road* rod_u)
void
u3t_samp(void)
{
if ( c3y == _ct_lop_o ) {
// _ct_lop_o here is a mutex for modifying pro.don. we
// do not want to sample in the middle of doing that, as
// it can cause memory errors.
return;
}
u3C.wag_w &= ~u3o_debug_cpu;
static int home = 0;
@ -248,7 +268,10 @@ c3_o
u3t_come(u3_noun lab)
{
if ( (u3_nul == u3R->pro.don) || !_(u3r_sing(lab, u3h(u3R->pro.don))) ) {
u3R->pro.don = u3nc(u3k(lab), u3R->pro.don);
u3a_gain(lab);
_ct_lop_o = c3y;
u3R->pro.don = u3nc(lab, u3R->pro.don);
_ct_lop_o = c3n;
return c3y;
}
else return c3n;
@ -259,10 +282,11 @@ u3t_come(u3_noun lab)
void
u3t_flee(void)
{
u3_noun t_don = u3k(u3t(u3R->pro.don));
u3z(u3R->pro.don);
u3R->pro.don = t_don;
_ct_lop_o = c3y;
u3_noun don = u3R->pro.don;
u3R->pro.don = u3k(u3t(don));
_ct_lop_o = c3n;
u3z(don);
}
extern FILE*
@ -355,6 +379,7 @@ void
u3t_boot(void)
{
if ( u3C.wag_w & u3o_debug_cpu ) {
_ct_lop_o = c3n;
#if defined(U3_OS_osx)
#if 1
{