Changes in / [aaa3c457:3ce781f4] in mainline
- Files:
-
- 2 added
- 2 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
abi/include/abi/cap.h
raaa3c457 r3ce781f4 52 52 } *cap_irq_handle_t; 53 53 54 typedef struct {55 } *cap_waitq_handle_t;56 57 54 #endif 58 55 -
abi/include/abi/syscall.h
raaa3c457 r3ce781f4 51 51 SYS_PROGRAM_SPAWN_LOADER, 52 52 53 SYS_WAITQ_CREATE, 54 SYS_WAITQ_SLEEP, 55 SYS_WAITQ_WAKEUP, 56 SYS_WAITQ_DESTROY, 53 SYS_FUTEX_SLEEP, 54 SYS_FUTEX_WAKEUP, 57 55 SYS_SMC_COHERENCE, 58 56 -
kernel/Makefile
raaa3c457 r3ce781f4 227 227 generic/src/synch/smc.c \ 228 228 generic/src/synch/waitq.c \ 229 generic/src/synch/ syswaitq.c \229 generic/src/synch/futex.c \ 230 230 generic/src/smp/ipi.c \ 231 231 generic/src/smp/smp.c \ -
kernel/generic/include/cap/cap.h
raaa3c457 r3ce781f4 55 55 KOBJECT_TYPE_IRQ, 56 56 KOBJECT_TYPE_PHONE, 57 KOBJECT_TYPE_WAITQ,58 57 KOBJECT_TYPE_MAX 59 58 } kobject_type_t; … … 64 63 struct irq; 65 64 struct phone; 66 struct waitq;67 65 68 66 typedef struct kobject_ops { … … 90 88 struct irq *irq; 91 89 struct phone *phone; 92 struct waitq *waitq;93 90 }; 94 91 } kobject_t; -
kernel/generic/include/proc/task.h
raaa3c457 r3ce781f4 42 42 #include <synch/spinlock.h> 43 43 #include <synch/mutex.h> 44 #include <synch/futex.h> 44 45 #include <adt/list.h> 45 46 #include <adt/odict.h> … … 127 128 task_arch_t arch; 128 129 130 /** Serializes access to futex_list.*/ 131 SPINLOCK_DECLARE(futex_list_lock); 132 /** List of all futexes accesses by this task. */ 133 list_t futex_list; 134 129 135 /** Accumulated accounting. */ 130 136 uint64_t ucycles; -
kernel/generic/include/synch/waitq.h
raaa3c457 r3ce781f4 49 49 * 50 50 */ 51 typedef struct waitq{51 typedef struct { 52 52 /** Lock protecting wait queue structure. 53 53 * -
kernel/generic/src/main/main.c
raaa3c457 r3ce781f4 77 77 #include <mm/reserve.h> 78 78 #include <synch/waitq.h> 79 #include <synch/ syswaitq.h>79 #include <synch/futex.h> 80 80 #include <arch/arch.h> 81 81 #include <arch.h> … … 278 278 task_init(); 279 279 thread_init(); 280 sys_waitq_init();280 futex_init(); 281 281 282 282 sysinfo_set_item_data("boot_args", NULL, bargs, str_size(bargs) + 1); -
kernel/generic/src/proc/task.c
raaa3c457 r3ce781f4 43 43 #include <mm/slab.h> 44 44 #include <atomic.h> 45 #include <synch/futex.h> 45 46 #include <synch/spinlock.h> 46 47 #include <synch/waitq.h> … … 250 251 } 251 252 253 futex_task_init(task); 254 252 255 irq_spinlock_lock(&tasks_lock, true); 253 256 -
kernel/generic/src/proc/thread.c
raaa3c457 r3ce781f4 48 48 #include <synch/spinlock.h> 49 49 #include <synch/waitq.h> 50 #include <synch/syswaitq.h>51 50 #include <cpu.h> 52 51 #include <str.h> … … 520 519 */ 521 520 ipc_cleanup(); 522 sys_waitq_task_cleanup();521 futex_task_cleanup(); 523 522 LOG("Cleanup of task %" PRIu64 " completed.", TASK->taskid); 524 523 } -
kernel/generic/src/syscall/syscall.c
raaa3c457 r3ce781f4 46 46 #include <interrupt.h> 47 47 #include <ipc/sysipc.h> 48 #include <synch/futex.h> 48 49 #include <synch/smc.h> 49 #include <synch/syswaitq.h>50 50 #include <ddi/ddi.h> 51 51 #include <ipc/event.h> … … 136 136 137 137 /* Synchronization related syscalls. */ 138 [SYS_WAITQ_CREATE] = (syshandler_t) sys_waitq_create, 139 [SYS_WAITQ_SLEEP] = (syshandler_t) sys_waitq_sleep, 140 [SYS_WAITQ_WAKEUP] = (syshandler_t) sys_waitq_wakeup, 141 [SYS_WAITQ_DESTROY] = (syshandler_t) sys_waitq_destroy, 138 [SYS_FUTEX_SLEEP] = (syshandler_t) sys_futex_sleep, 139 [SYS_FUTEX_WAKEUP] = (syshandler_t) sys_futex_wakeup, 142 140 [SYS_SMC_COHERENCE] = (syshandler_t) sys_smc_coherence, 143 141 -
uspace/app/trace/syscalls.c
raaa3c457 r3ce781f4 46 46 [SYS_TASK_GET_ID] = { "task_get_id", 1, V_ERRNO }, 47 47 [SYS_TASK_SET_NAME] = { "task_set_name", 2, V_ERRNO }, 48 [SYS_FUTEX_SLEEP] = { "futex_sleep_timeout", 3, V_ERRNO }, 49 [SYS_FUTEX_WAKEUP] = { "futex_wakeup", 1, V_ERRNO }, 48 50 49 51 [SYS_AS_AREA_CREATE] = { "as_area_create", 5, V_ERRNO }, -
uspace/lib/c/generic/async/client.c
raaa3c457 r3ce781f4 122 122 #include "../private/fibril.h" 123 123 124 static fibril_rmutex_t message_mutex;124 static FIBRIL_RMUTEX_INITIALIZE(message_mutex); 125 125 126 126 /** Naming service session */ … … 173 173 void __async_client_init(void) 174 174 { 175 if (fibril_rmutex_initialize(&message_mutex) != EOK)176 abort();177 178 175 session_ns.iface = 0; 179 176 session_ns.mgmt = EXCHANGE_ATOMIC; … … 189 186 fibril_mutex_initialize(&session_ns.mutex); 190 187 session_ns.exchanges = 0; 191 }192 193 void __async_client_fini(void)194 {195 fibril_rmutex_destroy(&message_mutex);196 188 } 197 189 -
uspace/lib/c/generic/async/ports.c
raaa3c457 r3ce781f4 100 100 101 101 /** Futex guarding the interface hash table. */ 102 static fibril_rmutex_t interface_mutex;102 static FIBRIL_RMUTEX_INITIALIZE(interface_mutex); 103 103 static hash_table_t interface_hash_table; 104 104 … … 292 292 void __async_ports_init(void) 293 293 { 294 if (fibril_rmutex_initialize(&interface_mutex) != EOK)295 abort();296 297 294 if (!hash_table_create(&interface_hash_table, 0, 0, 298 295 &interface_hash_table_ops)) 299 296 abort(); 300 297 } 301 302 void __async_ports_fini(void)303 {304 fibril_rmutex_destroy(&interface_mutex);305 } -
uspace/lib/c/generic/async/server.c
raaa3c457 r3ce781f4 216 216 } 217 217 218 static fibril_rmutex_t client_mutex;218 static FIBRIL_RMUTEX_INITIALIZE(client_mutex); 219 219 static hash_table_t client_hash_table; 220 220 221 221 // TODO: lockfree notification_queue? 222 static fibril_rmutex_t notification_mutex;222 static FIBRIL_RMUTEX_INITIALIZE(notification_mutex); 223 223 static hash_table_t notification_hash_table; 224 224 static LIST_INITIALIZE(notification_queue); … … 1013 1013 void __async_server_init(void) 1014 1014 { 1015 if (fibril_rmutex_initialize(&client_mutex) != EOK)1016 abort();1017 if (fibril_rmutex_initialize(¬ification_mutex) != EOK)1018 abort();1019 1020 1015 if (!hash_table_create(&client_hash_table, 0, 0, &client_hash_table_ops)) 1021 1016 abort(); … … 1026 1021 1027 1022 async_create_manager(); 1028 }1029 1030 void __async_server_fini(void)1031 {1032 fibril_rmutex_destroy(&client_mutex);1033 fibril_rmutex_destroy(¬ification_mutex);1034 1023 } 1035 1024 -
uspace/lib/c/generic/io/kio.c
raaa3c457 r3ce781f4 38 38 #include <str.h> 39 39 #include <stdint.h> 40 #include <stdlib.h>41 40 #include <errno.h> 42 41 #include <abi/kio.h> … … 54 53 char data[KIO_BUFFER_SIZE]; 55 54 size_t used; 56 } kio_buffer; 57 58 void __kio_init(void) 59 { 60 if (futex_initialize(&kio_buffer.futex, 1) != EOK) 61 abort(); 62 } 63 64 void __kio_fini(void) 65 { 66 futex_destroy(&kio_buffer.futex); 67 } 55 } kio_buffer = { .futex = FUTEX_INITIALIZER, }; 68 56 69 57 errno_t kio_write(const void *buf, size_t size, size_t *nwritten) -
uspace/lib/c/generic/libc.c
raaa3c457 r3ce781f4 40 40 #include <tls.h> 41 41 #include <fibril.h> 42 #include <fibril_synch.h>43 42 #include <task.h> 44 43 #include <loader/pcb.h> 45 44 #include <vfs/vfs.h> 46 45 #include <vfs/inbox.h> 47 #include <io/kio.h>48 46 #include "private/libc.h" 49 47 #include "private/async.h" … … 63 61 void __libc_main(void *pcb_ptr) 64 62 { 65 __kio_init();66 67 63 assert(!__tcb_is_set()); 68 64 … … 85 81 86 82 __fibrils_init(); 87 __fibril_synch_init();88 83 89 84 /* Initialize the fibril. */ … … 153 148 } 154 149 155 void __libc_fini(void)156 {157 __async_client_fini();158 __async_server_fini();159 __async_ports_fini();160 161 __fibril_synch_fini();162 __fibrils_fini();163 164 __malloc_fini();165 166 __kio_fini();167 }168 169 150 void __libc_exit(int status) 170 151 { -
uspace/lib/c/generic/malloc.c
raaa3c457 r3ce781f4 195 195 196 196 /** Futex for thread-safe heap manipulation */ 197 static fibril_rmutex_t malloc_mutex;197 static FIBRIL_RMUTEX_INITIALIZE(malloc_mutex); 198 198 199 199 #define malloc_assert(expr) safe_assert(expr) … … 484 484 void __malloc_init(void) 485 485 { 486 if (fibril_rmutex_initialize(&malloc_mutex) != EOK)487 abort();488 489 486 if (!area_create(PAGE_SIZE)) 490 487 abort(); 491 }492 493 void __malloc_fini(void)494 {495 fibril_rmutex_destroy(&malloc_mutex);496 488 } 497 489 -
uspace/lib/c/generic/private/async.h
raaa3c457 r3ce781f4 95 95 96 96 extern void __async_server_init(void); 97 extern void __async_server_fini(void);98 97 extern void __async_client_init(void); 99 extern void __async_client_fini(void);100 98 extern void __async_ports_init(void); 101 extern void __async_ports_fini(void);102 99 103 100 extern errno_t async_create_port_internal(iface_t, async_port_handler_t, -
uspace/lib/c/generic/private/fibril.h
raaa3c457 r3ce781f4 79 79 80 80 extern void __fibrils_init(void); 81 extern void __fibrils_fini(void);82 81 83 82 extern void fibril_wait_for(fibril_event_t *); … … 121 120 } fibril_rmutex_t; 122 121 123 extern errno_t fibril_rmutex_initialize(fibril_rmutex_t *); 124 extern void fibril_rmutex_destroy(fibril_rmutex_t *); 122 #define FIBRIL_RMUTEX_INITIALIZER(name) \ 123 { .futex = FUTEX_INITIALIZE(1) } 124 125 #define FIBRIL_RMUTEX_INITIALIZE(name) \ 126 fibril_rmutex_t name = FIBRIL_RMUTEX_INITIALIZER(name) 127 128 extern void fibril_rmutex_initialize(fibril_rmutex_t *); 125 129 extern void fibril_rmutex_lock(fibril_rmutex_t *); 126 130 extern bool fibril_rmutex_trylock(fibril_rmutex_t *); -
uspace/lib/c/generic/private/futex.h
raaa3c457 r3ce781f4 42 42 #include <time.h> 43 43 #include <fibril.h> 44 #include <abi/cap.h>45 #include <abi/synch.h>46 44 47 45 typedef struct futex { 48 46 volatile atomic_int val; 49 volatile cap_waitq_handle_t whandle;50 51 47 #ifdef CONFIG_DEBUG_FUTEX 52 48 _Atomic(fibril_t *) owner; … … 54 50 } futex_t; 55 51 56 extern errno_t futex_initialize(futex_t *futex, int value); 57 58 static inline errno_t futex_destroy(futex_t *futex) 59 { 60 if (futex->whandle) { 61 errno_t rc; 62 rc = __SYSCALL1(SYS_WAITQ_DESTROY, (sysarg_t) futex->whandle); 63 futex->whandle = CAP_NIL; 64 return rc; 65 } 66 return EOK; 67 } 52 extern void futex_initialize(futex_t *futex, int value); 68 53 69 54 #ifdef CONFIG_DEBUG_FUTEX 55 56 #define FUTEX_INITIALIZE(val) { (val) , NULL } 57 #define FUTEX_INITIALIZER FUTEX_INITIALIZE(1) 70 58 71 59 void __futex_assert_is_locked(futex_t *, const char *); … … 86 74 #else 87 75 76 #define FUTEX_INITIALIZE(val) { (val) } 77 #define FUTEX_INITIALIZER FUTEX_INITIALIZE(1) 78 88 79 #define futex_lock(fut) (void) futex_down((fut)) 89 80 #define futex_trylock(fut) futex_trydown((fut)) … … 95 86 96 87 #endif 97 98 static inline errno_t futex_allocate_waitq(futex_t *futex)99 {100 return __SYSCALL1(SYS_WAITQ_CREATE, (sysarg_t) &futex->whandle);101 }102 88 103 89 /** Down the futex with timeout, composably. … … 121 107 { 122 108 // TODO: Add tests for this. 123 124 assert(futex->whandle != CAP_NIL);125 109 126 110 if (atomic_fetch_sub_explicit(&futex->val, 1, memory_order_acquire) > 0) … … 148 132 } 149 133 150 return __SYSCALL3(SYS_WAITQ_SLEEP, (sysarg_t) futex->whandle, 151 (sysarg_t) timeout, (sysarg_t) SYNCH_FLAGS_FUTEX); 134 return __SYSCALL2(SYS_FUTEX_SLEEP, (sysarg_t) futex, (sysarg_t) timeout); 152 135 } 153 136 … … 164 147 { 165 148 if (atomic_fetch_add_explicit(&futex->val, 1, memory_order_release) < 0) 166 return __SYSCALL1(SYS_ WAITQ_WAKEUP, (sysarg_t) futex->whandle);149 return __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) futex); 167 150 168 151 return EOK; -
uspace/lib/c/generic/private/malloc.h
raaa3c457 r3ce781f4 37 37 38 38 extern void __malloc_init(void); 39 extern void __malloc_fini(void);40 39 41 40 #endif -
uspace/lib/c/generic/thread/fibril.c
raaa3c457 r3ce781f4 87 87 88 88 /* This futex serializes access to global data. */ 89 static futex_t fibril_futex ;89 static futex_t fibril_futex = FUTEX_INITIALIZER; 90 90 static futex_t ready_semaphore; 91 91 static long ready_st_count; … … 95 95 static LIST_INITIALIZE(timeout_list); 96 96 97 static futex_t ipc_lists_futex ;97 static futex_t ipc_lists_futex = FUTEX_INITIALIZER; 98 98 static LIST_INITIALIZE(ipc_waiter_list); 99 99 static LIST_INITIALIZE(ipc_buffer_list); … … 796 796 if (!multithreaded) { 797 797 _ready_debug_check(); 798 if (futex_initialize(&ready_semaphore, ready_st_count) != EOK) 799 abort(); 798 futex_initialize(&ready_semaphore, ready_st_count); 800 799 multithreaded = true; 801 800 } … … 862 861 void __fibrils_init(void) 863 862 { 864 if (futex_initialize(&fibril_futex, 1) != EOK)865 abort();866 if (futex_initialize(&ipc_lists_futex, 1) != EOK)867 abort();868 869 863 /* 870 864 * We allow a fixed, small amount of parallelism for IPC reads, but … … 882 876 } 883 877 884 void __fibrils_fini(void)885 {886 futex_destroy(&fibril_futex);887 futex_destroy(&ipc_lists_futex);888 }889 890 878 void fibril_usleep(usec_t timeout) 891 879 { -
uspace/lib/c/generic/thread/fibril_synch.c
raaa3c457 r3ce781f4 51 51 #include "../private/futex.h" 52 52 53 errno_t fibril_rmutex_initialize(fibril_rmutex_t *m) 54 { 55 return futex_initialize(&m->futex, 1); 56 } 57 58 void fibril_rmutex_destroy(fibril_rmutex_t *m) 59 { 60 futex_destroy(&m->futex); 53 void fibril_rmutex_initialize(fibril_rmutex_t *m) 54 { 55 futex_initialize(&m->futex, 1); 61 56 } 62 57 … … 90 85 static fibril_local bool deadlocked = false; 91 86 92 static futex_t fibril_synch_futex; 93 94 void __fibril_synch_init(void) 95 { 96 if (futex_initialize(&fibril_synch_futex, 1) != EOK) 97 abort(); 98 } 99 100 void __fibril_synch_fini(void) 101 { 102 futex_destroy(&fibril_synch_futex); 103 } 87 static futex_t fibril_synch_futex = FUTEX_INITIALIZER; 104 88 105 89 typedef struct { -
uspace/lib/c/generic/thread/futex.c
raaa3c457 r3ce781f4 49 49 * @param val Initialization value. 50 50 * 51 * @return Error code.52 51 */ 53 errno_tfutex_initialize(futex_t *futex, int val)52 void futex_initialize(futex_t *futex, int val) 54 53 { 55 54 atomic_store_explicit(&futex->val, val, memory_order_relaxed); 56 futex->whandle = CAP_NIL;57 return futex_allocate_waitq(futex);58 55 } 59 56 -
uspace/lib/c/generic/thread/mpsc.c
raaa3c457 r3ce781f4 80 80 } 81 81 82 if (fibril_rmutex_initialize(&q->t_lock) != EOK) {83 free(q);84 free(n);85 free(c);86 return NULL;87 }88 89 82 q->elem_size = elem_size; 83 fibril_rmutex_initialize(&q->t_lock); 90 84 q->head = q->tail = n; 91 85 q->close_node = c; … … 103 97 } 104 98 105 fibril_rmutex_destroy(&q->t_lock);99 // TODO: fibril_rmutex_destroy() 106 100 107 101 free(q); -
uspace/lib/c/include/fibril_synch.h
raaa3c457 r3ce781f4 164 164 fibril_semaphore_t name = FIBRIL_SEMAPHORE_INITIALIZER(name, cnt) 165 165 166 extern void __fibril_synch_init(void);167 extern void __fibril_synch_fini(void);168 169 166 extern void fibril_mutex_initialize(fibril_mutex_t *); 170 167 extern void fibril_mutex_lock(fibril_mutex_t *); -
uspace/lib/c/include/io/kio.h
raaa3c457 r3ce781f4 42 42 #include <_bits/size_t.h> 43 43 44 extern void __kio_init(void);45 extern void __kio_fini(void);46 44 extern errno_t kio_write(const void *, size_t, size_t *); 47 45 extern void kio_update(void); -
uspace/lib/c/include/libc.h
raaa3c457 r3ce781f4 62 62 __syscall6(p1, p2, p3, p4, p5, p6, id) 63 63 64 extern void __libc_fini(void);65 66 64 #endif 67 65 -
uspace/srv/loader/main.c
raaa3c457 r3ce781f4 59 59 #include <vfs/vfs.h> 60 60 #include <vfs/inbox.h> 61 #include <libc.h>62 61 63 62 #ifdef CONFIG_RTLD … … 358 357 DPRINTF("Jump to entry point at %p\n", pcb.entry); 359 358 360 __libc_fini();361 359 __tcb_reset(); 362 360 entry_point_jmp(prog_info.finfo.entry, &pcb);
Note:
See TracChangeset
for help on using the changeset viewer.