Changeset 40abf56 in mainline for uspace/lib/c/generic/thread.c
- Timestamp:
- 2018-07-18T19:42:28Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9bde0d5
- Parents:
- 0b05082
- git-author:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 19:05:08)
- git-committer:
- Jiří Zárevúcky <jiri.zarevucky@…> (2018-07-18 19:42:28)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/thread.c
r0b05082 r40abf56 58 58 void __thread_main(uspace_arg_t *uarg) 59 59 { 60 fibril_t *fibril = fibril_setup(); 61 if (fibril == NULL) 62 thread_exit(0); 60 assert(!__tcb_is_set()); 61 62 fibril_t *fibril = uarg->uspace_thread_arg; 63 assert(fibril); 63 64 64 65 __tcb_set(fibril->tcb); 65 66 66 uarg->uspace_thread_function( uarg->uspace_thread_arg);67 uarg->uspace_thread_function(fibril->arg); 67 68 /* 68 69 * XXX: we cannot free the userspace stack while running on it … … 95 96 thread_id_t *tid) 96 97 { 97 uspace_arg_t *uarg = 98 (uspace_arg_t *) malloc(sizeof(uspace_arg_t)); 98 uspace_arg_t *uarg = calloc(1, sizeof(uspace_arg_t)); 99 99 if (!uarg) 100 100 return ENOMEM; 101 102 fibril_t *fibril = fibril_alloc(); 103 if (!fibril) { 104 free(uarg); 105 return ENOMEM; 106 } 101 107 102 108 size_t stack_size = stack_size_get(); … … 105 111 AS_AREA_LATE_RESERVE, AS_AREA_UNPAGED); 106 112 if (stack == AS_MAP_FAILED) { 113 fibril_teardown(fibril, false); 107 114 free(uarg); 108 115 return ENOMEM; … … 112 119 malloc_enable_multithreaded(); 113 120 121 fibril->arg = arg; 114 122 uarg->uspace_entry = (void *) FADDR(__thread_entry); 115 123 uarg->uspace_stack = stack; 116 124 uarg->uspace_stack_size = stack_size; 117 125 uarg->uspace_thread_function = function; 118 uarg->uspace_thread_arg = arg;126 uarg->uspace_thread_arg = fibril; 119 127 uarg->uspace_uarg = uarg; 120 128
Note:
See TracChangeset
for help on using the changeset viewer.