Changeset 25eec4e in mainline for uspace/lib/c/generic/fibril.c
- Timestamp:
- 2013-04-19T18:38:18Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6d717a4
- Parents:
- a1e2df13 (diff), 289cb7dd (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril.c
ra1e2df13 r25eec4e 37 37 #include <fibril.h> 38 38 #include <thread.h> 39 #include <stack.h> 39 40 #include <tls.h> 40 41 #include <malloc.h> 42 #include <abi/mm/as.h> 43 #include <as.h> 41 44 #include <unistd.h> 42 45 #include <stdio.h> … … 47 50 #include <async.h> 48 51 49 #ifndef FIBRIL_INITIAL_STACK_PAGES_NO50 #define FIBRIL_INITIAL_STACK_PAGES_NO 151 #endif52 53 52 /** 54 53 * This futex serializes access to ready_list, … … 96 95 fibril_t *fibril_setup(void) 97 96 { 98 tcb_t *tcb = __make_tls();97 tcb_t *tcb = tls_make(); 99 98 if (!tcb) 100 99 return NULL; … … 102 101 fibril_t *fibril = malloc(sizeof(fibril_t)); 103 102 if (!fibril) { 104 __free_tls(tcb);103 tls_free(tcb); 105 104 return NULL; 106 105 } … … 123 122 void fibril_teardown(fibril_t *fibril) 124 123 { 125 __free_tls(fibril->tcb);124 tls_free(fibril->tcb); 126 125 free(fibril); 127 126 } … … 195 194 * stack member filled. 196 195 */ 197 free(stack);196 as_area_destroy(stack); 198 197 } 199 198 fibril_teardown(srcf->clean_after_me); … … 257 256 * @param func Implementing function of the new fibril. 258 257 * @param arg Argument to pass to func. 258 * @param stksz Stack size in bytes. 259 259 * 260 260 * @return 0 on failure or TLS of the new fibril. 261 261 * 262 262 */ 263 fid_t fibril_create (int (*func)(void *), void *arg)263 fid_t fibril_create_generic(int (*func)(void *), void *arg, size_t stksz) 264 264 { 265 265 fibril_t *fibril; … … 269 269 return 0; 270 270 271 fibril->stack = 272 (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize()); 273 if (!fibril->stack) { 271 size_t stack_size = (stksz == FIBRIL_DFLT_STK_SIZE) ? 272 stack_size_get() : stksz; 273 fibril->stack = as_area_create((void *) -1, stack_size, 274 AS_AREA_READ | AS_AREA_WRITE | AS_AREA_CACHEABLE | AS_AREA_GUARD | 275 AS_AREA_LATE_RESERVE); 276 if (fibril->stack == (void *) -1) { 274 277 fibril_teardown(fibril); 275 278 return 0; … … 281 284 context_save(&fibril->ctx); 282 285 context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack, 283 FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb);286 stack_size, fibril->tcb); 284 287 285 288 return (fid_t) fibril; … … 298 301 fibril_t *fibril = (fibril_t *) fid; 299 302 300 free(fibril->stack);303 as_area_destroy(fibril->stack); 301 304 fibril_teardown(fibril); 302 305 }
Note:
See TracChangeset
for help on using the changeset viewer.