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