Path: blob/main/benchmarks/interbench/files/patch-interbench.c
16460 views
--- interbench.c.orig 2009-10-31 04:14:59 UTC1+++ interbench.c2@@ -43,8 +43,12 @@3#include <sys/time.h>4#include <sys/resource.h>5#include <sys/types.h>6+#include <sys/stat.h>7#include <sys/mman.h>8#include <sys/wait.h>9+#ifdef __FreeBSD__10+#include <sys/sysctl.h>11+#endif12#include "interbench.h"1314#define MAX_UNAME_LENGTH 10015@@ -210,7 +214,7 @@ int test_fifo(void)16{17struct sched_param sp;18memset(&sp, 0, sizeof(sp));19- sp.sched_priority = 99;20+ sp.sched_priority = sched_get_priority_max(SCHED_FIFO);21if (sched_setscheduler(0, SCHED_FIFO, &sp) == -1) {22if (errno != EPERM)23terminal_error("sched_setscheduler");24@@ -888,7 +892,7 @@ void *timekeeping_thread(void *t)25* accurate accounting remains SCHED_NORMAL;26*/27if (th->dt != &th->benchmarks[NOT_BENCHING])28- set_fifo(96);29+ set_fifo(sched_get_priority_max(SCHED_FIFO) - 1);30/* These values must be changed at the appropriate places or race */31tk->sleep_interval = tk->slept_interval = 0;32post_sem(&s->ready);33@@ -1130,6 +1134,7 @@ write:3435void get_ram(void)36{37+#if defined(__linux__)38FILE *meminfo;39char aux[256];4041@@ -1143,6 +1148,21 @@ void get_ram(void)42fgets(aux,sizeof(aux),meminfo);43if (fclose(meminfo) == -1)44terminal_error("fclose");45+#elif defined(__FreeBSD__)46+ long pagesize, numpages;47+ quad_t swap;48+ size_t len = sizeof(swap);49+50+ pagesize = sysconf(_SC_PAGESIZE);51+ numpages = sysconf(_SC_PHYS_PAGES);52+ if (sysctlbyname("vm.swap_total", &swap, &len, NULL, 0) == -1)53+ swap = 0;54+55+ ud.ram = pagesize / 1024 * numpages;56+ ud.swap = swap / 1024;57+#else58+#error unsupported operating system59+#endif6061if( !ud.ram || !ud.swap ) {62unsigned long i;63@@ -1293,7 +1313,8 @@ void run_benchchild(int i, int j)64thi->dt = &thi->benchmarks[j];65initialise_thread_data(thi->dt);66if (ud.do_rt)67- set_thread_fifo(thi->pthread, 95);68+ set_thread_fifo(thi->pthread,69+ sched_get_priority_max(SCHED_FIFO) - 1);7071/* Tell main we're ready */72wakeup_with(b2m[1]);73@@ -1344,7 +1365,7 @@ void bench(int i, int j)74* We want to be higher priority than everything to signal them to75* stop and we lock our memory if we can as well76*/77- set_fifo(99);78+ set_fifo(sched_get_priority_max(SCHED_FIFO));79set_mlock();8081/* Wakeup the load process */82@@ -1652,7 +1673,7 @@ bench:83* To get as accurate a loop as possible we time it running84* SCHED_FIFO if we can85*/86- set_fifo(99);87+ set_fifo(sched_get_priority_max(SCHED_FIFO));88calibrate_loop();89set_normal();90} else919293