pintos/src/threads/thread.c File Reference

#include "threads/thread.h"
#include <debug.h>
#include <stddef.h>
#include <random.h>
#include <stdio.h>
#include <string.h>
#include "threads/flags.h"
#include "threads/interrupt.h"
#include "threads/intr-stubs.h"
#include "threads/palloc.h"
#include "threads/switch.h"
#include "threads/synch.h"
#include "threads/vaddr.h"

Go to the source code of this file.

Data Structures

struct  kernel_thread_frame

Defines

#define THREAD_MAGIC   0xcd6abf4b
#define TIME_SLICE   4

Functions

static void kernel_thread (thread_func *, void *aux)
static void idle (void *aux UNUSED)
static struct threadrunning_thread (void)
static struct threadnext_thread_to_run (void)
static void init_thread (struct thread *, const char *name, int priority)
static bool is_thread (struct thread *)
void thread_start (void)
void thread_tick (void)
void thread_print_stats (void)
tid_t thread_create (const char *name, int priority, thread_func *function, void *aux)
void thread_block (void)
void thread_unblock (struct thread *t)
const char * thread_name (void)
struct threadthread_current (void)
tid_t thread_tid (void)
void thread_exit (void)
void thread_yield (void)
void thread_foreach (thread_action_func *func, void *aux)
void thread_set_priority (int new_priority)
int thread_get_priority (void)
void thread_set_nice (int nice UNUSED)
int thread_get_nice (void)
int thread_get_load_avg (void)
int thread_get_recent_cpu (void)
static void idle (void *idle_started_ UNUSED)
static void * alloc_frame (struct thread *t, size_t size)
void schedule_tail (struct thread *prev)
static void schedule (void)
static tid_t allocate_tid (void)

Variables

static struct list ready_list
static struct list all_list
static struct threadidle_thread
static struct threadinitial_thread
static struct lock tid_lock
static long long idle_ticks
static long long kernel_ticks
static long long user_ticks
static unsigned thread_ticks
bool thread_mlfqs
uint32_t thread_stack_ofs = offsetof (struct thread, stack)


Define Documentation

#define THREAD_MAGIC   0xcd6abf4b

Definition at line 22 of file thread.c.

Referenced by init_thread().

#define TIME_SLICE   4

Definition at line 55 of file thread.c.

Referenced by thread_tick().


Function Documentation

static void* alloc_frame ( struct thread t,
size_t  size 
) [static]

Definition at line 479 of file thread.c.

References ASSERT, is_thread(), and thread::stack.

Referenced by thread_create().

static tid_t allocate_tid ( void   )  [static]

Definition at line 574 of file thread.c.

References lock_acquire(), lock_release(), thread::tid, and tid_lock.

Referenced by is_thread(), and thread_create().

static void idle ( void *idle_started_  UNUSED  )  [static]

Definition at line 398 of file thread.c.

References intr_disable(), sema_up(), thread_block(), and thread_current().

static void idle ( void *aux  UNUSED  )  [static]

Referenced by thread_start().

static void init_thread ( struct thread t,
const char *  name,
int  priority 
) [static]

static bool is_thread ( struct thread t  )  [static]

static void kernel_thread ( thread_func function,
void *  aux 
) [static]

Definition at line 428 of file thread.c.

References ASSERT, intr_enable(), NULL, and thread_exit().

Referenced by thread_create().

static struct thread * next_thread_to_run ( void   )  [static, read]

Definition at line 495 of file thread.c.

References thread::elem, list_empty(), list_entry, list_pop_front(), and ready_list.

Referenced by schedule().

struct thread * running_thread ( void   )  [static, read]

Definition at line 439 of file thread.c.

References pg_round_down().

Referenced by is_thread(), schedule(), schedule_tail(), and thread_current().

static void schedule ( void   )  [static]

void schedule_tail ( struct thread prev  ) 

void thread_block ( void   ) 

tid_t thread_create ( const char *  name,
int  priority,
thread_func function,
void *  aux 
)

struct thread* thread_current ( void   )  [read]

void thread_exit ( void   ) 

void thread_foreach ( thread_action_func func,
void *  aux 
)

int thread_get_load_avg ( void   ) 

int thread_get_nice ( void   ) 

Definition at line 366 of file thread.c.

int thread_get_priority ( void   ) 

int thread_get_recent_cpu ( void   ) 

Definition at line 382 of file thread.c.

Referenced by test_mlfqs_recent_1().

const char* thread_name ( void   ) 

void thread_print_stats ( void   ) 

Definition at line 145 of file thread.c.

References idle_ticks, kernel_ticks, printf(), and user_ticks.

Referenced by print_stats().

void thread_set_nice ( int nice  UNUSED  ) 

Definition at line 359 of file thread.c.

Referenced by load_thread(), test_mlfqs_fair(), and test_mlfqs_load_avg().

void thread_set_priority ( int  new_priority  ) 

void thread_start ( void   ) 

Definition at line 107 of file thread.c.

References idle(), intr_enable(), PRI_MIN, sema_down(), sema_init(), and thread_create().

Referenced by main().

void thread_tick ( void   ) 

tid_t thread_tid ( void   ) 

Definition at line 282 of file thread.c.

References thread_current(), and thread::tid.

void thread_unblock ( struct thread t  ) 

void thread_yield ( void   ) 


Variable Documentation

struct list all_list [static]

Definition at line 30 of file thread.c.

Referenced by init_thread(), is_thread(), and thread_foreach().

struct thread* idle_thread [static]

Definition at line 33 of file thread.c.

long long idle_ticks [static]

Definition at line 50 of file thread.c.

Referenced by thread_print_stats(), and thread_tick().

struct thread* initial_thread [static]

Definition at line 36 of file thread.c.

long long kernel_ticks [static]

Definition at line 51 of file thread.c.

Referenced by thread_print_stats(), and thread_tick().

struct list ready_list [static]

Definition at line 26 of file thread.c.

Referenced by is_thread(), next_thread_to_run(), thread_unblock(), and thread_yield().

uint32_t thread_stack_ofs = offsetof (struct thread, stack)

Definition at line 588 of file thread.c.

unsigned thread_ticks [static]

Definition at line 56 of file thread.c.

Referenced by schedule_tail(), and thread_tick().

struct lock tid_lock [static]

Definition at line 39 of file thread.c.

Referenced by allocate_tid(), and is_thread().

long long user_ticks [static]

Definition at line 52 of file thread.c.

Referenced by thread_print_stats(), and thread_tick().


Generated on Mon Jan 10 16:43:58 2011 for Pintos by  doxygen 1.5.6