Changeset 9a3b469 in mainline
- Timestamp:
- 2012-12-04T04:09:08Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d54b303
- Parents:
- 1b7eec9
- Location:
- uspace/lib/c/generic
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/libc.c
r1b7eec9 r9a3b469 51 51 #include "private/malloc.h" 52 52 #include "private/io.h" 53 #include "private/thread.h" 53 54 54 55 #ifdef CONFIG_RTLD … … 72 73 /* Save the PCB pointer */ 73 74 __pcb = (pcb_t *) pcb_ptr; 75 76 atomic_inc(&_created_thread_cnt); 74 77 75 78 /* The basic run-time environment is setup */ -
uspace/lib/c/generic/malloc.c
r1b7eec9 r9a3b469 47 47 #include <adt/gcdlcm.h> 48 48 #include "private/malloc.h" 49 #include "private/thread.h" 49 50 50 51 /** Magic used in heap headers. */ … … 785 786 void *malloc(const size_t size) 786 787 { 787 futex_down(&malloc_futex); 788 void *block = malloc_internal(size, BASE_ALIGN); 789 futex_up(&malloc_futex); 790 791 return block; 788 /* Do not use futexes for allocations during main thread initialization. */ 789 if (0 == atomic_get(&_created_thread_cnt)) { 790 return malloc_internal(size, BASE_ALIGN); 791 } else { 792 futex_down(&malloc_futex); 793 void *block = malloc_internal(size, BASE_ALIGN); 794 futex_up(&malloc_futex); 795 return block; 796 } 792 797 } 793 798 … … 807 812 size_t palign = 808 813 1 << (fnzb(max(sizeof(void *), align) - 1) + 1); 809 810 futex_down(&malloc_futex); 811 void *block = malloc_internal(size, palign); 812 futex_up(&malloc_futex); 813 814 return block; 814 815 /* Do not use futexes for allocations during main thread initialization. */ 816 if (0 == atomic_get(&_created_thread_cnt)) { 817 return malloc_internal(size, palign); 818 } else { 819 futex_down(&malloc_futex); 820 void *block = malloc_internal(size, palign); 821 futex_up(&malloc_futex); 822 823 return block; 824 } 815 825 } 816 826 -
uspace/lib/c/generic/private/thread.h
r1b7eec9 r9a3b469 41 41 extern void __thread_main(uspace_arg_t *); 42 42 43 struct atomic; 44 extern struct atomic _created_thread_cnt; 45 43 46 #endif 44 47 -
uspace/lib/c/generic/thread.c
r1b7eec9 r9a3b469 46 46 #include "private/thread.h" 47 47 48 /** 49 * The number of threads that have been created and initialized since 50 * the start of the program. 51 */ 52 atomic_t _created_thread_cnt = {0}; 53 48 54 /** Main thread function. 49 55 * … … 62 68 63 69 __tcb_set(fibril->tcb); 70 71 atomic_inc(&_created_thread_cnt); 64 72 65 73 uarg->uspace_thread_function(uarg->uspace_thread_arg);
Note:
See TracChangeset
for help on using the changeset viewer.