Added support for real-time kernels
This commit is contained in:
parent
f64a336138
commit
16f1c52025
3 changed files with 99 additions and 2 deletions
|
|
@ -10,9 +10,17 @@
|
||||||
#include "rog_ally.h"
|
#include "rog_ally.h"
|
||||||
#include "legion_go.h"
|
#include "legion_go.h"
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
// Lock all current and future pages from preventing of being paged to swap
|
||||||
|
const int lockall_res = mlockall( MCL_CURRENT | MCL_FUTURE );
|
||||||
|
if (lockall_res) {
|
||||||
|
fprintf(stderr, "mlockall failed: %d", lockall_res);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
// fill in configuration from file: automatic fallback to default
|
// fill in configuration from file: automatic fallback to default
|
||||||
|
|
|
||||||
47
main.c
47
main.c
|
|
@ -10,9 +10,17 @@
|
||||||
#include "rog_ally.h"
|
#include "rog_ally.h"
|
||||||
#include "legion_go.h"
|
#include "legion_go.h"
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
// Lock all current and future pages from preventing of being paged to swap
|
||||||
|
const int lockall_res = mlockall( MCL_CURRENT | MCL_FUTURE );
|
||||||
|
if (lockall_res) {
|
||||||
|
fprintf(stderr, "mlockall failed: %d", lockall_res);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dev_in_settings_t in_settings = {
|
dev_in_settings_t in_settings = {
|
||||||
|
|
@ -74,8 +82,45 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
//memset(&dev_in_thread_data.communication.endpoint.socket.serveraddr, 0, sizeof(dev_in_thread_data.communication.endpoint.socket.serveraddr));
|
//memset(&dev_in_thread_data.communication.endpoint.socket.serveraddr, 0, sizeof(dev_in_thread_data.communication.endpoint.socket.serveraddr));
|
||||||
|
|
||||||
|
// Initialize pthread attributes (default values)
|
||||||
|
struct sched_param param;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
ret = pthread_attr_init(&attr);
|
||||||
|
if (ret) {
|
||||||
|
printf("init pthread attributes failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a specific stack size
|
||||||
|
ret = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 8192);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setstacksize failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set scheduler policy and priority of pthread
|
||||||
|
ret = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setschedpolicy failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
param.sched_priority = 80;
|
||||||
|
ret = pthread_attr_setschedparam(&attr, ¶m);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setschedparam failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use scheduling parameters of attr
|
||||||
|
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setinheritsched failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
pthread_t dev_in_thread;
|
pthread_t dev_in_thread;
|
||||||
const int dev_in_thread_creation = pthread_create(&dev_in_thread, NULL, dev_in_thread_func, (void*)(&dev_in_thread_data));
|
const int dev_in_thread_creation = pthread_create(&dev_in_thread, &attr, dev_in_thread_func, (void*)(&dev_in_thread_data));
|
||||||
if (dev_in_thread_creation != 0) {
|
if (dev_in_thread_creation != 0) {
|
||||||
fprintf(stderr, "Error creating dev_in thread: %d\n", dev_in_thread_creation);
|
fprintf(stderr, "Error creating dev_in thread: %d\n", dev_in_thread_creation);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
|
||||||
46
stray_ally.c
46
stray_ally.c
|
|
@ -7,9 +7,17 @@
|
||||||
#include "dev_out.h"
|
#include "dev_out.h"
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
|
||||||
|
#include <sys/mman.h>
|
||||||
|
|
||||||
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
static const char* configuration_file = "/etc/ROGueENEMY/config.cfg";
|
||||||
|
|
||||||
int main(int argc, char ** argv) {
|
int main(int argc, char ** argv) {
|
||||||
|
// Lock all current and future pages from preventing of being paged to swap
|
||||||
|
const int lockall_res = mlockall( MCL_CURRENT | MCL_FUTURE );
|
||||||
|
if (lockall_res) {
|
||||||
|
fprintf(stderr, "mlockall failed: %d", lockall_res);
|
||||||
|
}
|
||||||
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
dev_out_settings_t out_settings = {
|
dev_out_settings_t out_settings = {
|
||||||
|
|
@ -62,8 +70,44 @@ int main(int argc, char ** argv) {
|
||||||
|
|
||||||
load_out_config(&dev_out_thread_data.settings, configuration_file);
|
load_out_config(&dev_out_thread_data.settings, configuration_file);
|
||||||
|
|
||||||
|
// Initialize pthread attributes (default values)
|
||||||
|
struct sched_param param;
|
||||||
|
pthread_attr_t attr;
|
||||||
|
ret = pthread_attr_init(&attr);
|
||||||
|
if (ret) {
|
||||||
|
printf("init pthread attributes failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set a specific stack size
|
||||||
|
ret = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN + 8192);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setstacksize failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set scheduler policy and priority of pthread
|
||||||
|
ret = pthread_attr_setschedpolicy(&attr, SCHED_FIFO);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setschedpolicy failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
param.sched_priority = 80;
|
||||||
|
ret = pthread_attr_setschedparam(&attr, ¶m);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setschedparam failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use scheduling parameters of attr
|
||||||
|
ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED);
|
||||||
|
if (ret) {
|
||||||
|
printf("pthread setinheritsched failed\n");
|
||||||
|
goto main_err;
|
||||||
|
}
|
||||||
|
|
||||||
pthread_t dev_out_thread;
|
pthread_t dev_out_thread;
|
||||||
const int dev_out_thread_creation = pthread_create(&dev_out_thread, NULL, dev_out_thread_func, (void*)(&dev_out_thread_data));
|
const int dev_out_thread_creation = pthread_create(&dev_out_thread, &attr, dev_out_thread_func, (void*)(&dev_out_thread_data));
|
||||||
if (dev_out_thread_creation != 0) {
|
if (dev_out_thread_creation != 0) {
|
||||||
fprintf(stderr, "Error creating dev_out thread: %d\n", dev_out_thread_creation);
|
fprintf(stderr, "Error creating dev_out thread: %d\n", dev_out_thread_creation);
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue