Merge branch 'process-wait' into 'userprog-merge'
Fix race-condition in process result (memory leak), fix infinite loop in donors_list See merge request lab2425_autumn/pintos_22!33
This commit is contained in:
@@ -170,6 +170,9 @@ list_insert (struct list_elem *before, struct list_elem *elem)
|
|||||||
{
|
{
|
||||||
ASSERT (is_interior (before) || is_tail (before));
|
ASSERT (is_interior (before) || is_tail (before));
|
||||||
ASSERT (elem != NULL);
|
ASSERT (elem != NULL);
|
||||||
|
// Sanity checks to prevent (some) loop lists
|
||||||
|
ASSERT (before != elem);
|
||||||
|
ASSERT (before->prev != elem);
|
||||||
|
|
||||||
elem->prev = before->prev;
|
elem->prev = before->prev;
|
||||||
elem->next = before;
|
elem->next = before;
|
||||||
|
|||||||
@@ -341,6 +341,7 @@ lock_release (struct lock *lock)
|
|||||||
released, transfer the remaining orphaned donors to its donor list. */
|
released, transfer the remaining orphaned donors to its donor list. */
|
||||||
if (max_donor != NULL)
|
if (max_donor != NULL)
|
||||||
{
|
{
|
||||||
|
list_remove (&max_donor->donor_elem);
|
||||||
while (!list_empty (&orphan_list))
|
while (!list_empty (&orphan_list))
|
||||||
list_push_back (&max_donor->donors_list, list_pop_front (&orphan_list));
|
list_push_back (&max_donor->donors_list, list_pop_front (&orphan_list));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -326,11 +326,12 @@ process_exit (void)
|
|||||||
struct process_result *, and may be waiting so call sema_up */
|
struct process_result *, and may be waiting so call sema_up */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lock_release (&cur->result->lock);
|
|
||||||
sema_up (&cur->result->sema);
|
sema_up (&cur->result->sema);
|
||||||
|
lock_release (&cur->result->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Free child process results or signal parent's death. */
|
||||||
struct list_elem *e;
|
struct list_elem *e;
|
||||||
for (e = list_begin (&cur->child_results);
|
for (e = list_begin (&cur->child_results);
|
||||||
e != list_end (&cur->child_results); e = list_next (e))
|
e != list_end (&cur->child_results); e = list_next (e))
|
||||||
@@ -347,8 +348,8 @@ process_exit (void)
|
|||||||
/* Child is still alive, signal via sema that parent has died. */
|
/* Child is still alive, signal via sema that parent has died. */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
lock_release (&result->lock);
|
|
||||||
sema_up (&result->sema);
|
sema_up (&result->sema);
|
||||||
|
lock_release (&result->lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user