Changeset f2cb80a in mainline for kernel/generic/src/ipc/kbox.c
- Timestamp:
- 2024-02-23T17:57:23Z (11 months ago)
- Children:
- 192019f
- Parents:
- 86f862c (diff), 90ba06c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- boba-buba <120932204+boba-buba@…> (2024-02-23 17:57:23)
- git-committer:
- GitHub <noreply@…> (2024-02-23 17:57:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/ipc/kbox.c
r86f862c rf2cb80a 90 90 LOG("Join kb.thread."); 91 91 thread_join(TASK->kb.thread); 92 thread_put(TASK->kb.thread);93 92 LOG("...join done."); 94 93 TASK->kb.thread = NULL; … … 201 200 /** Connect phone to a task kernel-box specified by id. 202 201 * 203 * Note that this is not completely atomic. For optimisation reasons, the task204 * might start cleaning up kbox after the phone has been connected and before205 * a kbox thread has been created. This must be taken into account in the206 * cleanup code.207 *208 202 * @param[out] out_phone Phone capability handle on success. 209 203 * @return Error code. … … 212 206 errno_t ipc_connect_kbox(task_id_t taskid, cap_phone_handle_t *out_phone) 213 207 { 214 irq_spinlock_lock(&tasks_lock, true);215 216 208 task_t *task = task_find_by_id(taskid); 217 if (task == NULL) { 218 irq_spinlock_unlock(&tasks_lock, true); 209 if (!task) 219 210 return ENOENT; 220 }221 222 atomic_inc(&task->refcount);223 224 irq_spinlock_unlock(&tasks_lock, true);225 211 226 212 mutex_lock(&task->kb.cleanup_lock); 227 228 if (atomic_predec(&task->refcount) == 0) {229 mutex_unlock(&task->kb.cleanup_lock);230 task_destroy(task);231 return ENOENT;232 }233 213 234 214 if (task->kb.finished) { 235 215 mutex_unlock(&task->kb.cleanup_lock); 216 task_release(task); 236 217 return EINVAL; 237 218 } … … 244 225 if (!kb_thread) { 245 226 mutex_unlock(&task->kb.cleanup_lock); 227 task_release(task); 246 228 return ENOMEM; 247 229 } 248 230 249 task->kb.thread = thread_ref(kb_thread);250 thread_ ready(kb_thread);231 task->kb.thread = kb_thread; 232 thread_start(kb_thread); 251 233 } 252 234 … … 256 238 if (rc != EOK) { 257 239 mutex_unlock(&task->kb.cleanup_lock); 240 task_release(task); 258 241 return rc; 259 242 } … … 266 249 267 250 mutex_unlock(&task->kb.cleanup_lock); 251 task_release(task); 268 252 *out_phone = phone_handle; 269 253 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.