From d17b33131c14864bd1eae275f49a3f148e21cf29 Mon Sep 17 00:00:00 2001 From: Leo Chan Date: Thu, 22 Oct 2020 01:53:21 -0400 Subject: Squashed commit of the sb-vbs branch. Includes the SD-VBS benchmarks modified to: - Use libextra to loop as realtime jobs - Preallocate memory before starting their main computation - Accept input via stdin instead of via argc Does not include the SD-VBS matlab code. Fixes libextra execution in LITMUS^RT. --- SD-VBS/tools/preload.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 SD-VBS/tools/preload.c (limited to 'SD-VBS/tools/preload.c') diff --git a/SD-VBS/tools/preload.c b/SD-VBS/tools/preload.c new file mode 100644 index 0000000..24cf428 --- /dev/null +++ b/SD-VBS/tools/preload.c @@ -0,0 +1,70 @@ +#include "stdio.h" +#include "stdlib.h" +#include "unistd.h" +#include +#include +#include +#include + + +static void sig_int(int signo){ + return; +} +int main(int argc, char* argv[]){ + if(argc < 2){ + printf("Too few arguments!\n"); + exit(1); + } + int fd = open(argv[1], O_RDONLY); + if(fd < 0){ + printf("open failure\n"); + exit(1); + } + + struct stat st; + if(fstat(fd, &st) < 0){ + printf("stat error\n"); + exit(1); + } + int len = st.st_size; + printf("size = %d\n", len); + void* pmap; + pmap = mmap(0, len, PROT_READ,MAP_SHARED | MAP_POPULATE,fd, 0); + + printf("pmap = 0x%016x\n", pmap); + if(!pmap){ + printf("map error\n"); + close(fd); + exit(1); + } + + + for(int i = 0; i < len;i++){ + char c = ((char*)pmap)[i]; + } + printf("pinning pages...\n"); + if(mlock(pmap, len) == -1){ + printf("mlock error"); + close(fd); + exit(1); + } + + printf("done pinning...\n"); + + + + sigset_t set; + sigemptyset(&set); + sigaddset(&set,SIGINT); + int sig; + signal(SIGINT, sig_int); + sigwait(&set, &sig); + printf("unpinning pages...\n"); + + if(munlock(pmap, len) < 0){ + printf("munlock error\n"); + } + munmap(pmap, len); + close(fd); + return 0; +} -- cgit v1.2.2