Changeset adb49f58 in mainline
- Timestamp:
- 2009-07-06T20:16:15Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 95bc57c
- Parents:
- 0315679
- Location:
- uspace
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/exec.c
r0315679 radb49f58 113 113 { 114 114 task_id_t tid; 115 task_exit_t texit; 115 116 char *tmp; 116 117 int retval; … … 127 128 } 128 129 129 task_wait(tid, &retval); 130 if (retval != 0) 130 task_wait(tid, &texit, &retval); 131 if (texit != TASK_EXIT_NORMAL) { 132 printf("Command failed (unexpectedly terminated).\n"); 133 } else if (retval != 0) { 131 134 printf("Command failed (return value %d).\n", retval); 135 } 132 136 133 137 return 0; -
uspace/app/getvc/getvc.c
r0315679 radb49f58 74 74 int main(int argc, char *argv[]) 75 75 { 76 task_exit_t texit; 76 77 int retval; 77 78 … … 100 101 version_print(argv[1]); 101 102 task_id_t id = spawn(argv[2]); 102 task_wait(id, & retval);103 task_wait(id, &texit, &retval); 103 104 104 105 return 0; -
uspace/lib/libc/generic/task.c
r0315679 radb49f58 149 149 } 150 150 151 int task_wait(task_id_t id, int *retval)151 int task_wait(task_id_t id, task_exit_t *texit, int *retval) 152 152 { 153 ipcarg_t rv;153 ipcarg_t te, rv; 154 154 int rc; 155 155 156 rc = (int) async_req_2_1(PHONE_NS, NS_TASK_WAIT, LOWER32(id), 157 UPPER32(id), &rv); 156 rc = (int) async_req_2_2(PHONE_NS, NS_TASK_WAIT, LOWER32(id), 157 UPPER32(id), &te, &rv); 158 *texit = te; 158 159 *retval = rv; 159 160 -
uspace/lib/libc/include/task.h
r0315679 radb49f58 40 40 typedef uint64_t task_id_t; 41 41 42 typedef enum { 43 TASK_EXIT_NORMAL, 44 TASK_EXIT_UNEXPECTED 45 } task_exit_t; 46 42 47 extern task_id_t task_get_id(void); 43 48 extern int task_set_name(const char *name); 44 49 extern task_id_t task_spawn(const char *path, char *const argv[]); 45 extern int task_wait(task_id_t id, int *retval);50 extern int task_wait(task_id_t id, task_exit_t *texit, int *retval); 46 51 extern int task_retval(int val); 47 52 -
uspace/srv/ns/task.c
r0315679 radb49f58 57 57 typedef struct { 58 58 link_t link; 59 task_id_t id; /**< Task ID. */ 60 int retval; 61 bool destroyed; 59 task_id_t id; /**< Task ID. */ 60 bool finished; /**< Task is done. */ 61 bool have_rval; /**< Task returned a value. */ 62 int retval; /**< The return value. */ 62 63 } hashed_task_t; 63 64 … … 212 213 { 213 214 link_t *cur; 215 task_exit_t texit; 214 216 215 217 loop: … … 227 229 228 230 hashed_task_t *ht = hash_table_get_instance(link, hashed_task_t, link); 229 if (!ht-> destroyed)231 if (!ht->finished) 230 232 continue; 231 233 232 if (!(pr->callid & IPC_CALLID_NOTIFICATION)) 233 ipc_answer_1(pr->callid, EOK, ht->retval); 234 234 if (!(pr->callid & IPC_CALLID_NOTIFICATION)) { 235 texit = ht->have_rval ? TASK_EXIT_NORMAL : 236 TASK_EXIT_UNEXPECTED; 237 ipc_answer_2(pr->callid, EOK, texit, 238 ht->retval); 239 } 240 235 241 hash_table_remove(&task_hash_table, keys, 2); 236 242 list_remove(cur); … … 243 249 { 244 250 ipcarg_t retval; 251 task_exit_t texit; 252 245 253 unsigned long keys[2] = { 246 254 LOWER32(id), … … 258 266 } 259 267 260 if (!ht-> destroyed) {268 if (!ht->finished) { 261 269 /* Add to pending list */ 262 270 pending_wait_t *pr = … … 277 285 278 286 out: 279 if (!(callid & IPC_CALLID_NOTIFICATION)) 280 ipc_answer_1(callid, retval, ht->retval); 287 if (!(callid & IPC_CALLID_NOTIFICATION)) { 288 texit = ht->have_rval ? TASK_EXIT_NORMAL : TASK_EXIT_UNEXPECTED; 289 ipc_answer_2(callid, retval, texit, ht->retval); 290 } 281 291 } 282 292 … … 319 329 link_initialize(&ht->link); 320 330 ht->id = id; 321 ht->destroyed = false; 331 ht->finished = false; 332 ht->have_rval = false; 322 333 ht->retval = -1; 323 334 hash_table_insert(&task_hash_table, keys, &ht->link); … … 343 354 hash_table_get_instance(link, hashed_task_t, link) : NULL; 344 355 345 if ((ht == NULL) || ht-> destroyed)356 if ((ht == NULL) || ht->finished) 346 357 return EINVAL; 347 358 359 ht->finished = true; 360 ht->have_rval = true; 348 361 ht->retval = IPC_GET_ARG1(*call); 349 362 … … 372 385 hashed_task_t *ht = 373 386 hash_table_get_instance(link, hashed_task_t, link); 374 assert(ht != NULL); 375 376 ht->destroyed = true; 387 if (ht == NULL) 388 return EOK; 389 390 ht->finished = true; 377 391 378 392 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.