Remove process_result lock since it is an invalid solution
TODO : synchronise process_result in another way
This commit is contained in:
@@ -647,7 +647,6 @@ init_process_result (struct thread *t)
|
|||||||
struct process_result *result = malloc (sizeof (struct process_result));
|
struct process_result *result = malloc (sizeof (struct process_result));
|
||||||
result->tid = t->tid;
|
result->tid = t->tid;
|
||||||
result->exit_status = t->exit_status;
|
result->exit_status = t->exit_status;
|
||||||
lock_init (&result->lock);
|
|
||||||
sema_init (&result->sema, 0);
|
sema_init (&result->sema, 0);
|
||||||
t->result = result;
|
t->result = result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,6 @@ struct process_result
|
|||||||
tid_t tid; /* The tid of the child process. */
|
tid_t tid; /* The tid of the child process. */
|
||||||
int exit_status; /* The exit status of the child process. Initially set to
|
int exit_status; /* The exit status of the child process. Initially set to
|
||||||
-1, then to exit_status when child dies. */
|
-1, then to exit_status when child dies. */
|
||||||
struct lock lock; /* Lock to synchronise access to the status and sema. */
|
|
||||||
struct semaphore sema; /* Semaphore to signal the parent that the exit_status
|
struct semaphore sema; /* Semaphore to signal the parent that the exit_status
|
||||||
has been set. */
|
has been set. */
|
||||||
struct list_elem elem; /* List element for the parent's children list. */
|
struct list_elem elem; /* List element for the parent's children list. */
|
||||||
|
|||||||
@@ -245,21 +245,14 @@ process_exit (void)
|
|||||||
/* Update process result. */
|
/* Update process result. */
|
||||||
if (cur->result != NULL)
|
if (cur->result != NULL)
|
||||||
{
|
{
|
||||||
lock_acquire (&cur->result->lock);
|
|
||||||
cur->result->exit_status = cur->exit_status;
|
cur->result->exit_status = cur->exit_status;
|
||||||
/* Parent has died, child has to free the struct process_result * */
|
/* Parent has died, child has to free the struct process_result * */
|
||||||
if (sema_try_down (&cur->result->sema))
|
if (sema_try_down (&cur->result->sema))
|
||||||
{
|
free (cur->result);
|
||||||
lock_release (&cur->result->lock);
|
|
||||||
free (cur->result);
|
|
||||||
}
|
|
||||||
/* Parent is still alive and will be the one to free the
|
/* Parent is still alive and will be the one to free the
|
||||||
struct process_result *, and may be waiting so call sema_up */
|
struct process_result *, and may be waiting so call sema_up */
|
||||||
else
|
else
|
||||||
{
|
sema_up (&cur->result->sema);
|
||||||
sema_up (&cur->result->sema);
|
|
||||||
lock_release (&cur->result->lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
struct list_elem *e;
|
struct list_elem *e;
|
||||||
@@ -268,19 +261,12 @@ process_exit (void)
|
|||||||
{
|
{
|
||||||
struct process_result *result
|
struct process_result *result
|
||||||
= list_entry (e, struct process_result, elem);
|
= list_entry (e, struct process_result, elem);
|
||||||
lock_acquire (&result->lock);
|
|
||||||
/* Child has died (and was not waited for). Free the result. */
|
/* Child has died (and was not waited for). Free the result. */
|
||||||
if (sema_try_down (&result->sema))
|
if (sema_try_down (&result->sema))
|
||||||
{
|
free (result);
|
||||||
lock_release (&result->lock);
|
|
||||||
free (result);
|
|
||||||
}
|
|
||||||
/* Child is still alive, signal via sema that parent has died. */
|
/* Child is still alive, signal via sema that parent has died. */
|
||||||
else
|
else
|
||||||
{
|
sema_up (&result->sema);
|
||||||
sema_up (&result->sema);
|
|
||||||
lock_release (&result->lock);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Destroy the current process's page directory and switch back
|
/* Destroy the current process's page directory and switch back
|
||||||
|
|||||||
Reference in New Issue
Block a user