Changeset 2e9b59b for libcfa/src/concurrency/io
- Timestamp:
- Apr 19, 2022, 3:00:04 PM (4 years ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation, qualifiedEnum, stuck-waitfor-destruct
- Children:
- 5b84a321
- Parents:
- ba897d21 (diff), bb7c77d (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. - Location:
- libcfa/src/concurrency/io
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/io/setup.cfa
rba897d21 r2e9b59b 32 32 33 33 void __cfa_io_start( processor * proc ) {} 34 bool __cfa_io_flush( processor * proc, int ) { return false; } 34 bool __cfa_io_flush( processor * proc ) { return false; } 35 bool __cfa_io_drain( processor * proc ) __attribute__((nonnull (1))) { return false; } 36 void __cfa_io_idle ( processor * ) __attribute__((nonnull (1))) {} 35 37 void __cfa_io_stop ( processor * proc ) {} 36 38 … … 39 41 40 42 #else 43 #pragma GCC diagnostic push 44 #pragma GCC diagnostic ignored "-Waddress-of-packed-member" 41 45 #include <errno.h> 42 46 #include <stdint.h> … … 57 61 #include "bitmanip.hfa" 58 62 #include "fstream.hfa" 59 #include "kernel_private.hfa" 63 #include "kernel/private.hfa" 64 #include "limits.hfa" 60 65 #include "thread.hfa" 66 #pragma GCC diagnostic pop 61 67 62 68 void ?{}(io_context_params & this) { … … 112 118 this.ext_sq.empty = true; 113 119 (this.ext_sq.queue){}; 114 __io_uring_setup( this, cl.io.params, proc->idle_ fd );120 __io_uring_setup( this, cl.io.params, proc->idle_wctx.evfd ); 115 121 __cfadbg_print_safe(io_core, "Kernel I/O : Created ring for io_context %u (%p)\n", this.fd, &this); 116 122 } … … 122 128 __cfadbg_print_safe(io_core, "Kernel I/O : Destroyed ring for io_context %u\n", this.fd); 123 129 } 124 125 extern void __disable_interrupts_hard();126 extern void __enable_interrupts_hard();127 130 128 131 static void __io_uring_setup( $io_context & this, const io_context_params & params_in, int procfd ) { … … 214 217 215 218 // completion queue 219 cq.lock = false; 220 cq.id = MAX; 221 cq.ts = rdtscl(); 216 222 cq.head = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.head); 217 223 cq.tail = (volatile __u32 *)(((intptr_t)cq.ring_ptr) + params.cq_off.tail); … … 227 233 __cfadbg_print_safe(io_core, "Kernel I/O : registering %d for completion with ring %d\n", procfd, fd); 228 234 229 __disable_interrupts_hard();230 231 235 int ret = syscall( __NR_io_uring_register, fd, IORING_REGISTER_EVENTFD, &procfd, 1); 232 236 if (ret < 0) { 233 237 abort("KERNEL ERROR: IO_URING EVENTFD REGISTER - %s\n", strerror(errno)); 234 238 } 235 236 __enable_interrupts_hard();237 239 238 240 __cfadbg_print_safe(io_core, "Kernel I/O : registered %d for completion with ring %d\n", procfd, fd); -
libcfa/src/concurrency/io/types.hfa
rba897d21 r2e9b59b 23 23 #include "bits/locks.hfa" 24 24 #include "bits/queue.hfa" 25 #include "iofwd.hfa" 25 26 #include "kernel/fwd.hfa" 27 #include "limits.hfa" 26 28 27 29 #if defined(CFA_HAVE_LINUX_IO_URING_H) … … 77 79 78 80 struct __cmp_ring_t { 81 volatile bool lock; 82 83 unsigned id; 84 85 unsigned long long ts; 86 79 87 // Head and tail of the ring 80 88 volatile __u32 * head; … … 128 136 }; 129 137 138 static inline unsigned long long ts($io_context *& this) { 139 const __u32 head = *this->cq.head; 140 const __u32 tail = *this->cq.tail; 141 142 if(head == tail) return MAX; 143 144 return this->cq.ts; 145 } 146 130 147 struct __pending_alloc { 131 148 inline __outstanding_io; … … 170 187 // void __ioctx_prepare_block($io_context & ctx); 171 188 #endif 172 173 //-----------------------------------------------------------------------174 // IO user data175 struct io_future_t {176 future_t self;177 __s32 result;178 };179 180 static inline {181 thread$ * fulfil( io_future_t & this, __s32 result, bool do_unpark = true ) {182 this.result = result;183 return fulfil(this.self, do_unpark);184 }185 186 // Wait for the future to be fulfilled187 bool wait ( io_future_t & this ) { return wait (this.self); }188 void reset ( io_future_t & this ) { return reset (this.self); }189 bool available( io_future_t & this ) { return available(this.self); }190 }
Note:
See TracChangeset
for help on using the changeset viewer.