Ejemplo n.º 1
0
void
bsd_utaskbootstrap(void)
{
	thread_t thread;
	struct uthread *ut;

	/*
	 * Clone the bootstrap process from the kernel process, without
	 * inheriting either task characteristics or memory from the kernel;
	 */
	thread = cloneproc(TASK_NULL, COALITION_NULL, kernproc, FALSE, TRUE);

	/* Hold the reference as it will be dropped during shutdown */
	initproc = proc_find(1);				
#if __PROC_INTERNAL_DEBUG
	if (initproc == PROC_NULL)
		panic("bsd_utaskbootstrap: initproc not set\n");
#endif
	/*
	 * Since we aren't going back out the normal way to our parent,
	 * we have to drop the transition locks explicitly.
	 */
	proc_signalend(initproc, 0);
	proc_transend(initproc, 0);

	ut = (struct uthread *)get_bsdthread_info(thread);
	ut->uu_sigmask = 0;
	act_set_astbsd(thread);
	proc_clear_return_wait(initproc, thread);
}
Ejemplo n.º 2
0
kern_return_t check_actforsig(task_t task, thread_act_t thact, int setast)
{

        thread_act_t inc;
        thread_act_t ninc;
        thread_act_t thr_act;
		thread_t	th;
		int found=0;

	task_lock(task);
	if (!task->active) {
		task_unlock(task);
		return(KERN_FAILURE);
	}

        thr_act = THR_ACT_NULL;
        for (inc  = (thread_act_t)queue_first(&task->threads);
			 !queue_end(&task->threads, (queue_entry_t)inc);
             inc  = ninc) {

				if (inc != thact) {
                	ninc = (thread_act_t)queue_next(&inc->task_threads);
						continue;
				}
                th = act_lock_thread(inc);
                if ((inc->active)  && 
                    ((th->state & (TH_ABORT|TH_ABORT_SAFELY)) != TH_ABORT)) {
					found = 1;
                    thr_act = inc;
                   break;
                }
                act_unlock_thread(inc);
                /* ninc = (thread_act_t)queue_next(&inc->thr_acts); */
				break;
        }
out:
		if (found) {
            if (setast)
				act_set_astbsd(thr_act);

           act_unlock_thread(thr_act);
        }
		task_unlock(task);

        if (found) 
            return(KERN_SUCCESS);
        else 
            return(KERN_FAILURE);
}
Ejemplo n.º 3
0
kern_return_t get_signalact(task_t task,thread_act_t * thact, int setast)
{

        thread_act_t inc;
        thread_act_t ninc;
        thread_act_t thr_act;
	thread_t	th;

	task_lock(task);
	if (!task->active) {
		task_unlock(task);
		return(KERN_FAILURE);
	}

        thr_act = THR_ACT_NULL;
        for (inc  = (thread_act_t)queue_first(&task->threads);
			 !queue_end(&task->threads, (queue_entry_t)inc);
             inc  = ninc) {
                th = act_lock_thread(inc);
                if ((inc->active)  && 
                    ((th->state & (TH_ABORT|TH_ABORT_SAFELY)) != TH_ABORT)) {
                    thr_act = inc;
                   break;
                }
                act_unlock_thread(inc);
                ninc = (thread_act_t)queue_next(&inc->task_threads);
        }
out:
        if (thact) 
                *thact = thr_act;
        if (thr_act) {
                if (setast)
                    act_set_astbsd(thr_act);

                act_unlock_thread(thr_act);
        }
	task_unlock(task);

        if (thr_act) 
            return(KERN_SUCCESS);
        else 
            return(KERN_FAILURE);
}