From 4f670845ff9ab6c48bcb5f7bf4d4ef6dc3c3064b Mon Sep 17 00:00:00 2001 From: manuel Date: Tue, 27 Mar 2012 11:51:08 +0200 Subject: reorganize file structure to match the upstream requirements --- userprog/process.h | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 userprog/process.h (limited to 'userprog/process.h') diff --git a/userprog/process.h b/userprog/process.h new file mode 100644 index 0000000..1609801 --- /dev/null +++ b/userprog/process.h @@ -0,0 +1,47 @@ +#ifndef USERPROG_PROCESS_H +#define USERPROG_PROCESS_H + +#include "threads/thread.h" + +/* In the current implementation, the capacity is fixed to 1024 (PGSIZE/4) */ +struct fd_table { + struct file** fds; + int fd_free; /* lowest-index free FD table entry */ + int fd_max; /* highest-index used FD table entry */ + int fd_cap; /* FD table capacity */ +}; + +struct process { + /* process tree */ + tid_t thread_id; + tid_t parent_tid; + struct list_elem parentelem; /* Owned by parent */ + + /* communication with parent process */ + struct semaphore exit_sem; + struct lock exit_lock; + int exit_status; + + /* files */ + struct file *executable; /* Loaded executable, if any. */ + struct fd_table fd_table; /* File descriptor table */ + + /* Owned by syscall.c */ + void* syscall_buffer; + size_t syscall_buffer_page_cnt; +}; + +void process_init (void); +struct process* process_current (void); +tid_t process_execute (const char *file_name); +int process_wait (tid_t); +void process_exit (void); +void process_activate (void); + +int process_open_file(const char* fname); +struct file* process_get_file(int fd); +void process_lock_filesys (void); +void process_unlock_filesys (void); +bool process_close_file(int fd); + +#endif /* userprog/process.h */ -- cgit v1.2.3