Changes in uspace/lib/c/generic/fibril.c [c0699467:eceff5f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril.c
rc0699467 receff5f 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; 289 } 290 291 /** Delete a fibril that has never run. 292 * 293 * Free resources of a fibril that has been created with fibril_create() 294 * but never readied using fibril_add_ready(). 295 * 296 * @param fid Pointer to the fibril structure of the fibril to be 297 * added. 298 */ 299 void fibril_destroy(fid_t fid) 300 { 301 fibril_t *fibril = (fibril_t *) fid; 302 303 as_area_destroy(fibril->stack); 304 fibril_teardown(fibril); 286 305 } 287 306
Note:
See TracChangeset
for help on using the changeset viewer.