Exemple #1
0
/* initialize kthread */
void kthread_init(struct kthread *thread, struct eprocess *process)
{
	ktrace("\n");

	INIT_DISP_HEADER(&thread->header, ThreadObject, sizeof(struct ethread), false);

	/* initialize the mutant list */
	INIT_LIST_HEAD(&thread->mutant_list_head);

	/* setup apc fields */
	INIT_LIST_HEAD(&thread->apc_state.apc_list_head[0]);
	INIT_LIST_HEAD(&thread->apc_state.apc_list_head[1]);
	INIT_LIST_HEAD(&thread->saved_apc_state.apc_list_head[0]);
	INIT_LIST_HEAD(&thread->saved_apc_state.apc_list_head[1]);
	thread->apc_state.process = (struct kprocess *)process;
	thread->apc_state_pointer[OriginalApcEnvironment] = &thread->apc_state;
	thread->apc_state_pointer[AttachedApcEnvironment] = &thread->saved_apc_state;
	thread->apc_state_index = OriginalApcEnvironment;
	thread->apc_queue_lock = SPIN_LOCK_UNLOCKED;
	thread->apc_queueable = true;

	/*NOW FIXME Initialize the Suspend APC */
	apc_init(&thread->suspend_apc, 
			thread, 
			OriginalApcEnvironment, 
			suspend_thread_kernel_routine, 
			NULL, 
			suspend_thread_normal_routine, 
			KernelMode, 
			NULL);


	/* Initialize the Suspend Semaphore */
	semaphore_init(&thread->suspend_semaphore, 0, 128);

	/* initialize the suspend semaphore */
	/* FIXME: sema_init(&thread->suspend_semaphore, 0); */
	/* FIXME: keinitializetimer(&thread->timer); */

	arch_init_thread(thread, context);

	thread->base_priority = process->pcb.base_priority;
	thread->quantum = process->pcb.quantum_reset;
	thread->quantum_reset = process->pcb.quantum_reset;
	thread->affinity = process->pcb.affinity;
	thread->priority = process->pcb.base_priority;
	thread->user_affinity = process->pcb.affinity;
	thread->disable_boost = process->pcb.disable_boost;
	thread->auto_alignment = process->pcb.auto_alignment;

	/* set the thread to initalized */
	thread->state = Initialized;

	lock_process(process);
	list_add_tail(&thread->thread_list_entry, &process->pcb.thread_list_head);
	unlock_process(process);
	if (!thread->win32thread)
		thread->win32thread = create_w32thread(process->win32process, (struct ethread *)thread);
} /* end kthread_init */
int fork_tramp(void *stack)
{
	local_irq_disable();
	arch_init_thread();
	init_new_thread_stack(stack, finish_fork_handler);

	os_usr1_process(os_getpid());
	change_sig(SIGUSR1, 1);
	return(0);
}