thread_exit (void)
{
+ struct thread *t = thread_current ();
-+ list_elem *e, *next;
++ struct list_elem *e, *next;
+
ASSERT (!intr_context ());
+thread_join (tid_t child_tid)
+{
+ struct thread *cur = thread_current ();
-+ list_elem *e;
++ struct list_elem *e;
+
+ for (e = list_begin (&cur->children); e != list_end (&cur->children); )
+ {
+ struct latch ready_to_die; /* Release when thread about to die. */
+ struct semaphore can_die; /* Up when thread allowed to die. */
+ struct list children; /* List of child threads. */
-+ list_elem children_elem; /* Element of `children' list. */
++ struct list_elem children_elem; /* Element of `children' list. */
+ int ret_code; /* Return status. */
+
/* Shared between thread.c and synch.c. */
- list_elem elem; /* List element. */
+ struct list_elem elem; /* List element. */
#ifdef USERPROG
/* Owned by userprog/process.c. */
bool user; /* True: access by user, false: access by kernel. */
void *fault_addr; /* Fault address. */
+ struct user_page tmp_up, *up;
-+ hash_elem *e;
++ struct hash_elem *e;
/* Obtain faulting address, the virtual address that was
accessed to cause the fault. It may point to code or to
}
}
-@@ -182,7 +189,10 @@ struct Elf32_Phdr
+@@ -182,7 +189,11 @@ struct Elf32_Phdr
#define PF_R 4 /* Readable. */
static bool load_segment (struct file *, const struct Elf32_Phdr *);
-static bool setup_stack (void **esp);
+static bool setup_stack (const char *cmdline, void **esp);
-+static unsigned user_page_hash (const hash_elem *, void *);
-+static bool user_page_less (const hash_elem *, const hash_elem *, void *);
++static unsigned user_page_hash (const struct hash_elem *, void *);
++static bool user_page_less (const struct hash_elem *, const struct hash_elem *,
++ void *);
+static struct user_page *make_user_page (void *upage);
/* Aborts loading an executable, with an error message. */
/* Is this a read-only segment? Not currently used, so it's
commented out. You'll want to use it when implementing VM
-@@ -340,70 +380,206 @@ load_segment (struct file *file, const s
+@@ -340,70 +380,207 @@ load_segment (struct file *file, const s
/* Load the segment page-by-page into memory. */
filesz_left = phdr->p_filesz + (phdr->p_vaddr & PGMASK);
+}
+
+static unsigned
-+user_page_hash (const hash_elem *e, void *aux UNUSED)
++user_page_hash (const struct hash_elem *e, void *aux UNUSED)
+{
+ struct user_page *up = hash_entry (e, struct user_page, elem);
+ return hash_bytes (&up->upage, sizeof up->upage);
- kpage = palloc_get_page (PAL_USER | PAL_ZERO);
- if (kpage != NULL)
+static bool
-+user_page_less (const hash_elem *a_, const hash_elem *b_, void *aux UNUSED)
++user_page_less (const struct hash_elem *a_,
++ const struct hash_elem *b_, void *aux UNUSED)
+{
+ struct user_page *a = hash_entry (a_, struct user_page, elem);
+ struct user_page *b = hash_entry (b_, struct user_page, elem);
+
+struct user_page
+ {
-+ hash_elem elem;
++ struct hash_elem elem;
+ void *upage; /* Virtual address of mapping. */
+
+ /* If FRAME is nonnull, the page is in memory.
+
+struct fildes
+ {
-+ list_elem elem;
++ struct list_elem elem;
+ struct file *file;
+ int handle;
+ };
+lookup_fd (int handle)
+{
+ struct thread *cur = thread_current ();
-+ list_elem *e;
++ struct list_elem *e;
+
+ for (e = list_begin (&cur->fds); e != list_end (&cur->fds);
+ e = list_next (e))
+syscall_exit (void)
+{
+ struct thread *cur = thread_current ();
-+ list_elem *e, *next;
++ struct list_elem *e, *next;
+
+ for (e = list_begin (&cur->fds); e != list_end (&cur->fds); e = next)
+ {