Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Initializes the threading system by transforming the code
- that's currently running into a thread. This can't work in
- general and it is possible in this case only because loader.S
- was careful to put the bottom of the stack at a page boundary.
- Also initializes the run queue and the tid lock.
- After calling this function, be sure to initialize the page
- allocator before trying to create any threads with
- thread_create().
- It is not safe to call thread_current() until this function
- finishes. */
- void
- thread_init(void) {
- ASSERT (intr_get_level() == INTR_OFF);
- lock_init(&tid_lock);
- list_init(&ready_list);
- list_init(&all_list);
- list_init(&sleep_list);
- sema_init(&sleep_semaphore, 1);
- /* Set up a thread structure for the running thread. */
- initial_thread = running_thread();
- init_thread(initial_thread, "main", PRI_DEFAULT);
- initial_thread->status = THREAD_RUNNING;
- initial_thread->tid = allocate_tid();
- /* Initializing "load_avg_const1", "load_avg_const2", then "load_avg" of the system for MLFQ Scheduler */
- load_avg_const1 = divide_int(convert_to_fixed(ALPHA), BETA);
- load_avg_const2 = divide_int(convert_to_fixed(ZETA), BETA);
- load_avg = convert_to_fixed(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement