Permalink
Browse files

57

  • Loading branch information...
1 parent 7129cb8 commit 33196f396e2892feaf0fbb80dfeb0ae0e570371d @grantborthwick committed Oct 31, 2012
Showing with 14 additions and 5 deletions.
  1. +4 −1 src/threads/thread.c
  2. +7 −4 src/userprog/process.c
  3. +3 −0 src/userprog/syscall.c
View
5 src/threads/thread.c
@@ -290,7 +290,10 @@ void
thread_exit (void)
{
ASSERT (!intr_context ());
- //sema_up(&thread_current ()->wait_status->dead); //Do this for make check if not everything implemented.
+ if (!sema_try_down(&thread_current ()->wait_status->dead)){
+ printf("Error! (%s) has not been given permission to die.\n",thread_current ()->name);
+ }
+ sema_up(&thread_current ()->wait_status->dead); //Do this for make check if not everything implemented.
#ifdef USERPROG
process_exit ();
#endif
View
11 src/userprog/process.c
@@ -157,6 +157,7 @@ process_wait (tid_t child_tid)
void
process_exit (void)
{
+ //printf(" "); Having this line causes exit code to print??? Not having it does not.
struct thread *cur = thread_current ();
struct list_elem *e, *next;
uint32_t *pd;
@@ -167,14 +168,16 @@ process_exit (void)
/* Notify parent that we're dead. */
if (cur->wait_status != NULL)
{
- struct wait_status *cs = cur->wait_status;
-
/* add code */
- printf ("%s: exit(0)\n", cur->name); // HACK all successful ;-)
+ struct wait_status *cs = cur->wait_status;
+ sema_up(&cur->wait_status->dead);
+ printf ("%s: exit(%d)\n", cur->name,cur->wait_status->exit_code); // HACK all successful ;-)
release_child (cs);
}
-
+ //else{printf("something bad..\n");}// Put this in to check. REMOVE
+ // Maybe if null make wait_status?
+
/* Free entries of children list. */
for (e = list_begin (&cur->children); e != list_end (&cur->children);
e = next)
View
3 src/userprog/syscall.c
@@ -211,6 +211,7 @@ static int
sys_create (const char *ufile, unsigned initial_size)
{
bool sucess = false;
+ if(ufile==NULL){return(-1);}//This presently does not work...
char *kfile = copy_in_string(ufile);
lock_acquire (&fs_lock);
if (kfile != NULL)
@@ -249,7 +250,9 @@ struct file_descriptor
static int
sys_open (const char *ufile)
{
+ if(ufile==NULL){return -1;}
char *kfile = copy_in_string (ufile);
+ //if(kfile==NULL){return -1;}
struct file_descriptor *fd;
int handle = -1;

0 comments on commit 33196f3

Please sign in to comment.