From b5f0874cd96ee2a62aabc645b9626c2749cb6a01 Mon Sep 17 00:00:00 2001 From: manuel Date: Mon, 26 Mar 2012 12:54:45 +0200 Subject: initial pintos checkin --- pintos-progos/userprog/process.h | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 pintos-progos/userprog/process.h (limited to 'pintos-progos/userprog/process.h') diff --git a/pintos-progos/userprog/process.h b/pintos-progos/userprog/process.h new file mode 100644 index 0000000..1609801 --- /dev/null +++ b/pintos-progos/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