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
  • master
1 result

Target

Select target project
  • y2-rhymansaib/pintos_student
1 result
Select Git revision
  • master
1 result
Show changes
Showing
with 80 additions and 437 deletions
#ifndef __LIB_SYSCALL_NR_H
#define __LIB_SYSCALL_NR_H
/* System call numbers. */
enum
{
/* Projects 2 and later. */
SYS_HALT, /* Halt the operating system. */
SYS_EXIT, /* Terminate this process. */
SYS_EXEC, /* Start another process. */
SYS_WAIT, /* Wait for a child process to die. */
SYS_CREATE, /* Create a file. */
SYS_REMOVE, /* Delete a file. */
SYS_OPEN, /* Open a file. */
SYS_FILESIZE, /* Obtain a file's size. */
SYS_READ, /* Read from a file. */
SYS_WRITE, /* Write to a file. */
SYS_SEEK, /* Change position in a file. */
SYS_TELL, /* Report current position in a file. */
SYS_CLOSE, /* Close a file. */
/* Project 3 and optionally project 4. */
SYS_MMAP, /* Map a file into memory. */
SYS_MUNMAP, /* Remove a memory mapping. */
/* Project 4 only. */
SYS_CHDIR, /* Change the current directory. */
SYS_MKDIR, /* Create a directory. */
SYS_READDIR, /* Reads a directory entry. */
SYS_ISDIR, /* Tests if a fd represents a directory. */
SYS_INUMBER /* Returns the inode number for a fd. */
};
#endif /* lib/syscall-nr.h */
/* Hash table.
This data structure is thoroughly documented in the Tour of
Pintos for Project 3.
See hash.h for basic information. */
#include "hash.h"
#include "../debug.h"
#include "threads/malloc.h"
......
#ifndef __LIB_KERNEL_HASH_H
#define __LIB_KERNEL_HASH_H
/* Hash table.
This data structure is thoroughly documented in the Tour of
Pintos for Project 3.
This is a standard hash table with chaining. To locate an
element in the table, we compute a hash function over the
element's data and use that as an index into an array of
doubly linked lists, then linearly search the list.
The chain lists do not use dynamic allocation. Instead, each
structure that can potentially be in a hash must embed a
struct hash_elem member. All of the hash functions operate on
these `struct hash_elem's. The hash_entry macro allows
conversion from a struct hash_elem back to a structure object
that contains it. This is the same technique used in the
linked list implementation. Refer to lib/kernel/list.h for a
detailed explanation. */
#include <stdbool.h>
#include <stddef.h>
......
......@@ -206,3 +206,4 @@ binary_search (const void *key, const void *array, size_t cnt, size_t size,
return NULL;
}
#ifndef __LIB_SYSCALL_NR_H
#define __LIB_SYSCALL_NR_H
/* System call numbers. */
enum
{
/* Projects 2 and later. */
SYS_HALT, /* Halt the operating system. */
SYS_EXIT, /* Terminate this process. */
SYS_EXEC, /* Start another process. */
SYS_WAIT, /* Wait for a child process to die. */
SYS_CREATE, /* Create a file. */
SYS_REMOVE, /* Delete a file. */
SYS_OPEN, /* Open a file. */
SYS_FILESIZE, /* Obtain a file's size. */
SYS_READ, /* Read from a file. */
SYS_WRITE, /* Write to a file. */
SYS_SEEK, /* Change position in a file. */
SYS_TELL, /* Report current position in a file. */
SYS_CLOSE, /* Close a file. */
/* Project 3 and optionally project 4. */
SYS_MMAP, /* Map a file into memory. */
SYS_MUNMAP, /* Remove a memory mapping. */
/* Project 4 only. */
SYS_CHDIR, /* Change the current directory. */
SYS_MKDIR, /* Create a directory. */
SYS_READDIR, /* Reads a directory entry. */
SYS_ISDIR, /* Tests if a fd represents a directory. */
SYS_INUMBER /* Returns the inode number for a fd. */
SYS_HALT,
SYS_EXIT,
SYS_EXEC,
SYS_WAIT,
SYS_CREATE,
SYS_REMOVE,
SYS_OPEN,
SYS_FILESIZE,
SYS_READ,
SYS_WRITE,
SYS_SEEK,
SYS_TELL,
SYS_CLOSE,
SYS_MMAP,SYS_MUNMAP,SYS_CHDIR,SYS_MKDIR,SYS_READDIR,SYS_ISDIR,SYS_INUMBER
};
#endif /* lib/syscall-nr.h */
#endif
......@@ -19,7 +19,6 @@ typedef int mapid_t;
#define EXIT_SUCCESS 0 /* Successful execution. */
#define EXIT_FAILURE 1 /* Unsuccessful execution. */
/* Projects 2 and later. */
void halt (void) NO_RETURN;
void exit (int status) NO_RETURN;
pid_t exec (const char *file);
......@@ -34,15 +33,13 @@ void seek (int fd, unsigned position);
unsigned tell (int fd);
void close (int fd);
/* Project 3 and optionally project 4. */
mapid_t mmap (int fd, void *addr);
void munmap (mapid_t);
/* Project 4 only. */
bool chdir (const char *dir);
bool mkdir (const char *dir);
bool readdir (int fd, char name[READDIR_MAX_LEN + 1]);
bool isdir (int fd);
int inumber (int fd);
#endif /* lib/user/syscall.h */
#endif
######### PINTOS Macro #########
# Root directory which has /src as its child
export PINTOS_DIR='/home/you_may_edit_here/pintos'
export TEST_EMUL='bochs'
export PINTOS_PRJ='threads'
# Test directory. One of 'threads' 'userprog' 'vm' 'filesys/extended'
export TEST_DIR='threads'
# Test item
export TEST_ITEM='alarm-multiple'
# Additional test file like 'child-simple' 'tar' ...
export ADD_TEST_FILE='child-simple'
export PATH=$PINTOS_DIR/src/utils/:$PATH
alias gop='cd $PINTOS_DIR/src/$PINTOS_PRJ;cd build'
alias editrc='vi ~/.pintosrc'
alias applyrc='source ~/.pintosrc'
alias runitem='pintos --$TEST_EMUL -- -q run $TEST_ITEM'
alias checkitem='make tests/$TEST_DIR/$TEST_ITEM.result'
alias debugitem='pintos --$TEST_EMUL --gdb -- run $TEST_ITEM'
alias debugpintos='pintos-gdb kernel.o'
alias makedisk='pintos-mkdisk filesys.dsk --filesys-size=2;pintos-mkdisk swap.dsk --swap-size=4'
alias copyitem='pintos -p tests/$TEST_DIR/$TEST_ITEM -a $TEST_ITEM -- -f -q'
alias copyadd='pintos -p tests/$TEST_DIR/$ADD_TEST_FILE -a $ADD_TEST_FILE -- -q'
alias copysample='pintos -p ../../tests/$TEST_DIR/sample.txt -a sample.txt -- -q'
alias debugcopy='pintos -p tests/$TEST_DIR/$TEST_ITEM -a $TEST_ITEM --gdb --$TEST_EMUL -- -f -q'
alias debugtar='pintos --$TEST_EMUL --gdb -- -q run "tar fs.tar /"'
diff -urp bochs-2.2.6/gdbstub.cc bochs-2.2.6.orig/gdbstub.cc
--- bochs-2.2.6.orig/gdbstub.cc 2006-01-17 09:15:29.000000000 -0800
+++ bochs-2.2.6/gdbstub.cc 2006-04-03 13:47:39.000000000 -0700
@@ -672,35 +672,36 @@
case 'g':
#if !BX_SUPPORT_X86_64
- registers[0] = EAX;
- registers[1] = ECX;
- registers[2] = EDX;
- registers[3] = EBX;
- registers[4] = ESP;
- registers[5] = EBP;
- registers[6] = ESI;
- registers[7] = EDI;
+ WriteHostDWordToLittleEndian(registers + 0, EAX);
+ WriteHostDWordToLittleEndian(registers + 1, ECX);
+ WriteHostDWordToLittleEndian(registers + 2, EDX);
+ WriteHostDWordToLittleEndian(registers + 3, EBX);
+ WriteHostDWordToLittleEndian(registers + 4, ESP);
+ WriteHostDWordToLittleEndian(registers + 5, EBP);
+ WriteHostDWordToLittleEndian(registers + 6, ESI);
+ WriteHostDWordToLittleEndian(registers + 7, EDI);
if (last_stop_reason == GDBSTUB_EXECUTION_BREAKPOINT)
{
- registers[8] = EIP + 1;
+ WriteHostDWordToLittleEndian(registers + 8, EIP + 1);
}
else
{
- registers[8] = EIP;
+ WriteHostDWordToLittleEndian(registers + 8, EIP);
}
- registers[9] = BX_CPU_THIS_PTR read_eflags();
- registers[10] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value;
- registers[11] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value;
- registers[12] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value;
- registers[13] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value;
- registers[14] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value;
- registers[15] =
- BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value;
+ WriteHostDWordToLittleEndian(registers + 9,
+ BX_CPU_THIS_PTR read_eflags());
+ WriteHostDWordToLittleEndian(registers + 10,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_CS].selector.value);
+ WriteHostDWordToLittleEndian(registers + 11,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_SS].selector.value);
+ WriteHostDWordToLittleEndian(registers + 12,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_DS].selector.value);
+ WriteHostDWordToLittleEndian(registers + 13,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_ES].selector.value);
+ WriteHostDWordToLittleEndian(registers + 14,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].selector.value);
+ WriteHostDWordToLittleEndian(registers + 15,
+ BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].selector.value);
mem2hex((char *)registers, obuf, NUMREGSBYTES);
#else
#define PUTREG(buf, val, len) do { \
#! /bin/sh -e
if test -z "$SRCDIR" || test -z "$PINTOSDIR" || test -z "$DSTDIR"; then
echo "usage: env SRCDIR=<srcdir> PINTOSDIR=<srcdir> DSTDIR=<dstdir> sh $0"
echo " where <srcdir> contains bochs-2.2.6.tar.gz"
echo " and <pintosdir> is the root of the pintos source tree"
echo " and <dstdir> is the installation prefix (e.g. /usr/local)"
exit 1
fi
cd /tmp
mkdir $$
cd $$
mkdir bochs-2.2.6
tar xzf $SRCDIR/bochs-2.2.6.tar.gz
cd bochs-2.2.6
cat $PINTOSDIR/src/misc/bochs-2.2.6-ms-extensions.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-big-endian.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-jitter.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-triple-fault.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-solaris-tty.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-page-fault-segv.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-paranoia.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-gdbstub-ENN.patch | patch -p1
cat $PINTOSDIR/src/misc/bochs-2.2.6-namespace.patch | patch -p1
if test "`uname -s`" = "SunOS"; then
cat $PINTOSDIR/src/misc/bochs-2.2.6-solaris-link.patch | patch -p1
fi
CFGOPTS="--with-x --with-x11 --with-term --with-nogui --prefix=$DSTDIR --enable-cpu-level=6"
mkdir plain &&
cd plain &&
../configure $CFGOPTS --enable-gdb-stub &&
make &&
make install &&
cd ..
mkdir with-dbg &&
cd with-dbg &&
../configure --enable-debugger $CFGOPTS &&
make &&
cp bochs $DSTDIR/bin/bochs-dbg &&
cd ..
--- bochs-2.2.6/gdbstub.cc 2006-01-17 12:15:29.000000000 -0500
+++ bochs-2.2.6-patched/gdbstub.cc 2007-02-06 23:04:51.095523904 -0500
@@ -515,7 +515,7 @@
}
else
{
- put_reply("ENN");
+ put_reply("Eff");
}
}
break;
@@ -761,7 +761,7 @@
}
else
{
- put_reply("ENN");
+ put_reply("Eff");
}
break;
@@ -782,7 +782,7 @@
}
else
{
- put_reply("ENN");
+ put_reply("Eff");
}
break;
diff -urp bochs-2.2.6/iodev/pit82c54.cc bochs-2.2.6.orig/iodev/pit82c54.cc
--- bochs-2.2.6.orig/iodev/pit82c54.cc 2006-01-08 12:39:08.000000000 -0800
+++ bochs-2.2.6/iodev/pit82c54.cc 2006-04-03 14:00:27.000000000 -0700
@@ -28,6 +28,7 @@
#include "iodev.h"
#include "pit82c54.h"
+#include <stdlib.h>
#define LOG_THIS this->
@@ -359,7 +360,13 @@
case 2:
if(thisctr.count_written) {
if(thisctr.triggerGATE || thisctr.first_pass) {
- set_count(thisctr, thisctr.inlatch);
+ unsigned n = thisctr.inlatch;
+ if (jitter && n > 5) {
+ n *= (double) rand() / RAND_MAX;
+ if (n < 5)
+ n = 5;
+ }
+ set_count(thisctr, n);
thisctr.next_change_time=(thisctr.count_binary-1) & 0xFFFF;
thisctr.null_count=0;
if(thisctr.inlatch==1) {
diff -urp bochs-2.2.6/main.cc bochs-2.2.6.orig/main.cc
--- bochs-2.2.6.orig/main.cc 2006-01-22 04:31:15.000000000 -0800
+++ bochs-2.2.6/main.cc 2006-04-03 14:00:54.000000000 -0700
@@ -105,6 +105,7 @@
#endif
char *bochsrc_filename = NULL;
+int jitter = 0;
void bx_print_header ()
{
@@ -459,6 +460,13 @@
else if (!strcmp ("-q", argv[arg])) {
SIM->get_param_enum(BXP_BOCHS_START)->set (BX_QUICK_START);
}
+ else if (!strcmp ("-j", argv[arg])) {
+ if (++arg >= argc) BX_PANIC(("-j must be followed by a number"));
+ else {
+ jitter = 1;
+ srand (atoi (argv[arg]));
+ }
+ }
else if (!strcmp ("-f", argv[arg])) {
if (++arg >= argc) BX_PANIC(("-f must be followed by a filename"));
else bochsrc_filename = argv[arg];
diff -up /home/blp/cs140/bochs-2.2.6/bochs.h\~ /home/blp/cs140/bochs-2.2.6/bochs.h
--- bochs-2.2.6/bochs.h.orig 2006-01-28 08:16:02.000000000 -0800
+++ bochs-2.2.6/bochs.h 2006-04-03 14:03:54.000000000 -0700
@@ -698,4 +698,6 @@ int bx_init_hardware ();
#endif
+extern int jitter;
+
#endif /* BX_BOCHS_H */
diff -urp orig/bochs-2.1.1/gui/Makefile.in bochs-2.1.1/gui/Makefile.in
--- orig/bochs-2.1.1/gui/Makefile.in 2003-11-28 07:07:28.000000000 -0800
+++ bochs-2.1.1/gui/Makefile.in 2004-09-13 15:05:09.402039000 -0700
@@ -44,7 +44,7 @@ SHELL = /bin/sh
@SET_MAKE@
CXX = @CXX@
-CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@
+CXXFLAGS = $(BX_INCDIRS) @CXXFLAGS@ @GUI_CXXFLAGS@ -fms-extensions
LOCAL_CXXFLAGS =
LDFLAGS = @LDFLAGS@
LIBS = @LIBS@
--- bochs-2.2.6/bx_debug/symbols.cc 2011-08-19 11:04:11.760139836 -0600
+++ bochs-2.2.6-patched/bx_debug/symbols.cc 2011-08-19 11:04:04.980139837 -0600
@@ -92,6 +92,7 @@
#endif
using namespace std;
+namespace std { using namespace __gnu_cxx; }
struct symbol_entry_t
{
Index: bochs-2.2.6/cpu/exception.cc
diff -u bochs-2.2.6/cpu/exception.cc\~ bochs-2.2.6/cpu/exception.cc
--- bochs-2.2.6/cpu/exception.cc~ 2006-09-28 15:51:39.000000000 -0700
+++ bochs-2.2.6/cpu/exception.cc 2006-12-08 11:14:33.000000000 -0800
@@ -1033,6 +1033,10 @@ void BX_CPU_C::exception(unsigned vector
BX_CPU_THIS_PTR curr_exception[0] = exception_type;
}
+#if BX_GDBSTUB
+ bx_gdbstub_exception(vector);
+#endif
+
#if BX_CPU_LEVEL >= 2
if (!real_mode()) {
BX_CPU_THIS_PTR interrupt(vector, 0, push_error, error_code);
Index: bochs-2.2.6/gdbstub.cc
diff -u bochs-2.2.6/gdbstub.cc\~ bochs-2.2.6/gdbstub.cc
--- bochs-2.2.6/gdbstub.cc~ 2006-09-28 15:51:39.000000000 -0700
+++ bochs-2.2.6/gdbstub.cc 2006-12-08 11:12:03.000000000 -0800
@@ -26,6 +26,7 @@ static int last_stop_reason = GDBSTUB_ST
#define GDBSTUB_EXECUTION_BREAKPOINT (0xac1)
#define GDBSTUB_TRACE (0xac2)
#define GDBSTUB_USER_BREAK (0xac3)
+#define GDBSTUB_EXCEPTION_0E (0xac4)
static int listen_socket_fd;
static int socket_fd;
@@ -271,6 +272,12 @@ int bx_gdbstub_check(unsigned int eip)
return(GDBSTUB_STOP_NO_REASON);
}
+void bx_gdbstub_exception(unsigned int nr)
+{
+ if (nr == 0x0e)
+ last_stop_reason = GDBSTUB_EXCEPTION_0E;
+}
+
static int remove_breakpoint(unsigned int addr, int len)
{
unsigned int i;
@@ -452,6 +459,10 @@ static void debug_loop(void)
{
write_signal(&buf[1], SIGTRAP);
}
+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
+ {
+ write_signal(&buf[1], SIGSEGV);
+ }
else
{
write_signal(&buf[1], 0);
@@ -476,10 +487,14 @@ static void debug_loop(void)
{
write_signal(&buf[1], SIGTRAP);
}
- else
+ else if (last_stop_reason == GDBSTUB_EXCEPTION_0E)
{
write_signal(&buf[1], SIGSEGV);
}
+ else
+ {
+ write_signal(&buf[1], 0);
+ }
put_reply(buf);
break;
}
Index: bochs-2.2.6/bochs.h
diff -u bochs-2.2.6/bochs.h\~ bochs-2.2.6/bochs.h
--- bochs-2.2.6/bochs.h~ 2006-09-28 15:51:39.000000000 -0700
+++ bochs-2.2.6/bochs.h 2006-12-08 11:14:19.000000000 -0800
@@ -375,6 +375,7 @@ BOCHSAPI extern logfunc_t *genlog;
// defines for GDB stub
void bx_gdbstub_init(int argc, char* argv[]);
int bx_gdbstub_check(unsigned int eip);
+void bx_gdbstub_exception(unsigned int nr);
#define GDBSTUB_STOP_NO_REASON (0xac0)
#if BX_SUPPORT_SMP
Index: bochs-2.2.6/iodev/hdimage.h
diff -u bochs-2.2.6/iodev/hdimage.h\~ bochs-2.2.6/iodev/hdimage.h
--- bochs-2.2.6/iodev/hdimage.h~ 2005-11-06 03:07:01.000000000 -0800
+++ bochs-2.2.6/iodev/hdimage.h 2006-09-28 15:55:50.000000000 -0700
@@ -273,14 +273,8 @@ class sparse_image_t : public device_ima
void panic(const char * message);
off_t
-#ifndef PARANOID
- sparse_image_t::
-#endif
get_physical_offset();
void
-#ifndef PARANOID
- sparse_image_t::
-#endif
set_virtual_page(Bit32u new_virtual_page);
void read_header();
ssize_t read_page_fragment(Bit32u read_virtual_page, Bit32u read_page_offset, size_t read_size, void * buf);