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

Implement exit() #8

Closed
Lment opened this issue Mar 29, 2017 · 6 comments
Closed

Implement exit() #8

Lment opened this issue Mar 29, 2017 · 6 comments
Assignees
Labels
Milestone

Comments

@Lment
Copy link
Contributor

Lment commented Mar 29, 2017

Implement exit().

exit() should be implemented first, since every user program finished in normal way always call exit. This should terminate current running program and return given status to kernel.
This would need exit-handler to call thread_exit() in threads.c. Since pintos does not support multi-threading, when a thread exits, a process corresponding to that thread should be exited, too. So, thread_exit() should call process_exit(), which is defined in process.c. structure thread defined in threads/thread.h should also be changed, to contain info about exiting.

@Lment Lment added the feature label Mar 29, 2017
@Lment Lment added this to the Project #2 milestone Mar 29, 2017
@Lment Lment changed the title Implement exit() and write() Implement exit() Apr 2, 2017
@Lment
Copy link
Contributor Author

Lment commented Apr 9, 2017

@hangpark Currently working on defining parent-child relation. In thread.h.

#ifdef USERPROG
    /* Owned by userprog/process.c. */
    uint32_t *pagedir;                  /* Page directory. */
    struct file *exec_file;             /* File this thread executing. */
    struct list child_list;             /* Child thread this thread has. */
    struct list open_file_list;         /* File opened by this thread. */
    struct child *identity;             /* Contain info about child and exit. */
#endif

    /* Owned by thread.c. */
    unsigned magic;                     /* Detects stack overflow. */
  };

#ifdef USERPROG
struct child
  {
    tid_t tid;
    int exit_status;
    struct list_elem elem;
  };

struct opened_file
  {
    int fd;
    struct file *file;
    struct list_elem elem;
  };
#endif

@hangpark
Copy link
Owner

hangpark commented Apr 9, 2017

@Lment Basically, I think this is good approach. For little comments,

  • How about make struct process and put it in struct thread as a member named process? Because for init thread, I think it does not have any relation to a specific process, so we have to set NULL to all of process attributes.
  • Rename open_file_list to file_list.
  • What does identity mean? And why is struct child separated from struct thread (or for my suggestion, struct process)?
  • Renaming opened_file to process_file or something else would better.
  • I think tid_t tid should become pid_t pid or something about pid.

@Lment
Copy link
Contributor Author

Lment commented Apr 9, 2017

  • Approved.
  • Approved.
  • Merging with structure thread now.
  • Approved
  • Not needed when merged with structure thread. It already has tid_t tid. Also I heard that in pintos, tid is same as pid. (Because of single thread system, probably.)

@hangpark
Copy link
Owner

hangpark commented Apr 9, 2017

For the last:
No, pid and tid would be different in some implementation. Also, we need to think about our pintos expanded into multi threads system.

If you're correct, then why do you store tid in there? It is already saved in struct thread, isn't it?

Lment added a commit that referenced this issue Apr 9, 2017
@hangpark
Copy link
Owner

The process definition implementation is now moved to #48. This issue should be implemented based on it.

@hangpark hangpark self-assigned this Apr 10, 2017
hangpark added a commit that referenced this issue Apr 10, 2017
hangpark added a commit that referenced this issue Apr 10, 2017
[#8] Implement exit system call
@hangpark
Copy link
Owner

Done by PR #50.

@hangpark hangpark mentioned this issue Apr 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants