Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#57] Fix typo and append conding convention #58

Merged
merged 1 commit into from
Apr 12, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/threads/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "threads/synch.h"
#include "threads/vaddr.h"
#ifdef USERPROG
#include "threads/malloc.h"
#include "userprog/process.h"
#endif

Expand Down Expand Up @@ -191,6 +190,7 @@ thread_create (const char *name, int priority,
struct process *curr_proc = process_current ();
struct process *new_proc = &t->process;

/* Initialize process. */
new_proc->pid = t->tid;
new_proc->parent = curr_proc;
new_proc->status = PROCESS_LOADING;
Expand Down
2 changes: 1 addition & 1 deletion src/userprog/exception.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ page_fault (struct intr_frame *f)
if (!user)
{
f->eip = (void (*) (void)) f->eax;
f->eax = (uint32_t) 0xffffffff;
f->eax = (uint32_t) -1;
return;
}

Expand Down
17 changes: 8 additions & 9 deletions src/userprog/process.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ process_execute (const char *file_name)
args = (struct arguments *) malloc (sizeof (struct arguments));
argument_parser (fn_copy, args);

/* Create a new thread to execute FILE_NAME. */
/* Create a new thread to execute the given file name. */
pid = (pid_t) thread_create (args->argv[0], PRI_DEFAULT, start_process, args);
if (pid == TID_ERROR)
{
Expand All @@ -64,8 +64,9 @@ process_execute (const char *file_name)
return pid;
}

/* Parse arguments from given string, which removes whole adjacent spaces and replace it
with a null character. And then stores it in given argument struct by pointer. */
/* Parse arguments from the given string by replacing whole
adjacent spaces to the null character. Then store it in
given argument struct by pointer. */
static void
argument_parser (char *str_input, struct arguments *args)
{
Expand Down Expand Up @@ -129,10 +130,7 @@ start_process (void *arguments)
exception), returns -1. If TID is invalid or if it was not a
child of the calling process, or if process_wait() has already
been successfully called for the given TID, returns -1
immediately, without waiting.

This function will be implemented in problem 2-2. For now, it
does nothing. */
immediately, without waiting. */
int
process_wait (tid_t child_tid UNUSED)
{
Expand All @@ -148,7 +146,7 @@ process_wait (tid_t child_tid UNUSED)
return child->exit_code;
}

/* Free the current process's resources. */
/* Frees the current process's resources. */
void
process_exit (void)
{
Expand All @@ -164,7 +162,7 @@ process_exit (void)
child->parent = NULL;
}

/* Free resources. */
/* Update the process status and free resources. */
proc->status |= PROCESS_EXIT;
list_remove (&proc->elem);
file_close (proc->exec_file);
Expand Down Expand Up @@ -406,6 +404,7 @@ load (struct arguments *args, void (**eip) (void), void **esp,
if (!setup_stack (esp))
goto fail;

/* Push arguments on stack. */
push_args_on_stack (args, esp);

/* Start address. */
Expand Down
17 changes: 11 additions & 6 deletions src/userprog/syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

#define pid_t int

/* A Lock for mutual exclusion between system calls.
This lock must be released immediately when a thread is no longer
running a code which must be executed in mutually exclueded state. */
/* A Lock for mutual exclusion between system calls. */
static struct lock sys_lock;

static int get_byte (const uint8_t *uaddr);
Expand Down Expand Up @@ -88,8 +86,7 @@ get_word (const uint32_t *uaddr)
return res;
}

/* Handler which matches appropriate handler to system calls.
Dispatching handlers with arguments they need. */
/* Handler which matches the appropriate system call. */
static void
syscall_handler (struct intr_frame *f UNUSED)
{
Expand Down Expand Up @@ -143,23 +140,31 @@ syscall_handler (struct intr_frame *f UNUSED)
syscall_close ((int) get_word (esp + 1));
break;
default:
/* Undefined system calls. */
thread_exit ();
}
}

/* Terminate pintos. */
/* Terminates pintos. */
static void
syscall_halt (void)
{
power_off ();
NOT_REACHED ();
}

/* Terminates the current user program, returning status
to the kernel. */
void
syscall_exit (int status)
{
/* Set exit code. */
process_current ()->exit_code = status;

/* Print the termination message. */
printf ("%s: exit(%d)\n", thread_current ()->name, status);

/* Exit the current thread. */
thread_exit ();
NOT_REACHED ();
}
Expand Down