diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-03-17 01:47:23 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-03-17 01:47:23 +0100 |
| commit | 185f7edbf34d9926bb0083281fa61e800887eff8 (patch) | |
| tree | f0abfd8a4be5eb951a4d7fde7a7ac367c05a6b8f /src/standalone/upg5 | |
| parent | 6dab587f279e5320dc3fc2dcc9977af98a323c33 (diff) | |
| parent | b7002c53057d4ae049237786d26f00a762dbc2ea (diff) | |
| download | pintos-rs-185f7edbf34d9926bb0083281fa61e800887eff8.tar.gz | |
Merge remote-tracking branch 'upstream/master'main
Diffstat (limited to 'src/standalone/upg5')
| -rw-r--r-- | src/standalone/upg5/pagedir.c | 8 | ||||
| -rw-r--r-- | src/standalone/upg5/pagedir.h | 42 | ||||
| -rw-r--r-- | src/standalone/upg5/pagedir.o | bin | 8784 -> 0 bytes | |||
| -rw-r--r-- | src/standalone/upg5/thread.h | 16 | ||||
| -rw-r--r-- | src/standalone/upg5/verify_adr.c | 90 |
5 files changed, 0 insertions, 156 deletions
diff --git a/src/standalone/upg5/pagedir.c b/src/standalone/upg5/pagedir.c deleted file mode 100644 index b60d871..0000000 --- a/src/standalone/upg5/pagedir.c +++ /dev/null @@ -1,8 +0,0 @@ -/* The code that simulates and tests your address verification. How - this is done is disclosed. As a student you shall not compile this - file, but instead compile your program with the .o file as: - - gcc -Wall -Wextra -std=c99 -pedantic -m32 -g verify_adr.c pagedir.o - */ -#error Read comment above. Leave this line in place. - diff --git a/src/standalone/upg5/pagedir.h b/src/standalone/upg5/pagedir.h deleted file mode 100644 index 2919d1a..0000000 --- a/src/standalone/upg5/pagedir.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef PAGEDIR_H -#define PAGEDIR_H - -typedef int bool; -#define false 0 -#define true 1 - -/* Returns true iff 'adr' contains a null-character ('\0'). */ -bool is_end_of_string(char* adr); - -/* Returns the start address of the page that contains 'adr'. */ -void* pg_round_down(const void* adr); - -/* Returns the page number of the page that contains 'adr'. - * Page numbers are counted with start at zero (0). - */ -unsigned pg_no(const void* adr); - -/* Uses the page table to translate from logic to physical - * address. Returns NULL if the translation fail. - * - * The first parameter specify the top level page table to - * use. Normally you will find it in the structure corresponding - * to your operating systems PCB (Process Control Block). - */ -void *pagedir_get_page (void *pagetable, const void *adr); - -/* Page size: The number of bytes in each page. */ -#define PGSIZE 100 - -/* Functions used to simulate a paging system and testing your - * solution. */ -void start_evaluate_algorithm(void* start, int size); -void evaluate(bool result); -void end_evaluate_algorithm(); - -/* Let us decide how costly a simulated page fault is in terms of - * time. Does not exist in Pintos. Set to zero (0) for faster - * testing. */ -void simulator_set_pagefault_time(unsigned i); - -#endif diff --git a/src/standalone/upg5/pagedir.o b/src/standalone/upg5/pagedir.o Binary files differdeleted file mode 100644 index 470080a..0000000 --- a/src/standalone/upg5/pagedir.o +++ /dev/null diff --git a/src/standalone/upg5/thread.h b/src/standalone/upg5/thread.h deleted file mode 100644 index 62568ab..0000000 --- a/src/standalone/upg5/thread.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef THREAD_H -#define THREAD_H - -struct thread -{ - /* This is just a part of the Pintos Thread. */ - void* pagedir; -}; - -/* Initiate the threading system. */ -void thread_init(); - -/* Return a pointer to the currently active thread. */ -struct thread* thread_current(); - -#endif diff --git a/src/standalone/upg5/verify_adr.c b/src/standalone/upg5/verify_adr.c deleted file mode 100644 index 9bac64f..0000000 --- a/src/standalone/upg5/verify_adr.c +++ /dev/null @@ -1,90 +0,0 @@ -#include <stdlib.h> -#include "pagedir.h" -#include "thread.h" - -/* verfy_*_lenght are intended to be used in a system call that accept - * parameters containing suspisious (user mode) adresses. The - * operating system (executng the system call in kernel mode) must not - * be fooled into using (reading or writing) addresses not available - * to the user mode process performing the system call. - * - * In pagedir.h you can find some supporting functions that will help - * you dermining if a logic address can be translated into a physical - * addrerss using the process pagetable. A single translation is - * costly. Work out a way to perform as few translations as - * possible. - * - * Recommended compilation command: - * - * gcc -Wall -Wextra -std=gnu99 -pedantic -m32 -g pagedir.o verify_adr.c - */ -#error Read comment above and then remove this line. - -/* Verify all addresses from and including 'start' up to but excluding - * (start+length). */ -bool verify_fix_length(void* start, int length) -{ - // ADD YOUR CODE HERE -} - -/* Verify all addresses from and including 'start' up to and including - * the address first containg a null-character ('\0'). (The way - * C-strings are stored.) - */ -bool verify_variable_length(char* start) -{ - // ADD YOUR CODE HERE -} - -/* Definition of test cases. */ -struct test_case_t -{ - void* start; - unsigned length; -}; - -#define TEST_CASE_COUNT 6 - -const struct test_case_t test_case[TEST_CASE_COUNT] = -{ - {(void*)100, 100}, /* one full page */ - {(void*)199, 102}, - {(void*)101, 98}, - {(void*)250, 190}, - {(void*)250, 200}, - {(void*)250, 210} -}; - -/* This main program will evalutate your solution. */ -int main(int argc, char* argv[]) -{ - int i; - bool result; - - if ( argc == 2 ) - { - simulator_set_pagefault_time( atoi(argv[1]) ); - } - thread_init(); - - /* Test the algorithm with a given intervall (a buffer). */ - for (i = 0; i < TEST_CASE_COUNT; ++i) - { - start_evaluate_algorithm(test_case[i].start, test_case[i].length); - result = verify_fix_length(test_case[i].start, test_case[i].length); - evaluate(result); - end_evaluate_algorithm(); - } - - /* Test the algorithm with a C-string (start address with - * terminating null-character). - */ - for (i = 0; i < TEST_CASE_COUNT; ++i) - { - start_evaluate_algorithm(test_case[i].start, test_case[i].length); - result = verify_variable_length(test_case[i].start); - evaluate(result); - end_evaluate_algorithm(); - } - return 0; -} |
