Merge branch 'code-review-2-changes' into 'master'
fix: code review 2 changes See merge request lab2425_autumn/pintos_22!52
This commit is contained in:
@@ -16,18 +16,13 @@ stages:
|
|||||||
script:
|
script:
|
||||||
- cd src/$DIR
|
- cd src/$DIR
|
||||||
- make check | tee build.log
|
- make check | tee build.log
|
||||||
- grep -q "FAIL tests/$DIR" build.log && exit 1 || exit 0
|
- grep -vE "^FAIL $IGNORE\$" build.log | grep -q "FAIL tests/$DIR" && exit 1 || exit 0
|
||||||
|
|
||||||
test_devices:
|
test_devices:
|
||||||
extends: .pintos_tests
|
extends: .pintos_tests
|
||||||
variables:
|
variables:
|
||||||
DIR: devices
|
DIR: devices
|
||||||
|
|
||||||
test_filesys:
|
|
||||||
extends: .pintos_tests
|
|
||||||
variables:
|
|
||||||
DIR: filesys
|
|
||||||
|
|
||||||
test_threads:
|
test_threads:
|
||||||
extends: .pintos_tests
|
extends: .pintos_tests
|
||||||
variables:
|
variables:
|
||||||
@@ -42,3 +37,4 @@ test_vm:
|
|||||||
extends: .pintos_tests
|
extends: .pintos_tests
|
||||||
variables:
|
variables:
|
||||||
DIR: vm
|
DIR: vm
|
||||||
|
IGNORE: (tests/vm/pt-grow-stack|tests/vm/pt-grow-pusha|tests/vm/pt-big-stk-obj|tests/vm/pt-overflowstk|tests/vm/pt-write-code2|tests/vm/pt-grow-stk-sc|tests/vm/page-linear|tests/vm/page-parallel|tests/vm/page-merge-seq|tests/vm/page-merge-par|tests/vm/page-merge-stk|tests/vm/page-merge-mm|tests/vm/mmap-read|tests/vm/mmap-close|tests/vm/mmap-overlap|tests/vm/mmap-twice|tests/vm/mmap-write|tests/vm/mmap-exit|tests/vm/mmap-shuffle|tests/vm/mmap-clean|tests/vm/mmap-inherit|tests/vm/mmap-misalign|tests/vm/mmap-null|tests/vm/mmap-over-code|tests/vm/mmap-over-data|tests/vm/mmap-over-stk|tests/vm/mmap-remove)
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ static void kernel_thread (thread_func *, void *aux);
|
|||||||
static void idle (void *aux UNUSED);
|
static void idle (void *aux UNUSED);
|
||||||
static struct thread *running_thread (void);
|
static struct thread *running_thread (void);
|
||||||
static struct thread *next_thread_to_run (void);
|
static struct thread *next_thread_to_run (void);
|
||||||
static void init_process_result (struct thread *t);
|
static bool init_process_result (struct thread *t);
|
||||||
static void init_thread (struct thread *, const char *name, int nice,
|
static void init_thread (struct thread *, const char *name, int nice,
|
||||||
int priority, fp32_t recent_cpu);
|
int priority, fp32_t recent_cpu);
|
||||||
static bool is_thread (struct thread *) UNUSED;
|
static bool is_thread (struct thread *) UNUSED;
|
||||||
@@ -252,7 +252,11 @@ thread_create (const char *name, int priority,
|
|||||||
struct thread *parent_thread = thread_current ();
|
struct thread *parent_thread = thread_current ();
|
||||||
init_thread (t, name, parent_thread->nice, priority, parent_thread->recent_cpu);
|
init_thread (t, name, parent_thread->nice, priority, parent_thread->recent_cpu);
|
||||||
tid = t->tid = allocate_tid ();
|
tid = t->tid = allocate_tid ();
|
||||||
init_process_result (t);
|
if (!init_process_result (t))
|
||||||
|
{
|
||||||
|
palloc_free_page (t);
|
||||||
|
return TID_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef USERPROG
|
#ifdef USERPROG
|
||||||
/* Initialize the thread's file descriptor table. */
|
/* Initialize the thread's file descriptor table. */
|
||||||
@@ -668,15 +672,18 @@ is_thread (struct thread *t)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Allocate and initialise a process result for given thread. */
|
/* Allocate and initialise a process result for given thread. */
|
||||||
static void
|
static bool
|
||||||
init_process_result (struct thread *t)
|
init_process_result (struct thread *t)
|
||||||
{
|
{
|
||||||
struct process_result *result = malloc (sizeof (struct process_result));
|
struct process_result *result = malloc (sizeof (struct process_result));
|
||||||
|
if (result == NULL)
|
||||||
|
return false;
|
||||||
result->tid = t->tid;
|
result->tid = t->tid;
|
||||||
result->exit_status = -1;
|
result->exit_status = -1;
|
||||||
lock_init (&result->lock);
|
lock_init (&result->lock);
|
||||||
sema_init (&result->sema, 0);
|
sema_init (&result->sema, 0);
|
||||||
t->result = result;
|
t->result = result;
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Does basic initialization of T as a blocked thread named
|
/* Does basic initialization of T as a blocked thread named
|
||||||
|
|||||||
@@ -348,12 +348,7 @@ syscall_seek (int fd, unsigned position)
|
|||||||
/* Find the file from the FD. If it does not exist, do nothing. */
|
/* Find the file from the FD. If it does not exist, do nothing. */
|
||||||
struct open_file *file_info = fd_get_file (fd);
|
struct open_file *file_info = fd_get_file (fd);
|
||||||
if (file_info != NULL)
|
if (file_info != NULL)
|
||||||
{
|
|
||||||
/* File exists: Acquire the file system lock to prevent race conditions. */
|
|
||||||
lock_acquire (&filesys_lock);
|
|
||||||
file_seek (file_info->file, position);
|
file_seek (file_info->file, position);
|
||||||
lock_release (&filesys_lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Handles the syscall for returning the next byte in a file referenced by
|
/* Handles the syscall for returning the next byte in a file referenced by
|
||||||
@@ -367,10 +362,7 @@ syscall_tell (int fd)
|
|||||||
if (file_info == NULL)
|
if (file_info == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* Acquire the file system lock to prevent race conditions. */
|
|
||||||
lock_acquire (&filesys_lock);
|
|
||||||
unsigned pos = file_tell (file_info->file);
|
unsigned pos = file_tell (file_info->file);
|
||||||
lock_release (&filesys_lock);
|
|
||||||
|
|
||||||
/* Return the current position in the file. */
|
/* Return the current position in the file. */
|
||||||
return pos;
|
return pos;
|
||||||
|
|||||||
Reference in New Issue
Block a user