Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found
Select Git revision

Target

Select target project
  • y2-rhymansaib/pintos_student
1 result
Select Git revision
Show changes
Showing
with 6 additions and 332 deletions
# Percentage of the testing point total designated for each set of
# tests.
20.0% tests/threads/Rubric.alarm
40.0% tests/threads/Rubric.priority
40.0% tests/threads/Rubric.mlfqs
30.0% tests/threads/Rubric.alarm
70.0% tests/threads/Rubric.priority
#40.0% tests/threads/Rubric.mlfqs
......@@ -7,9 +7,9 @@ alarm-negative priority-change priority-donate-one \
priority-donate-multiple priority-donate-multiple2 \
priority-donate-nest priority-donate-sema priority-donate-lower \
priority-fifo priority-preempt priority-sema priority-condvar \
priority-donate-chain \
mlfqs-load-1 mlfqs-load-60 mlfqs-load-avg mlfqs-recent-1 mlfqs-fair-2 \
mlfqs-fair-20 mlfqs-nice-2 mlfqs-nice-10 mlfqs-block)
priority-donate-chain)
#mlfqs-load-1 mlfqs-load-60 mlfqs-load-avg mlfqs-recent-1 mlfqs-fair-2 \
#mlfqs-fair-20 mlfqs-nice-2 mlfqs-nice-10 mlfqs-block)
# Sources for tests.
tests/threads_SRC = tests/threads/tests.c
......
/* Invokes a system call with the stack pointer (%esp) set to a
bad address. The process must be terminated with -1 exit
code.
For Project 3: The bad address lies approximately 64MB below
the code segment, so there is no ambiguity that this attempt
must be rejected even after stack growth is implemented.
Moreover, a good stack growth heuristics should probably not
grow the stack for the purpose of reading the system call
number and arguments. */
#include "tests/lib.h"
#include "tests/main.h"
......
Functionality of virtual memory subsystem:
- Test stack growth.
3 pt-grow-stack
3 pt-grow-stk-sc
3 pt-big-stk-obj
3 pt-grow-pusha
- Test paging behavior.
3 page-linear
3 page-parallel
3 page-shuffle
4 page-merge-seq
4 page-merge-par
4 page-merge-mm
4 page-merge-stk
- Test "mmap" system call.
2 mmap-read
2 mmap-write
2 mmap-shuffle
2 mmap-twice
2 mmap-unmap
1 mmap-exit
3 mmap-clean
2 mmap-close
2 mmap-remove
Robustness of virtual memory subsystem:
- Test robustness of page table support.
2 pt-bad-addr
3 pt-bad-read
2 pt-write-code
3 pt-write-code2
4 pt-grow-bad
- Test robustness of "mmap" system call.
1 mmap-bad-fd
1 mmap-inherit
1 mmap-null
1 mmap-zero
2 mmap-misalign
2 mmap-over-code
2 mmap-over-data
2 mmap-over-stk
2 mmap-overlap
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
(pt-grow-stack) begin
(pt-grow-stack) cksum: 3424492700
(pt-grow-stack) end
EOF
pass;
/* This test checks that the stack is properly extended even if
the first access to a stack location occurs inside a system
call.
From Godmar Back. */
#include <string.h>
#include <syscall.h>
#include "tests/vm/sample.inc"
#include "tests/lib.h"
#include "tests/main.h"
void
test_main (void)
{
int handle;
int slen = strlen (sample);
char buf2[65536];
/* Write file via write(). */
CHECK (create ("sample.txt", slen), "create \"sample.txt\"");
CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
CHECK (write (handle, sample, slen) == slen, "write \"sample.txt\"");
close (handle);
/* Read back via read(). */
CHECK ((handle = open ("sample.txt")) > 1, "2nd open \"sample.txt\"");
CHECK (read (handle, buf2 + 32768, slen) == slen, "read \"sample.txt\"");
CHECK (!memcmp (sample, buf2 + 32768, slen), "compare written data against read data");
close (handle);
}
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
check_expected (IGNORE_EXIT_CODES => 1, [<<'EOF']);
(pt-grow-stk-sc) begin
(pt-grow-stk-sc) create "sample.txt"
(pt-grow-stk-sc) open "sample.txt"
(pt-grow-stk-sc) write "sample.txt"
(pt-grow-stk-sc) 2nd open "sample.txt"
(pt-grow-stk-sc) read "sample.txt"
(pt-grow-stk-sc) compare written data against read data
(pt-grow-stk-sc) end
EOF
pass;
/* Try to write to the code segment using a system call.
The process must be terminated with -1 exit code. */
#include "tests/lib.h"
#include "tests/main.h"
void
test_main (void)
{
int handle;
CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");
read (handle, (void *) test_main, 1);
fail ("survived reading data into code segment");
}
/* Try to write to the code segment.
The process must be terminated with -1 exit code. */
#include "tests/lib.h"
#include "tests/main.h"
void
test_main (void)
{
*(int *) test_main = 0;
fail ("writing the code segment succeeded");
}
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
use tests::vm::process_death;
check_process_death ('pt-write-code');
# -*- perl -*-
use strict;
use warnings;
use tests::tests;
check_expected ([<<'EOF']);
(pt-write-code2) begin
(pt-write-code2) open "sample.txt"
pt-write-code2: exit(-1)
EOF
pass;
#include "tests/vm/qsort.h"
#include <stdbool.h>
#include <debug.h>
#include <random.h>
/* Picks a pivot for the quicksort from the SIZE bytes in BUF. */
static unsigned char
pick_pivot (unsigned char *buf, size_t size)
{
ASSERT (size >= 1);
return buf[random_ulong () % size];
}
/* Checks whether the SIZE bytes in ARRAY are divided into an
initial LEFT_SIZE elements all less than PIVOT followed by
SIZE - LEFT_SIZE elements all greater than or equal to
PIVOT. */
static bool
is_partitioned (const unsigned char *array, size_t size,
unsigned char pivot, size_t left_size)
{
size_t i;
for (i = 0; i < left_size; i++)
if (array[i] >= pivot)
return false;
for (; i < size; i++)
if (array[i] < pivot)
return false;
return true;
}
/* Swaps the bytes at *A and *B. */
static void
swap (unsigned char *a, unsigned char *b)
{
unsigned char t = *a;
*a = *b;
*b = t;
}
/* Partitions ARRAY in-place in an initial run of bytes all less
than PIVOT, followed by a run of bytes all greater than or
equal to PIVOT. Returns the length of the initial run. */
static size_t
partition (unsigned char *array, size_t size, int pivot)
{
size_t left_size = size;
unsigned char *first = array;
unsigned char *last = first + left_size;
for (;;)
{
/* Move FIRST forward to point to first element greater than
PIVOT. */
for (;;)
{
if (first == last)
{
ASSERT (is_partitioned (array, size, pivot, left_size));
return left_size;
}
else if (*first >= pivot)
break;
first++;
}
left_size--;
/* Move LAST backward to point to last element no bigger
than PIVOT. */
for (;;)
{
last--;
if (first == last)
{
ASSERT (is_partitioned (array, size, pivot, left_size));
return left_size;
}
else if (*last < pivot)
break;
else
left_size--;
}
/* By swapping FIRST and LAST we extend the starting and
ending sequences that pass and fail, respectively,
PREDICATE. */
swap (first, last);
first++;
}
}
/* Returns true if the SIZE bytes in BUF are in nondecreasing
order, false otherwise. */
static bool
is_sorted (const unsigned char *buf, size_t size)
{
size_t i;
for (i = 1; i < size; i++)
if (buf[i - 1] > buf[i])
return false;
return true;
}
/* Sorts the SIZE bytes in BUF into nondecreasing order, using
the quick-sort algorithm. */
void
qsort_bytes (unsigned char *buf, size_t size)
{
if (!is_sorted (buf, size))
{
int pivot = pick_pivot (buf, size);
unsigned char *left_half = buf;
size_t left_size = partition (buf, size, pivot);
unsigned char *right_half = left_half + left_size;
size_t right_size = size - left_size;
if (left_size <= right_size)
{
qsort_bytes (left_half, left_size);
qsort_bytes (right_half, right_size);
}
else
{
qsort_bytes (right_half, right_size);
qsort_bytes (left_half, left_size);
}
}
}
#ifndef TESTS_VM_QSORT_H
#define TESTS_VM_QSORT_H 1
#include <stddef.h>
void qsort_bytes (unsigned char *buf, size_t size);
#endif /* tests/vm/qsort.h */
char sample[] = {
"=== ALL USERS PLEASE NOTE ========================\n"
"\n"
"CAR and CDR now return extra values.\n"
"\n"
"The function CAR now returns two values. Since it has to go to the\n"
"trouble to figure out if the object is carcdr-able anyway, we figured\n"
"you might as well get both halves at once. For example, the following\n"
"code shows how to destructure a cons (SOME-CONS) into its two slots\n"
"(THE-CAR and THE-CDR):\n"
"\n"
" (MULTIPLE-VALUE-BIND (THE-CAR THE-CDR) (CAR SOME-CONS) ...)\n"
"\n"
"For symmetry with CAR, CDR returns a second value which is the CAR of\n"
"the object. In a related change, the functions MAKE-ARRAY and CONS\n"
"have been fixed so they don't allocate any storage except on the\n"
"stack. This should hopefully help people who don't like using the\n"
"garbage collector because it cold boots the machine so often.\n"
};