PKUOS - Pintos
Pintos source browser for PKU Operating System course
Data Structures | Macros | Functions
mlfqs-fair.c File Reference
#include <stdio.h>
#include <inttypes.h>
#include "tests/threads/tests.h"
#include "threads/init.h"
#include "threads/malloc.h"
#include "threads/palloc.h"
#include "threads/synch.h"
#include "threads/thread.h"
#include "devices/timer.h"
Include dependency graph for mlfqs-fair.c:

Go to the source code of this file.

Data Structures

struct  thread_info
 

Macros

#define MAX_THREAD_CNT   20
 

Functions

static void test_mlfqs_fair (int thread_cnt, int nice_min, int nice_step)
 Measures the correctness of the "nice" implementation. More...
 
void test_mlfqs_fair_2 (void)
 
void test_mlfqs_fair_20 (void)
 
void test_mlfqs_nice_2 (void)
 
void test_mlfqs_nice_10 (void)
 
static void load_thread (void *aux)
 

Macro Definition Documentation

◆ MAX_THREAD_CNT

#define MAX_THREAD_CNT   20

Definition at line 54 of file mlfqs-fair.c.

Function Documentation

◆ load_thread()

static void load_thread ( void *  aux)
static

Definition at line 108 of file mlfqs-fair.c.

References thread_info::nice, thread_info::start_time, thread_set_nice(), thread_info::tick_count, timer_elapsed(), TIMER_FREQ, timer_sleep(), and timer_ticks().

Referenced by test_mlfqs_fair().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_mlfqs_fair()

static void test_mlfqs_fair ( int  thread_cnt,
int  nice_min,
int  nice_step 
)
static

Measures the correctness of the "nice" implementation.

The "fair" tests run either 2 or 20 threads all niced to 0. The threads should all receive approximately the same number of ticks. Each test runs for 30 seconds, so the ticks should also sum to approximately 30 * 100 == 3000 ticks.

The mlfqs-nice-2 test runs 2 threads, one with nice 0, the other with nice 5, which should receive 1,904 and 1,096 ticks, respectively, over 30 seconds.

The mlfqs-nice-10 test runs 10 threads with nice 0 through 9. They should receive 672, 588, 492, 408, 316, 232, 152, 92, 40, and 8 ticks, respectively, over 30 seconds.

(The above are computed via simulation in mlfqs.pm.)

Definition at line 66 of file mlfqs-fair.c.

References ASSERT, load_thread(), MAX_THREAD_CNT, msg(), name, thread_info::nice, PRI_DEFAULT, PRId64, snprintf(), thread_info::start_time, start_time, thread_create(), thread_mlfqs, thread_set_nice(), thread_info::tick_count, timer_elapsed(), TIMER_FREQ, timer_sleep(), and timer_ticks().

Here is the call graph for this function:

◆ test_mlfqs_fair_2()

void test_mlfqs_fair_2 ( void  )

Definition at line 31 of file mlfqs-fair.c.

◆ test_mlfqs_fair_20()

void test_mlfqs_fair_20 ( void  )

Definition at line 37 of file mlfqs-fair.c.

◆ test_mlfqs_nice_10()

void test_mlfqs_nice_10 ( void  )

Definition at line 49 of file mlfqs-fair.c.

◆ test_mlfqs_nice_2()

void test_mlfqs_nice_2 ( void  )

Definition at line 43 of file mlfqs-fair.c.