diff options
author | Dimitri Staessens <[email protected]> | 2019-03-28 14:26:36 +0100 |
---|---|---|
committer | Sander Vrijders <[email protected]> | 2019-03-28 14:54:03 +0100 |
commit | 7039fd62a5863741adb757665696a67a8228db40 (patch) | |
tree | 4ea61f6e76f1e7f5e01c4f9ba31642b1b2d64813 /src/ipcpd | |
parent | 34b82a4d68022d462d49dd1f0401e81b84319f47 (diff) | |
download | ouroboros-7039fd62a5863741adb757665696a67a8228db40.tar.gz ouroboros-7039fd62a5863741adb757665696a67a8228db40.zip |
ipcpd: Give max priority to flow allocator
The flow allocator thread was running on a low priority, causing some
delay when handling packets. Usually this isn't a problem, but for
congestion control updates, the delay may become problematic. The
priority is now set to the maximum allowed by the scheduler policy to
improve responsiveness.
Signed-off-by: Dimitri Staessens <[email protected]>
Signed-off-by: Sander Vrijders <[email protected]>
Diffstat (limited to 'src/ipcpd')
-rw-r--r-- | src/ipcpd/normal/fa.c | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/src/ipcpd/normal/fa.c b/src/ipcpd/normal/fa.c index e03467c2..76942143 100644 --- a/src/ipcpd/normal/fa.c +++ b/src/ipcpd/normal/fa.c @@ -306,15 +306,44 @@ void fa_fini(void) int fa_start(void) { + struct sched_param par; + int pol; + int max; + fa.psched = psched_create(packet_handler); - if (fa.psched == NULL) + if (fa.psched == NULL) { + log_err("Failed to start packet scheduler."); goto fail_psched; + } - if (pthread_create(&fa.worker, NULL, fa_handle_packet, NULL)) + if (pthread_create(&fa.worker, NULL, fa_handle_packet, NULL)) { + log_err("Failed to create worker thread."); goto fail_thread; + } + + if (pthread_getschedparam(fa.worker, &pol, &par)) { + log_err("Failed to get worker thread scheduling parameters."); + goto fail_sched; + } + + max = sched_get_priority_max(pol); + if (max < 0) { + log_err("Failed to get max priority for scheduler."); + goto fail_sched; + } + + par.sched_priority = max; + + if (pthread_setschedparam(fa.worker, pol, &par)) { + log_err("Failed to set scheduler priority to maximum."); + goto fail_sched; + } return 0; + fail_sched: + pthread_cancel(fa.worker); + pthread_join(fa.worker, NULL); fail_thread: psched_destroy(fa.psched); fail_psched: |