Separate struct process_result allows a thread's page to be freed while keeping the result available for the parent (if still alive).
This then needs to be freed by either parent or child, whoever dies last (in process_exit).
Implement syscall_exec to make some tests work.
TODO:
process_result.sema and process_result.exit_status are accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts).
I need a sanity check about my "child_results is guaranteed to be in-order" comment please 😅 .
There's a deadlock in at leastexec-multiple.
Changes:
- Separate `struct process_result` allows a thread's page to be freed while keeping the result available for the parent (if still alive).
- This then needs to be freed by either parent or child, whoever dies last (in `process_exit`).
- Implement `syscall_exec` to make some tests work.
TODO:
- [x] `process_result.sema` and `process_result.exit_status` are accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts).
- [x] I need a sanity check about my "child_results is guaranteed to be in-order" comment please :sweat_smile: .
- [x] There's a deadlock in _at least_ `exec-multiple`.
added 1 commit
<ul><li>6ed1ccd2 - Fix process_result locking by acquiring in process_wait as well to prevent freeing memory too early</li></ul>
[Compare with previous version](/lab2425_autumn/pintos_22/-/merge_requests/31/diffs?diff_id=137979&start_sha=84fe637c7e284dd8dab7e2a7ce036857900e1926)
marked the checklist item process_result.sema and process_result.exit_status are accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts). as completed
marked the checklist item **`process_result.sema` and `process_result.exit_status` are accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts).** as completed
Okay so I've managed to get locks almost to work. Turns out I just needed them in process_wait to make sure I don't free memory too early.
However, I am now getting a deadlock in one of the tests (exec-multiple). I suspect this might have something to do with priority donation not working 100% properly, but still need to debug further.
Okay so I've managed to get locks almost to work. Turns out I just needed them in `process_wait` to make sure I don't free memory too early.
However, I am now getting a deadlock in one of the tests (exec-multiple). I suspect this might have something to do with priority donation not working 100% properly, but still need to debug further.
added 1 commit
<ul><li>7778e05a - Fix deadlock by release of lock and semaphore in the wrong order</li></ul>
[Compare with previous version](/lab2425_autumn/pintos_22/-/merge_requests/31/diffs?diff_id=138169&start_sha=6ed1ccd21ea012ffb37d8c8d47e87b5f90979fc8)
I haven't quite figured out exactly why this is a problem, but turns out releasing the lock AFTER sema_up in one of the if branches was problamatic, so I switched the order.
I haven't quite figured out exactly why this is a problem, but turns out releasing the lock AFTER `sema_up` in one of the `if` branches was problamatic, so I switched the order.
added 1 commit
<ul><li>18c88423 - Fix race-condition in process result (memory leak), fix infinite loop in donors_list</li></ul>
[Compare with previous version](/lab2425_autumn/pintos_22/-/merge_requests/31/diffs?diff_id=138519&start_sha=7778e05aa42e7fa8c6f0e2aee1924f3c2df64ec8)
Deleted previous comment because it was completely wrong.
So the "working" implementation had a race-condition where if a parent thread dies after the child releases its result lock, but BEFORE it calls sema_up, then neither thread will free the result, resulting in a memory leak.
So revert back to the previous implementation which had a "deadlock". Turns out it wasn't a deadlock, but an infinite loop in the donors_list caused by a bug in the priority donation implementation that resulted in threads being part of their own donors_list.
Deleted previous comment because it was completely wrong.
So the "working" implementation had a race-condition where if a parent thread dies after the child releases its result lock, but BEFORE it calls `sema_up`, then neither thread will free the result, resulting in a memory leak.
So revert back to the previous implementation which had a "deadlock". Turns out it wasn't a deadlock, but an infinite loop in the `donors_list` caused by a bug in the priority donation implementation that resulted in threads being part of their own `donors_list`.
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Changes:
struct process_resultallows a thread's page to be freed while keeping the result available for the parent (if still alive).process_exit).syscall_execto make some tests work.TODO:
process_result.semaandprocess_result.exit_statusare accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts).exec-multiple.requested review from @td1223
changed the description
added 1 commit
6ed1ccd2- Fix process_result locking by acquiring in process_wait as well to prevent freeing memory too earlyCompare with previous version
marked the checklist item
process_result.semaandprocess_result.exit_statusare accessed by potentially multiple threads. We need to synchronise this; however, I don't think locks nor semaphores would work for this due to being too high-level. Lmk any ideas (other than disabling interrupts). as completedOkay so I've managed to get locks almost to work. Turns out I just needed them in
process_waitto make sure I don't free memory too early.However, I am now getting a deadlock in one of the tests (exec-multiple). I suspect this might have something to do with priority donation not working 100% properly, but still need to debug further.
changed the description
Feel free to revert back to the first few commits of master and try it out. I can't see any deadlock scenario but it is possible.
I’ll give it ago with latest master when I get home, but notice the timeout in the exec-multiple test.
added 1 commit
7778e05a- Fix deadlock by release of lock and semaphore in the wrong orderCompare with previous version
marked the checklist item There's a deadlock in at least
exec-multiple. as completedI haven't quite figured out exactly why this is a problem, but turns out releasing the lock AFTER
sema_upin one of theifbranches was problamatic, so I switched the order.resolved all threads
marked this merge request as ready
added 1 commit
18c88423- Fix race-condition in process result (memory leak), fix infinite loop in donors_listCompare with previous version
Deleted previous comment because it was completely wrong.
So the "working" implementation had a race-condition where if a parent thread dies after the child releases its result lock, but BEFORE it calls
sema_up, then neither thread will free the result, resulting in a memory leak.So revert back to the previous implementation which had a "deadlock". Turns out it wasn't a deadlock, but an infinite loop in the
donors_listcaused by a bug in the priority donation implementation that resulted in threads being part of their owndonors_list.marked the checklist item I need a sanity check about my "child_results is guaranteed to be in-order" comment please 😅 . as completed