Bas
Bas

Reputation: 467

how to find if the kernel being used is real time or not

I have patched a linux kernel 3.2 with a rt patch and have then installed it. Now in the GRUB menu I am able to select the kernel and it also contains the suffix -rt. But I am still not sure if it actually has real time capabilities. Is there a way to find out if it is a real time kernel or an ordinary vanilla kernel? Further according to an example in rtwiki, which informs whether we are using a vanilla or a rt preempt kernel.

#include <string.h>
#include <stdio.h>
#include <sys/utsname.h>
int main(int argc, char **argv)
{
struct utsname u;
int crit1, crit2 = 0;
FILE *fd;
uname(&u);
crit1 = strcasestr (u.version, "PREEMPT RT");
if ((fd = fopen("/sys/kernel/realtime","r")) != NULL) {
int flag;
crit2 = ((fscanf(fd, "%d", &flag) == 1) && (flag == 1));
fclose(fd);
}
fprintf(stderr, "this is a %s kernel\n",
(crit1 && crit2) ? "PREEMPT RT" : "vanilla");
}

This code access's a file named realtime from sys/kernel, but no such file was created when i patched my kernel with an rt patch.

Upvotes: 0

Views: 9237

Answers (1)

brokenfoot
brokenfoot

Reputation: 11609

Presence of real time scheduler and various other dependent kernel option is what makes a kernel real time. If this is the default scheduler selected in the source, then it is real time. You can put some printfs in the source to check whether that code is getting executed and check using dmesg.

You need to debug the kernel using kgdb or other debug tools to see why you are getting errors.

Upvotes: 0

Related Questions