aboutsummaryrefslogtreecommitdiff
path: root/src/libthread/setproc.c
blob: 5f1e2a8d0bffafc72f0e57357f860dc43f97058e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
 * Avoid using threading calls for single-proc programs.
 */

#include "threadimpl.h"

static int multi;
static Proc *theproc;

void
_threadsetproc(Proc *p)
{
	if(!multi)
		theproc = p;
	else
		_kthreadsetproc(p);
}

Proc*
_threadgetproc(void)
{
	if(!multi)
		return theproc;
	return _kthreadgetproc();
}

void
_threadmultiproc(void)
{
	if(multi)
		return;

	multi = 1;
	_kthreadinit();
	_threadsetproc(theproc);
}