Rev 3445 | Rev 3495 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 3445 | Rev 3494 | ||
---|---|---|---|
Line 43... | Line 43... | ||
43 | #include <udebug/udebug_ipc.h> |
43 | #include <udebug/udebug_ipc.h> |
44 | #include <ipc/kbox.h> |
44 | #include <ipc/kbox.h> |
45 | 45 | ||
46 | void ipc_kbox_cleanup(void) |
46 | void ipc_kbox_cleanup(void) |
47 | { |
47 | { |
- | 48 | ipl_t ipl; |
|
48 | bool have_kb_thread; |
49 | bool have_kb_thread; |
49 | 50 | ||
50 | /* Only hold kb_cleanup_lock while setting kb_finished - this is enough */ |
51 | /* Only hold kb_cleanup_lock while setting kb_finished - this is enough */ |
51 | mutex_lock(&TASK->kb_cleanup_lock); |
52 | mutex_lock(&TASK->kb_cleanup_lock); |
52 | TASK->kb_finished = true; |
53 | TASK->kb_finished = true; |
Line 61... | Line 62... | ||
61 | * notify_box causes a HANGUP message to be inserted for each |
62 | * notify_box causes a HANGUP message to be inserted for each |
62 | * disconnected phone. This ensures the kbox thread is going to |
63 | * disconnected phone. This ensures the kbox thread is going to |
63 | * wake up and terminate. |
64 | * wake up and terminate. |
64 | */ |
65 | */ |
65 | ipc_answerbox_slam_phones(&TASK->kernel_box, have_kb_thread); |
66 | ipc_answerbox_slam_phones(&TASK->kernel_box, have_kb_thread); |
- | 67 | ||
- | 68 | /* |
|
- | 69 | * If the task was being debugged, clean up debugging session. |
|
- | 70 | * This is necessarry as slamming the phones won't force |
|
- | 71 | * kbox thread to clean it up since sender != debugger. |
|
- | 72 | */ |
|
- | 73 | ipl = interrupts_disable(); |
|
- | 74 | spinlock_lock(&TASK->lock); |
|
- | 75 | udebug_task_cleanup(TASK); |
|
- | 76 | spinlock_unlock(&TASK->lock); |
|
- | 77 | interrupts_restore(ipl); |
|
66 | 78 | ||
67 | if (have_kb_thread) { |
79 | if (have_kb_thread) { |
68 | LOG("join kb_thread..\n"); |
80 | LOG("join kb_thread..\n"); |
69 | thread_join(TASK->kb_thread); |
81 | thread_join(TASK->kb_thread); |
70 | thread_detach(TASK->kb_thread); |
82 | thread_detach(TASK->kb_thread); |
Line 124... | Line 136... | ||
124 | 136 | ||
125 | ipl = interrupts_disable(); |
137 | ipl = interrupts_disable(); |
126 | spinlock_lock(&TASK->lock); |
138 | spinlock_lock(&TASK->lock); |
127 | spinlock_lock(&TASK->answerbox.lock); |
139 | spinlock_lock(&TASK->answerbox.lock); |
128 | if (list_empty(&TASK->answerbox.connected_phones)) { |
140 | if (list_empty(&TASK->answerbox.connected_phones)) { |
- | 141 | /* |
|
129 | /* Last phone has been disconnected */ |
142 | * Last phone has been disconnected. |
- | 143 | */ |
|
- | 144 | ||
- | 145 | /* Detach thread so it gets freed. */ |
|
- | 146 | thread_detach(TASK->kb_thread); |
|
130 | TASK->kb_thread = NULL; |
147 | TASK->kb_thread = NULL; |
131 | done = true; |
148 | done = true; |
132 | LOG("phone list is empty\n"); |
149 | LOG("phone list is empty\n"); |
133 | } |
150 | } |
134 | spinlock_unlock(&TASK->answerbox.lock); |
151 | spinlock_unlock(&TASK->answerbox.lock); |