group/pintos/src/threads/thread.c
/* 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. */
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.
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);
  load_avg = fix_int(0);
  if (thread_mlfqs) {
    int i;
    for (i = PRI_MIN; i <= PRI_MAX; i++)
        list_init(&mlfqs_lists[i]);
  }
  initial_thread = running_thread ();
  init_thread (initial_thread, "main", PRI_DEFAULT);
  initial_thread->status = THREAD_RUNNING;
  initial_thread->tid = allocate_tid ();
}
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 ) ; load_avg = fix_int ( 0 ) ; if ( thread_mlfqs ) { int i ; for ( i = PRI_MIN ; i <= PRI_MAX ; i ++ ) list_init ( & mlfqs_lists [ i ] ) ; } initial_thread = running_thread ( ) ; init_thread ( initial_thread , " " , PRI_DEFAULT ) ; initial_thread -> status = THREAD_RUNNING ; initial_thread -> tid = allocate_tid ( ) ; }
Initializes the threading system by transforming the code
that's currently running into a thread.
Initializes the threading system by transforming the code that ' s currently running into a thread .
// sema_init (&fileop_sema, 1); /* Set up a thread structure for the running thread. */