Пример #1
0
Файл: main.c Проект: 8l/inferno
void
userinit(void)
{
	Proc *p;
	Osenv *o;

	p = newproc();
	o = p->env;

	o->fgrp = newfgrp(nil);

	o->pgrp = newpgrp();
	o->egrp = newegrp();
	kstrdup(&o->user, eve);

	strcpy(p->text, "interp");

	/*
	 * Kernel Stack
	 */
	p->sched.pc = (ulong)init0;
	p->sched.sp = (ulong)p->kstack+KSTACK;

	ready(p);
}
Пример #2
0
void
userinit(void)
{
	Proc *p;
	Osenv *o;

	p = newproc();
	o = p->env;

	o->fgrp = newfgrp(nil);
	o->pgrp = newpgrp();
	o->egrp = newegrp();
	kstrdup(&o->user, eve);

	strcpy(p->text, "interp");

	p->fpstate = FPINIT;

	/*	Kernel Stack
		N.B. The -12 for the stack pointer is important.
		4 bytes for gotolabel's return PC */
	p->sched.pc = (ulong)init0;
	p->sched.sp = (ulong)p->kstack+KSTACK-8;

	ready(p);
}
Пример #3
0
Файл: main.c Проект: 8l/inferno
void
userinit(void)
{
	Proc *p;
	Osenv *o;

	p = newproc();
	o = p->env;

	o->fgrp = newfgrp(nil);
	o->pgrp = newpgrp();
	kstrdup(&o->user, eve);
	strcpy(p->text,"interp");

	p->fpstate = FPINIT;
	fpinit();

	/*
	 * Kernel Stack
	 */
	p->sched.pc = (ulong)init0;
	p->sched.sp = (ulong)p->kstack+KSTACK-8;
	p->sched.sp &= ~7;		/* SP must be 8-byte aligned */

	ready(p);
}
Пример #4
0
hproc_t*
kern_baseproc(void (*start_func)(void *arg), char *start_module)
{
    hproc_t *p;
    Osdep *os;
    Osenv *e;

    /* create a kernel hosting proc */
    p = new_hproc(uv_default_loop());

    /* bind the base proc to the startup thread */
    baseinit(p);
    
    /* append it to the proc list */
    procs.head = p;
    p->prev = nil;
	procs.tail = p;

    /* setup the skeleton process environment */
    e = p->env;
    e->pgrp = newpgrp();
    e->fgrp = newfgrp(nil);
    e->egrp = newegrp();
    e->errstr = e->errbuf0;
    e->syserrstr = e->errbuf1;
    //e->user = strdup("node9");
    e->uid = hostuid;
    e->gid = hostgid;


    /* allocate the os dependency structure */
    os = malloc(sizeof(*os));
	if(os == nil) {
		panic("host_proc: no memory");
    }
    p->os = os;

    os->self = uv_thread_self();  // just the handle for primary thread
    os->thread = nil;             // because its the process thread itself

	uv_sem_init(&os->sem, 0);
    
    /* insert the startup function and module */
    p->func = start_func;
    p->arg = start_module;
    
    /* debug watchers */
    //uv_idle_init(p->loop, &idle_watcher);
    //uv_idle_start(&idle_watcher, debug_idle);
    //uv_prepare_init(p->loop, &prepare_watcher);
    //uv_prepare_start(&prepare_watcher, debug_prepare);
    //uv_poll_init(p->loop, &poll_watcher,0);
    //uv_poll_start(&poll_watcher, 0, debug_poll);
    //uv_check_init(p->loop, &check_watcher);
    //uv_check_start(&check_watcher, debug_check);

    return p;
}
Пример #5
0
void
emuinit(void *imod)
{
	Osenv *e;
	char *wdir;

	e = up->env;
	e->pgrp = newpgrp();
	e->fgrp = newfgrp(nil);
	e->egrp = newegrp();
	e->errstr = e->errbuf0;
	e->syserrstr = e->errbuf1;
	e->user = strdup("");

	links();
	chandevinit();

	if(waserror())
		panic("setting root and dot");

	e->pgrp->slash = namec("#/", Atodir, 0, 0);
	cnameclose(e->pgrp->slash->name);
	e->pgrp->slash->name = newcname("/");
	e->pgrp->dot = cclone(e->pgrp->slash);
	poperror();

	strcpy(up->text, "main");

	if(kopen("#c/cons", OREAD) != 0)
		fprint(2, "failed to make fd0 from #c/cons: %r\n");
	kopen("#c/cons", OWRITE);
	kopen("#c/cons", OWRITE);

	/* the setid cannot precede the bind of #U */
	kbind("#U", "/", MAFTER|MCREATE);
	setid(eve, 0);
	kbind("#^", "/dev", MBEFORE);	/* snarf */
	kbind("#^", "/chan", MBEFORE);
	kbind("#m", "/dev", MBEFORE);	/* pointer */
	kbind("#c", "/dev", MBEFORE);
	kbind("#p", "/prog", MREPL);
	kbind("#d", "/fd", MREPL);
	kbind("#I", "/net", MAFTER);	/* will fail on Plan 9 */

	/* BUG: we actually only need to do these on Plan 9 */
	kbind("#U/dev", "/dev", MAFTER);
	kbind("#U/net", "/net", MAFTER);
	kbind("#U/net.alt", "/net.alt", MAFTER);

	if(cputype != nil)
		ksetenv("cputype", cputype, 1);
	putenvqv("emuargs", rebootargv, rebootargc, 1);
	putenvq("emuroot", rootdir, 1);
	ksetenv("emuhost", hosttype, 1);
	wdir = malloc(1024);
	if(wdir != nil){
		if(getwd(wdir, 1024) != nil)
			putenvq("emuwdir", wdir, 1);
		free(wdir);
	}

	kproc("main", disinit, imod, KPDUPFDG|KPDUPPG|KPDUPENVG);

	for(;;)
		ospause(); 
}