summaryrefslogtreecommitdiff
path: root/concurrency.c
diff options
context:
space:
mode:
Diffstat (limited to 'concurrency.c')
-rw-r--r--concurrency.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/concurrency.c b/concurrency.c
index 08dfdbc..b45ee08 100644
--- a/concurrency.c
+++ b/concurrency.c
@@ -70,9 +70,7 @@ spawnthread(Function f, Array *name, Array *left, Array *right)
SpawnData *sp = emallocz(sizeof(SpawnData), 1);
sp->func = dupfunction(f);
- Symtab *scope = dupscope(f.scope);
- freesymtab(sp->func.scope);
- sp->func.scope = scope;
+ sp->func.scope = dupscope(f.scope);
sp->name = duparray(name);
sp->left = left ? duparray(left) : nil;
sp->right = duparray(right);
@@ -224,6 +222,7 @@ newprocfn(SpawnData *sp)
freearray(sp->name);
freearray(sp->left);
freearray(sp->right);
+ freesymtab(sp->func.scope);
freefunction(sp->func);
free(sp);
free(td);
@@ -271,6 +270,7 @@ threadproperty(vlong t, vlong p)
ThreadData *td = nil;
Array *res = nil;
int mailcount = 0;
+ int framecount = 0;
lock(&threadlock);
for(int i = 0; i < nthreads && td == nil; i++)
if(threads[i]->id == t)
@@ -292,9 +292,16 @@ threadproperty(vlong t, vlong p)
qunlock(&td->lock);
res = mkscalarint(mailcount);
break;
- case 3: /* used stacksize */
+ case 3: /* used C stacksize */
res = mkscalarint(td->stackused);
break;
+ case 4: /* DfnFrame count */
+ qlock(&td->lock);
+ for(DfnFrame *f = td->currentdfn; f != nil; f = f->prev)
+ framecount++;
+ qunlock(&td->lock);
+ res = mkscalarint(framecount);
+ break;
default:
unlock(&threadlock);
throwerror(L"Invalid thread property", EDomain);