Changeset af77459 in mainline for uspace/app/kio/kio.c
- Timestamp:
- 2025-04-17T15:14:03Z (5 days ago)
- Branches:
- master
- Children:
- 571cc2d
- Parents:
- 1db4e2ae
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-11 15:27:51)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2025-04-17 15:14:03)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/kio/kio.c
r1db4e2ae raf77459 68 68 static FIBRIL_MUTEX_INITIALIZE(mtx); 69 69 70 static size_t last_notification; 71 70 72 /** Klog producer 71 73 * … … 153 155 * at any time to limit the chance of the consumer 154 156 * starving. 155 *156 * Note: Usually the automatic masking of the kio157 * notifications on the kernel side does the trick158 * of limiting the chance of accidentally copying159 * the same data multiple times. However, due to160 * the non-blocking architecture of kio notifications,161 * this possibility cannot be generally avoided.162 157 */ 163 158 164 159 fibril_mutex_lock(&mtx); 165 160 166 size_t kio_start = (size_t) ipc_get_arg1(call); 167 size_t kio_len = (size_t) ipc_get_arg2(call); 168 size_t kio_stored = (size_t) ipc_get_arg3(call); 169 170 size_t offset = (kio_start + kio_len - kio_stored) % kio_length; 161 size_t kio_written = (size_t) ipc_get_arg1(call); 162 163 /* This works just fine even when kio_written overflows. */ 164 size_t new_chars = kio_written - last_notification; 165 last_notification = kio_written; 166 167 if (new_chars > kio_length) { 168 /* We missed some data. */ 169 // TODO: Send a message with the number of lost bytes to the consumer. 170 new_chars = kio_length; 171 } 172 173 size_t offset = (kio_written - new_chars) % kio_length; 171 174 172 175 /* Copy data from the ring buffer */ 173 if (offset + kio_stored >=kio_length) {176 if (offset + new_chars > kio_length) { 174 177 size_t split = kio_length - offset; 175 178 176 179 producer(split, kio + offset); 177 producer(kio_stored - split, kio); 178 } else 179 producer(kio_stored, kio + offset); 180 producer(new_chars - split, kio); 181 } else { 182 producer(new_chars, kio + offset); 183 } 180 184 181 185 async_event_unmask(EVENT_KIO);
Note:
See TracChangeset
for help on using the changeset viewer.