/*
 * Thread initialization.
 */
struct thread *
thread_bootstrap(void)
{
	struct thread *me;

	/* Create the data structures we need. */
	sleepers = array_create();
	if (sleepers==NULL) {
		panic("Cannot create sleepers array\n");
	}

	zombies = array_create();
	if (zombies==NULL) {
		panic("Cannot create zombies array\n");
	}

	//as_array = array_create();
	//if(as_array == NULL)
	//{
	//	panic("Cannot create addrspace array\n");
	//}

	/*as_lock = lock_create("copy_lock");
	if(as_lock == NULL)
	{
		panic("Cannot create addrspace array lock\n");
	}*/

	/*
	 * Create the thread structure for the first thread
	 * (the one that's already running)
	 */
	me = thread_create("<boot/menu>");
	if (me==NULL) {
		panic("thread_bootstrap: Out of memory\n");
	}

	/*
	 * Leave me->t_stack NULL. This means we're using the boot stack,
	 * which can't be freed.
	 */

	/* Initialize the first thread's pcb */
	md_initpcb0(&me->t_pcb);

	/* Set curthread */
	curthread = me;

	/* Number of threads starts at 1 */
	numthreads = 1;
	
	forking = 0;

	/* Done */
	return me;
}
예제 #2
0
/*
 * Thread initialization.
 */
struct thread *
thread_bootstrap(void)
{
	struct thread *me;
    
    
	/* Create the data structures we need. */
	sleepers = array_create();
	if (sleepers==NULL) {
		panic("Cannot create sleepers array\n");
	}
    
	zombies = array_create();
	if (zombies==NULL) {
		panic("Cannot create zombies array\n");
	}
	
	/*
	 * Create the thread structure for the first thread
	 * (the one that's already running)
	 */
#if OPT_A2
    
    int i;
    for (i = 1; i < MAX_FORKED_PROCESSES; i++) { // pid cannot be 0
        process_table[i].active = 0;
        process_table[i].pid = 0;
        process_table[i].parentWaiting = 0;
        process_table[i].children = NULL;
        process_table[i].processSem = sem_create("process_sem", 0);
        // FIXME may init more fields here.
    }
#endif
	me = thread_create("<boot/menu>");
	if (me==NULL) {
		panic("thread_bootstrap: Out of memory\n");
	}
    
	/*
	 * Leave me->t_stack NULL. This means we're using the boot stack,
	 * which can't be freed.
	 */
    
	/* Initialize the first thread's pcb */
	md_initpcb0(&me->t_pcb);
    
	/* Set curthread */
	curthread = me;
    
	/* Number of threads starts at 1 */
	numthreads = 1;
    
	/* Done */
	return me;
}
예제 #3
0
파일: thread.c 프로젝트: jessZhAnG/OS
/*
 * Thread initialization.
 */
struct thread *
thread_bootstrap(void)
{
	struct thread *me;

	/* Create the data structures we need. */
	sleepers = array_create();
	if (sleepers==NULL) {
		panic("Cannot create sleepers array\n");
	}

	zombies = array_create();
	if (zombies==NULL) {
		panic("Cannot create zombies array\n");
	}
	
	/*
	 * Create the thread structure for the first thread
	 * (the one that's already running)
	 */
	me = thread_create("<boot/menu>");
	if (me==NULL) {
		panic("thread_bootstrap: Out of memory\n");
	}

	/*
	 * Leave me->t_stack NULL. This means we're using the boot stack,
	 * which can't be freed.
	 */

	/* Initialize the first thread's pcb */
	md_initpcb0(&me->t_pcb);

	/* Set curthread */
	curthread = me;

	/* Number of threads starts at 1 */
	numthreads = 1;

        #if OPT_A2
        /* init process table */
        int i;
        for (i = 0 ; i < MAX_PROG+1 ; ++i) p_table[i] = NULL;


        #endif
	/* Done */
	return me;
}
예제 #4
0
파일: thread.c 프로젝트: adi-mishra/CSC369
/*
 * Thread initialization.
 */
struct thread *
thread_bootstrap(void)
{
	struct thread *me;

	/* Create the data structures we need. */
	sleepers = array_create();
	if (sleepers==NULL) {
		panic("Cannot create sleepers array\n");
	}

	zombies = array_create();
	if (zombies==NULL) {
		panic("Cannot create zombies array\n");
	}
	
	/*
	 * Create the thread structure for the first thread
	 * (the one that's already running)
	 */
	me = thread_create("<boot/menu>");
	if (me==NULL) {
		panic("thread_bootstrap: Out of memory\n");
	}

	/*
	 * Leave me->t_stack NULL. This means we're using the boot stack,
	 * which can't be freed.
	 */

	/* Initialize the first thread's pcb */
	md_initpcb0(&me->t_pcb);

	/* ASST1: Manually set my pid - it was already allocated and set up
	 * in the pidinfo struct by pid_bootstrap
	 */
	me->t_pid = BOOTUP_PID;

	/* Set curthread */
	curthread = me;

	/* Number of threads starts at 1 */
	numthreads = 1;

	/* Done */
	return me;
}
예제 #5
0
파일: thread.c 프로젝트: MattMarji/os161
/*
 * Thread initialization.
 */
struct thread *
thread_bootstrap(void)
{
	struct thread 
	lock_exit = lock_create("lock_exit");
	cv_parent_queue = cv_create("parent_queue");

	/* Create the DAta structures we need. */
	sleepers = array_create();
	if (sleepers==NULL) {
		panic("Cannot create sleepers array\n");
	}

	zombies = array_create();
	if (zombies==NULL) {
		panic("Cannot create zombies array\n");
	}
	
	/*
	 * Create the thread structure for the first thread
	 * (the one that's already running)
	 */
	me = thread_create("<boot/menu>");
	if (me==NULL) {
		panic("thread_bootstrap: Out of memory\n");
	}

	/*
	 * Leave me->t_stack NULL. This means we're using the boot stack,
	 * which can't be freed.
	 */

	/* Initialize the first thread's pcb */
	md_initpcb0(&me->t_pcb);

	/* Set curthread */
	curthread = me;

	/* Number of threads starts at 1 */
	numthreads = 1;

	/* Done */
	return me;
}