-
Notifications
You must be signed in to change notification settings - Fork 3
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
[#4] Implement argument passing #39
Conversation
7411c0c
to
98648fe
Compare
src/userprog/process.c
Outdated
|
||
#define WORD_SIZE sizeof(uintptr_t) | ||
|
||
struct arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this static
src/userprog/process.c
Outdated
|
||
#define WORD_SIZE sizeof(uintptr_t) | ||
|
||
struct arguments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write a comment.
src/userprog/process.c
Outdated
static void argument_parser(char *str, struct arguments *args); | ||
|
||
static void | ||
argument_parser (char *string_input, struct arguments *argument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this method below start_process()
for consistency.
src/userprog/process.c
Outdated
static void argument_parser(char *str, struct arguments *args); | ||
|
||
static void | ||
argument_parser (char *string_input, struct arguments *argument) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write a comment.
src/userprog/process.c
Outdated
|
||
process_name = strtok_r (process_name, " ", &leftover); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use argument_parse()
here. Duplicated.
src/userprog/process.c
Outdated
{ | ||
arg_length = strlen (args->argv[i]) + 1; | ||
dest = top - arg_length; | ||
memcpy ((void *) dest, (void *) (args->argv[i]), arg_length); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(void *)
is now useless.
src/userprog/process.c
Outdated
for(i = 0; i < alignment ; i++) | ||
{ | ||
memcpy ((top - 1), &zero, 1); | ||
top--; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
memcpy (--top, &zero, 1);
src/userprog/process.c
Outdated
} | ||
|
||
memcpy ((top - WORD_SIZE), &zero, WORD_SIZE); | ||
top -= WORD_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch above two statements.
src/userprog/process.c
Outdated
for(i = (args->argc -1); i >= 0; i--) | ||
{ | ||
memcpy ((top - WORD_SIZE), &argument_pointers[i], WORD_SIZE); | ||
top -= WORD_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch above two statements.
src/userprog/process.c
Outdated
top -= WORD_SIZE; | ||
|
||
memcpy ((top - WORD_SIZE), &zero, WORD_SIZE); | ||
top -= WORD_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch two statements in each of 3 groups above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add full commit message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add little comment in
src/userprog/process.c
Outdated
@@ -464,3 +513,55 @@ install_page (void *upage, void *kpage, bool writable) | |||
return (pagedir_get_page (t->pagedir, upage) == NULL | |||
&& pagedir_set_page (t->pagedir, upage, kpage, writable)); | |||
} | |||
|
|||
static void | |||
push_arg_on_stack(struct arguments *args, void **esp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename push_args_to_stack
and rename all occurrence of argument
and arg
above to args
appropriately.
src/userprog/process.c
Outdated
int i; | ||
char *dest; | ||
|
||
for(i = (args->argc - 1); i >= 0; i--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Write little comment with //
to specify which data is going to be pushed.
6823c80
to
346cfa7
Compare
src/userprog/process.c
Outdated
static bool load (const char *cmdline, void (**eip) (void), void **esp); | ||
static bool load (struct arguments *argument, void (**eip) (void), void **esp); | ||
|
||
static void argument_parser(char *str, struct arguments *args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this prototype above start_process
.
src/userprog/process.c
Outdated
@@ -29,6 +41,7 @@ tid_t | |||
process_execute (const char *file_name) | |||
{ | |||
char *fn_copy; | |||
struct arguments *args = malloc (sizeof *args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change right-hand side to (struct arguments *) malloc (sizeof struct arguments)
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I referenced here. Also, this doesn't work. Casting is o.k, but in sizeof
, this code invokes syntax error before struct
.
src/userprog/process.c
Outdated
@@ -38,34 +51,66 @@ process_execute (const char *file_name) | |||
return TID_ERROR; | |||
strlcpy (fn_copy, file_name, PGSIZE); | |||
|
|||
argument_parser (fn_copy, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to give a short comment above this statement. How do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a comment.
src/userprog/process.c
Outdated
if (tid == TID_ERROR) | ||
palloc_free_page (fn_copy); | ||
{ | ||
palloc_free_page (fn_copy); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be freed after below two frees.
src/userprog/process.c
Outdated
return tid; | ||
} | ||
|
||
/* Starts string tokenizer, which cuts given input string into tokens |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need to explain which library function did you use. Writing about what does this method do is better.
ex) Parse a given command line in string to strings of each argument by replacing every spaces to the null character. And then store them in the arguments structure.
src/userprog/process.c
Outdated
static void | ||
push_args_on_stack(struct arguments *args, void **esp) | ||
{ | ||
void **arg_ptrs = calloc (args->argc, sizeof(uintptr_t)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use
void **arg_ptrs = (void **) calloc (args->argc, sizeof void *);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Invokes syntax error before void
, when following this problem.
src/userprog/process.c
Outdated
|
||
alignment = ((uint32_t) curr) % WORD_SIZE; | ||
|
||
/* Aligning, and push bytes required for aligning. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should move above alignment
initialization.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use push, save. Not pushing, saving.
src/userprog/process.c
Outdated
int i; | ||
void *dest; | ||
|
||
/* Pushing arguments on stack, saving their address in arg_ptrs. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use push, save. Not pushing, saving.
src/userprog/process.c
Outdated
for(i = 0; i < alignment ; i++) | ||
memcpy (--curr, &zero, 1); | ||
|
||
curr -= WORD_SIZE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? missing comment.
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &zero, WORD_SIZE); | ||
|
||
for(i = (args->argc -1); i >= 0; i--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? missing comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why indent is tab?
src/userprog/process.c
Outdated
|
||
/* esp pointing bottom of the stack */ | ||
*esp = (void *) curr; | ||
hex_dump((uintptr_t)(PHYS_BASE - 200), (void **) (PHYS_BASE - 200), 250, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Plz......
src/userprog/process.c
Outdated
return tid; | ||
} | ||
|
||
/* Parse arguments from given string, which removes whole adjacent spaces and replace it | ||
with NULL. And then stores it in given argument struct by pointer. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not NULL
. '\0'
or null character
.
src/userprog/process.c
Outdated
|
||
for (curr = strtok_r (str_input, delim, &leftover); | ||
curr != NULL; curr = strtok_r (NULL, delim, &leftover)) | ||
args->argv[args->argc ++] = curr; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove space
src/userprog/process.c
Outdated
delim = " "; | ||
|
||
for (curr = strtok_r (str_input, delim, &leftover); | ||
curr != NULL; curr = strtok_r (NULL, delim, &leftover)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does first line > 80? If not, move curr != NULL
above.
src/userprog/process.c
Outdated
args->argc = 0; | ||
args->argv = (char **) calloc ((strlen (str_input) + 1), sizeof (char)); | ||
|
||
delim = " "; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just use in strtok_r
src/userprog/process.c
Outdated
struct intr_frame if_; | ||
bool success; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;;
src/userprog/process.c
Outdated
/* Push arguments on newly initialized stack, following calling conventions. | ||
This invention does not use esp dynamically, just making it point bottom of | ||
stack frame after all push is done.*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
;;
src/userprog/process.c
Outdated
push_args_on_stack(struct arguments *args, void **esp) | ||
{ | ||
void **arg_ptrs = (void **) calloc (args->argc, sizeof (void *)); | ||
void *curr = (char *) PHYS_BASE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use esp
, not PHYS_BASE
.
src/userprog/process.c
Outdated
void *dest; | ||
|
||
/* Push arguments on stack, save their address in arg_ptrs. */ | ||
for(i = (args->argc - 1); i >= 0; i--) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Space after for
, remove parenthesis wrapping args->argc - 1
.
src/userprog/process.c
Outdated
{ | ||
arg_len = strlen (args->argv[i]) + 1; | ||
dest = curr - arg_len; | ||
memcpy (dest, (args->argv[i]), arg_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove parenthesis
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're using curr -= WORD_SIZE
and --curr
both. Use just one. I prefer second one. And then you might not need WORD_SIZE
.
src/userprog/process.c
Outdated
int argc; | ||
char **argv; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No blank line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault
src/userprog/process.c
Outdated
static bool load (const char *cmdline, void (**eip) (void), void **esp); | ||
static bool load (struct arguments *args, void (**eip) (void), void **esp); | ||
|
||
static void argument_parser(char *str, struct arguments *args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented that this method should be above start_process
but this has not been fixed yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method is now part of process_execute()
, and not called in start_process()
. And, in load()
, all of its helper function prototypes are defined just above its declaration. So I placed this prototype here, just above process_execute()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll follow you. then, plz remove gap between load()
and argument_parser()
.
src/userprog/process.c
Outdated
@@ -29,6 +43,7 @@ tid_t | |||
process_execute (const char *file_name) | |||
{ | |||
char *fn_copy; | |||
struct arguments *args = (struct arguments *) malloc (sizeof *args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw your reply now. Please tag me with # symbol for outdated comment 😃
But still, then does sizeof (struct arguments)
invoke an error? If not, I'd like to recommend you to use this instead of getting size from variable args
by sizeof *args
. What do you think about it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also tried it, wondering why sizeof
cannot calculate a size of structure pointers, but it still invoked an error, with same message. Following this now, since I can't figure out how I could get size of structure pointer without this syntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is your error appearing during building?
struct arguments *args = (struct arguments *) malloc (sizeof (struct arguments));
This works very well in my env. Please let me know your error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to be problem with this. Since this problem was solved, the above solution now works. Changing it as suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
Be careful limit length of line (80)!!!!
src/userprog/process.c
Outdated
@@ -38,19 +53,43 @@ process_execute (const char *file_name) | |||
return TID_ERROR; | |||
strlcpy (fn_copy, file_name, PGSIZE); | |||
|
|||
/* Parse argument, save it in structure. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about Parse arguments into the structure
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
okay..
src/userprog/process.c
Outdated
free(args); | ||
palloc_free_page (fn_copy); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault.
src/userprog/process.c
Outdated
char *curr; | ||
|
||
args->argc = 0; | ||
args->argv = (char **) calloc ((strlen (str_input) + 1), sizeof (char)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you fix this code as I requested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
char *
is changed to char
. Previously it was char *
. It is a minimum memory for argv
, I suppose.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean parenthesis.
src/userprog/process.c
Outdated
args->argv = (char **) calloc ((strlen (str_input) + 1), sizeof (char)); | ||
|
||
for (curr = strtok_r (str_input, " ", &leftover); | ||
curr != NULL; curr = strtok_r (NULL, " ", &leftover)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why didn't you fix this code as I requested? Please always write the reply why you disagree my request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is about 113 or more characters which is longer than 80, so it should be divided.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean CHANGE
for (curr = strtok_r (str_input, " ", &leftover);
curr != NULL; curr = strtok_r (NULL, " ", &leftover))
TO
for (curr = strtok_r (str_input, " ", &leftover); curr != NULL;
curr = strtok_r (NULL, " ", &leftover))
NOT
for (curr = strtok_r (str_input, " ", &leftover); curr != NULL; curr = strtok_r (NULL, " ", &leftover))
src/userprog/process.c
Outdated
push_args_on_stack(struct arguments *args, void **esp) | ||
{ | ||
void **arg_ptrs = (void **) calloc (args->argc, sizeof (void *)); | ||
void *curr = (char *) *esp; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why (char *)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault.
src/userprog/process.c
Outdated
alignment = ((uint32_t) curr) % WORD_SIZE; | ||
for(i = 0; i < alignment ; i++) | ||
{ | ||
curr -= 1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that was my mistake. Sorry. Please combine these two into memcpy (--curr, ~~~~~)
.
src/userprog/process.c
Outdated
@@ -17,9 +17,23 @@ | |||
#include "threads/palloc.h" | |||
#include "threads/thread.h" | |||
#include "threads/vaddr.h" | |||
#include "threads/malloc.h" | |||
|
|||
#define WORD_SIZE sizeof(uintptr_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof uintptr_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sizeof uintptr_t
invokes syntax error when referencing WORD_SIZE
. Similarly, sizeof char
too. It seems it needs parenthesis to count something's size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, why no spacing? 😠
src/userprog/process.c
Outdated
|
||
#define WORD_SIZE sizeof(uintptr_t) | ||
|
||
/* Structure for argument, which saves arguments in argv, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It does not count the number of args. Just saves it.
Structure for arguments. would be enough I think. And add right comment (//) for each member like in threads/thread.h
68b28f7
to
04e5c67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update your local branch to the origin.
9d13291
to
415d37b
Compare
src/userprog/process.c
Outdated
struct arguments | ||
{ | ||
int argc; /* Argument counter which saves calculated number of arguments. */ | ||
char **argv; /* Argument vector, which saves arguments in array of strings. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does these two lines fit in 80 letters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified.
src/userprog/process.c
Outdated
#define WORD_SIZE sizeof (uintptr_t) | ||
|
||
/* Structure for arguments, which saves arguments in argv, | ||
and saves the number of arguments. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does not need which saves ~~~ of arguments
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified.
src/userprog/process.c
Outdated
and saves the number of arguments. */ | ||
struct arguments | ||
{ | ||
int argc; /* Argument counter which saves calculated number of arguments. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Number of arguments.
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified.
src/userprog/process.c
Outdated
struct arguments | ||
{ | ||
int argc; /* Argument counter which saves calculated number of arguments. */ | ||
char **argv; /* Argument vector, which saves arguments in array of strings. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Array of arguments.
is enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified.
src/userprog/process.c
Outdated
@@ -29,6 +41,7 @@ tid_t | |||
process_execute (const char *file_name) | |||
{ | |||
char *fn_copy; | |||
struct arguments *args = (struct arguments *) malloc (sizeof (struct arguments)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this line fit in 80 letters?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@hangpark this line has 84 characters, So it should be divided.
In my opinion :
struct arguments *args =
(struct arguments *) malloc (sizeof (struct arguments));
struct arguments *args = (struct arguments *)
malloc (sizeof (struct arguments));
struct arguments *args = (struct arguments *) malloc
(sizeof (struct arguments));
could be used to follow convention. What would you suggest? I think third one is most appropriate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just separate declaration and initialization.
src/userprog/process.c
Outdated
@@ -38,19 +51,42 @@ process_execute (const char *file_name) | |||
return TID_ERROR; | |||
strlcpy (fn_copy, file_name, PGSIZE); | |||
|
|||
/* Parse argument into the structure. */ | |||
argument_parser (fn_copy, args); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move initialization to here, between comment and caller.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Almost done....!! 😆
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &arg_ptrs[i], WORD_SIZE); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removing this line would be better 😃
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &zero, WORD_SIZE); | ||
|
||
/* esp pointing bottom of the stack */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add comma at the last and change esp
to ESP
.
src/userprog/process.c
Outdated
|
||
/* Push arguments on newly initialized stack, following calling conventions. | ||
This invention does not use esp dynamically, just making it point bottom of | ||
stack frame after all push is done.*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Second and third line are not aligned vertically with the first line.
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &zero, WORD_SIZE); | ||
|
||
/* Esp pointing bottom of the stack */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why din't you fix all my requests?
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &zero, WORD_SIZE); | ||
|
||
/* esp pointing bottom of the stack. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code were
esp pointing bottom of the stack no comma
and I want
ESP pointing bottom of the stack .
But you changed yours to
Esp pointing bottom of the stack no comma
and I asked once again, you gave
esp pointing bottom of the stack .
without any reason.
What's the reason? If there is no reason, what's the problem with you?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My fault. I misunderstood the comment.
src/userprog/process.c
Outdated
curr -= WORD_SIZE; | ||
memcpy (curr, &zero, WORD_SIZE); | ||
|
||
/* Esp pointing bottom of the stack. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your code were
esp pointing bottom of the stack no comma
and I want
ESP pointing bottom of the stack .
But you changed yours to
Esp pointing bottom of the stack no comma
and I asked once again, you gave
esp pointing bottom of the stack .
Finally, you still don't accept my request.
Esp pointing bottom of the stack .
Compare my suggestion and yours:
ESP pointing bottom of the stack .
Esp pointing bottom of the stack .
Is this too hard to understand?
Now an execution of process supports multiple arguments, by pushing arguments onto stack that has been previously allocated, but not used. esp now points bottom of the stack frame, which is extended from PHYS_BASE to accommodate arguments and pointers to that arguments. This implementation is now following calling convention, which is defined in pintos manual.
Merged branch [#38] in local, which fixed unintended argument manipulation.
Using
pintos -v -k -T 60 --bochs --fs-disk=2 -p ../../examples/echo -a echo -- -q -f run 'echo xxx'
andhex_dump()
, current implementation is working well withargc = 2
, and since implementation is based on make argument passing whenargc = n
, I expect this works well with another user programs.Use
hex_dump((uintptr_t)(PHYS_BASE - 200), (void **) (PHYS_BASE - 200), 250, true);
in bottom ofpush_arg_on_stack()
.