Changes in uspace/lib/c/generic/fibril.c [eceff5f:c0699467] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/fibril.c
receff5f rc0699467 37 37 #include <fibril.h> 38 38 #include <thread.h> 39 #include <stack.h>40 39 #include <tls.h> 41 40 #include <malloc.h> 42 #include <abi/mm/as.h>43 #include <as.h>44 41 #include <unistd.h> 45 42 #include <stdio.h> … … 50 47 #include <async.h> 51 48 49 #ifndef FIBRIL_INITIAL_STACK_PAGES_NO 50 #define FIBRIL_INITIAL_STACK_PAGES_NO 1 51 #endif 52 52 53 /** 53 54 * This futex serializes access to ready_list, … … 95 96 fibril_t *fibril_setup(void) 96 97 { 97 tcb_t *tcb = tls_make();98 tcb_t *tcb = __make_tls(); 98 99 if (!tcb) 99 100 return NULL; … … 101 102 fibril_t *fibril = malloc(sizeof(fibril_t)); 102 103 if (!fibril) { 103 tls_free(tcb);104 __free_tls(tcb); 104 105 return NULL; 105 106 } … … 122 123 void fibril_teardown(fibril_t *fibril) 123 124 { 124 tls_free(fibril->tcb);125 __free_tls(fibril->tcb); 125 126 free(fibril); 126 127 } … … 194 195 * stack member filled. 195 196 */ 196 as_area_destroy(stack);197 free(stack); 197 198 } 198 199 fibril_teardown(srcf->clean_after_me); … … 256 257 * @param func Implementing function of the new fibril. 257 258 * @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 _generic(int (*func)(void *), void *arg, size_t stksz)263 fid_t fibril_create(int (*func)(void *), void *arg) 264 264 { 265 265 fibril_t *fibril; … … 269 269 return 0; 270 270 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) { 271 fibril->stack = 272 (char *) malloc(FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize()); 273 if (!fibril->stack) { 277 274 fibril_teardown(fibril); 278 275 return 0; … … 284 281 context_save(&fibril->ctx); 285 282 context_set(&fibril->ctx, FADDR(fibril_main), fibril->stack, 286 stack_size, fibril->tcb);283 FIBRIL_INITIAL_STACK_PAGES_NO * getpagesize(), fibril->tcb); 287 284 288 285 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 be297 * 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);305 286 } 306 287
Note:
See TracChangeset
for help on using the changeset viewer.