PKUOS - Pintos
Pintos source browser for PKU Operating System course
Data Structures | Macros | Functions
list.c File Reference
#include <debug.h>
#include <list.h>
#include <random.h>
#include <stdio.h>
#include "threads/test.h"
Include dependency graph for list.c:

Go to the source code of this file.

Data Structures

struct  value
 A linked list element. More...
 

Macros

#define MAX_SIZE   64
 Test program for lib/kernel/list.c. More...
 

Functions

static void shuffle (struct value[], size_t)
 
static bool value_less (const struct list_elem *, const struct list_elem *, void *)
 
static void verify_list_fwd (struct list *list, int size)
 Verifies that LIST contains the values 0...SIZE when traversed in forward order. More...
 
static void verify_list_bkwd (struct list *list, int size)
 Verifies that LIST contains the values 0...SIZE when traversed in reverse order. More...
 
void test (void)
 Test the linked list implementation. More...
 
static void shuffle (struct value *array, size_t cnt)
 Shuffles the CNT elements in ARRAY into random order. More...
 
static bool value_less (const struct list_elem *a_, const struct list_elem *b_, void *aux UNUSED)
 Returns true if value A is less than value B, false otherwise. More...
 

Macro Definition Documentation

◆ MAX_SIZE

#define MAX_SIZE   64

Test program for lib/kernel/list.c.

Attempts to test the list functionality that is not sufficiently tested elsewhere in Pintos.

This is not a test we will run on your submitted projects. It is here for completeness. Maximum number of elements in a linked list that we will test.

Definition at line 19 of file list.c.

Function Documentation

◆ shuffle() [1/2]

static void shuffle ( struct value array,
size_t  cnt 
)
static

Shuffles the CNT elements in ARRAY into random order.

Definition at line 113 of file list.c.

References random_ulong().

Here is the call graph for this function:

◆ shuffle() [2/2]

static void shuffle ( struct value  [],
size_t   
)
static

Referenced by test(), and test_main().

Here is the caller graph for this function:

◆ test()

void test ( void  )

Test the linked list implementation.

Definition at line 36 of file list.c.

References ASSERT, value::elem, list_begin(), list_end(), list_entry, list_init(), list_insert(), list_insert_ordered(), list_max(), list_min(), list_next(), list_push_back(), list_reverse(), list_sort(), list_unique(), MAX_SIZE, NULL, printf(), random_ulong(), shuffle(), value::value, value_less(), verify_list_bkwd(), and verify_list_fwd().

Referenced by test_sleep().

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

◆ value_less() [1/2]

static bool value_less ( const struct list_elem ,
const struct list_elem ,
void *   
)
static

Referenced by test().

Here is the caller graph for this function:

◆ value_less() [2/2]

static bool value_less ( const struct list_elem a_,
const struct list_elem b_,
void *aux  UNUSED 
)
static

Returns true if value A is less than value B, false otherwise.

Definition at line 129 of file list.c.

References value::elem, list_entry, and value::value.

Here is the call graph for this function:

◆ verify_list_bkwd()

static void verify_list_bkwd ( struct list list,
int  size 
)
static

Verifies that LIST contains the values 0...SIZE when traversed in reverse order.

Definition at line 160 of file list.c.

References ASSERT, value::elem, list_entry, list_prev(), list_rbegin(), list_rend(), and value::value.

Referenced by test().

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

◆ verify_list_fwd()

static void verify_list_fwd ( struct list list,
int  size 
)
static

Verifies that LIST contains the values 0...SIZE when traversed in forward order.

Definition at line 141 of file list.c.

References ASSERT, value::elem, list_begin(), list_end(), list_entry, list_next(), and value::value.

Referenced by test().

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