Changeset 111b9b9 in mainline for kernel/generic/src/time/timeout.c
- Timestamp:
- 2023-02-11T19:13:44Z (20 months ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4777e02
- Parents:
- 76e17d7c
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2022-08-15 17:46:39)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2023-02-11 19:13:44)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/time/timeout.c
r76e17d7c r111b9b9 71 71 } 72 72 73 /** Register timeout 74 * 75 * Insert timeout handler f (with argument arg) 76 * to timeout list and make it execute in 77 * time microseconds (or slightly more). 78 * 79 * @param timeout Timeout structure. 80 * @param time Number of usec in the future to execute the handler. 81 * @param handler Timeout handler function. 82 * @param arg Timeout handler argument. 83 * 84 */ 85 void timeout_register(timeout_t *timeout, uint64_t time, 73 /* Only call when interrupts are disabled. */ 74 deadline_t timeout_deadline_in_usec(uint32_t usec) 75 { 76 if (usec == 0) 77 return 0; 78 79 return CPU->current_clock_tick + us2ticks(usec); 80 } 81 82 static void timeout_register_deadline_locked(timeout_t *timeout, deadline_t deadline, 86 83 timeout_handler_t handler, void *arg) 87 84 { 88 irq_spinlock_lock(&CPU->timeoutlock, true);89 90 85 assert(!link_in_use(&timeout->link)); 91 86 92 87 *timeout = (timeout_t) { 93 88 .cpu = CPU, 94 .deadline = CPU->current_clock_tick + us2ticks(time),89 .deadline = deadline, 95 90 .handler = handler, 96 91 .arg = arg, … … 113 108 } 114 109 } 110 } 115 111 112 /** Register timeout 113 * 114 * Insert timeout handler f (with argument arg) 115 * to timeout list and make it execute in 116 * time microseconds (or slightly more). 117 * 118 * @param timeout Timeout structure. 119 * @param time Number of usec in the future to execute the handler. 120 * @param handler Timeout handler function. 121 * @param arg Timeout handler argument. 122 * 123 */ 124 void timeout_register(timeout_t *timeout, uint64_t time, 125 timeout_handler_t handler, void *arg) 126 { 127 irq_spinlock_lock(&CPU->timeoutlock, true); 128 timeout_register_deadline_locked(timeout, timeout_deadline_in_usec(time), handler, arg); 129 irq_spinlock_unlock(&CPU->timeoutlock, true); 130 } 131 132 void timeout_register_deadline(timeout_t *timeout, deadline_t deadline, 133 timeout_handler_t handler, void *arg) 134 { 135 irq_spinlock_lock(&CPU->timeoutlock, true); 136 timeout_register_deadline_locked(timeout, deadline, handler, arg); 116 137 irq_spinlock_unlock(&CPU->timeoutlock, true); 117 138 }
Note:
See TracChangeset
for help on using the changeset viewer.