1.1 --- a/libexec/lib/src/external_pager.cc Thu Mar 23 15:42:39 2023 +0100
1.2 +++ b/libexec/lib/src/external_pager.cc Fri Mar 24 00:46:26 2023 +0100
1.3 @@ -43,7 +43,7 @@
1.4 /* A simple system pager also acting as a region mapper. */
1.5
1.6 ExternalPager::ExternalPager(address_t start, address_t end)
1.7 -: ExecPager(start, end), NotificationSupport()
1.8 +: ExecPager(start, end)
1.9 {
1.10 }
1.11
1.12 @@ -94,30 +94,15 @@
1.13 for (itc = _dataspaces.begin(); itc != _dataspaces.end(); itc++)
1.14 ipc_cap_free_um(*itc);
1.15
1.16 - /* Remove the created task. */
1.17 + /* Notify the monitor. */
1.18
1.19 - if (l4_is_valid_cap(_task))
1.20 - {
1.21 - ipc_unmap_capability(_task, _mapped_task);
1.22 - ipc_cap_free_um(_task);
1.23 - _task = L4_INVALID_CAP;
1.24 - }
1.25 + if (_monitor != NULL)
1.26 + _monitor->pager_ended();
1.27 }
1.28
1.29
1.30
1.31 -/* Manage the task and thread capabilities. */
1.32 -
1.33 -void ExternalPager::add_thread(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap)
1.34 -{
1.35 - _threads.push_back(cap);
1.36 - _mapped_threads.push_back(mapped_cap);
1.37 -}
1.38 -
1.39 -void ExternalPager::set_gate(l4_cap_idx_t cap)
1.40 -{
1.41 - _ipc_gate = cap;
1.42 -}
1.43 +/* Capability management. */
1.44
1.45 void ExternalPager::set_pager(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap)
1.46 {
1.47 @@ -137,6 +122,21 @@
1.48 _mapped_task = mapped_cap;
1.49 }
1.50
1.51 +void ExternalPager::set_thread(l4_cap_idx_t cap, l4_cap_idx_t mapped_cap)
1.52 +{
1.53 + _thread = cap;
1.54 + _mapped_thread = mapped_cap;
1.55 +}
1.56 +
1.57 +
1.58 +
1.59 +/* Lifecycle management. */
1.60 +
1.61 +void ExternalPager::set_monitor(ProcessMonitor *monitor)
1.62 +{
1.63 + _monitor = monitor;
1.64 +}
1.65 +
1.66
1.67
1.68 /* Manage pager resources. */
1.69 @@ -277,41 +277,23 @@
1.70
1.71 long ExternalPager::signal(unsigned long sig, unsigned long val)
1.72 {
1.73 - notify_all(NOTIFY_TASK_SIGNAL, (notify_values_t) {sig, val});
1.74 -
1.75 - /* Handle the termination event. */
1.76 + /* Handle the termination event of the internal pager. */
1.77
1.78 if (sig == 0)
1.79 {
1.80 - printf("Signal from task.\n");
1.81 -
1.82 - /* Once the program exits, the IPC gate connecting the program with its
1.83 - internal pager can be released. */
1.84 + printf("Signal from internal pager.\n");
1.85
1.86 - if (l4_is_valid_cap(_ipc_gate))
1.87 - {
1.88 - ipc_cap_free_um(_ipc_gate);
1.89 - _ipc_gate = L4_INVALID_CAP;
1.90 - }
1.91 -
1.92 - /* Upon exit of the program's internal pager, release the capabilities
1.93 - associated with this server. */
1.94 + /* For some reason, threads cannot be released by the process, so they are
1.95 + also unmapped on its behalf. */
1.96
1.97 - else if (l4_is_valid_cap(_task))
1.98 + if (l4_is_valid_cap(_thread))
1.99 {
1.100 - /* Threads. For some reason, these cannot be released by the process, so
1.101 - they are also unmapped on its behalf. */
1.102 -
1.103 - std::vector<l4_cap_idx_t>::iterator it;
1.104 + ipc_cap_free_um(_thread);
1.105 + ipc_unmap_capability(_task, _mapped_thread);
1.106 + _thread = L4_INVALID_CAP;
1.107
1.108 - for (it = _threads.begin(); it != _threads.end(); it++)
1.109 - ipc_cap_free_um(*it);
1.110 -
1.111 - for (it = _mapped_threads.begin(); it != _mapped_threads.end(); it++)
1.112 - ipc_unmap_capability(_task, *it);
1.113 -
1.114 - /* Parent and pager/region mapper. Freeing these after the threads should
1.115 - avoid warnings about invalid pager capabilities. */
1.116 + /* Parent and pager/region mapper. Freeing the pager after the thread
1.117 + should avoid warnings about invalid pager capabilities. */
1.118
1.119 ipc_unmap_capability(_task, _mapped_parent);
1.120 ipc_unmap_capability(_task, _mapped_pager);
1.121 @@ -321,21 +303,5 @@
1.122 return L4_EOK;
1.123 }
1.124
1.125 -
1.126 -
1.127 -/* Subscribe to notifications. */
1.128 -
1.129 -long ExternalPager::subscribe(l4_cap_idx_t notifier, notify_flags_t flags)
1.130 -{
1.131 - return NotificationSupport::subscribe(notifier, flags);
1.132 -}
1.133 -
1.134 -/* Unsubscribe from notifications. */
1.135 -
1.136 -long ExternalPager::unsubscribe(l4_cap_idx_t notifier)
1.137 -{
1.138 - return NotificationSupport::unsubscribe(notifier);
1.139 -}
1.140 -
1.141 /* vim: tabstop=2 expandtab shiftwidth=2
1.142 */