From 5a807265a819206f8342ab3a23b940a0c75049fc Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Wed, 13 Oct 2021 17:08:26 +0000 Subject: libthread: fix debug prints, simplify Do the debuglevel check before calling the print function for _threaddebug, by making it a macro. Do not waste cycles passing arguments. Generalize the _threaddebug function into _threadprint() and add a varargcheck pragma. This function can also be used from _threadassert(). Fix missing arguments in one case, fix trailing newlines in _threaddebug(). Make _threadgetproc()/_threadsetproc() a macro, just dereferencing Proc**_threadprocp. Simplify the mainjump, just call _threadsetproc() directly without that mainp dance. Remove the _schedinit() argument, it uses _threadgetproc() now. Get rid of Mainarg struct, just have a global variable for argc. --- sys/src/libthread/sched.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'sys/src/libthread/sched.c') diff --git a/sys/src/libthread/sched.c b/sys/src/libthread/sched.c index 888d64cc2..6e7a6d57a 100644 --- a/sys/src/libthread/sched.c +++ b/sys/src/libthread/sched.c @@ -36,14 +36,13 @@ unlinkproc(Proc *p) } void -_schedinit(void *arg) +_schedinit(void) { Proc *p; Thread *t, **l; - p = arg; + p = _threadgetproc(); p->pid = getpid(); - _threadsetproc(p); while(setjmp(p->sched)) ; _threaddebug(DBGSCHED, "top of schedinit, _threadexitsallstatus=%p", _threadexitsallstatus); @@ -164,7 +163,7 @@ Resched: _threaddebug(DBGSCHED, "running %d.%d", t->proc->pid, t->id); p->thread = t; if(t->moribund){ - _threaddebug(DBGSCHED, "%d.%d marked to die"); + _threaddebug(DBGSCHED, "%d.%d marked to die", t->proc->pid, t->id); goto Resched; } t->state = Running; -- cgit v1.2.3