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:
Demetriades, Themis
2024-11-11 22:24:39 +00:00
3 changed files with 7 additions and 2 deletions

View File

@@ -170,6 +170,9 @@ list_insert (struct list_elem *before, struct list_elem *elem)
{
ASSERT (is_interior (before) || is_tail (before));
ASSERT (elem != NULL);
// Sanity checks to prevent (some) loop lists
ASSERT (before != elem);
ASSERT (before->prev != elem);
elem->prev = before->prev;
elem->next = before;

View File

@@ -341,6 +341,7 @@ lock_release (struct lock *lock)
released, transfer the remaining orphaned donors to its donor list. */
if (max_donor != NULL)
{
list_remove (&max_donor->donor_elem);
while (!list_empty (&orphan_list))
list_push_back (&max_donor->donors_list, list_pop_front (&orphan_list));
}

View File

@@ -326,11 +326,12 @@ process_exit (void)
struct process_result *, and may be waiting so call sema_up */
else
{
lock_release (&cur->result->lock);
sema_up (&cur->result->sema);
lock_release (&cur->result->lock);
}
}
/* Free child process results or signal parent's death. */
struct list_elem *e;
for (e = list_begin (&cur->child_results);
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. */
else
{
lock_release (&result->lock);
sema_up (&result->sema);
lock_release (&result->lock);
}
}