Write a program to report behaviour of Linux kernel including information on 19 configured memory, amount of free and used memory. (memory information)

by

Last updated on Nov 4, 2022
Operating System Practicals (Question 3)

Input

#include<stdio.h>
#include<sys/sysinfo.h>
#include<stdlib.h>
#include<sys/utsname.h>
using namespace std;

int main()
{
    int p = 0 , q = 0;
    struct sysinfo un;
    p = sysinfo(&un);
    
    struct utsname s1;
    
    q = uname(&s1);

    
    if(p==0 && q==0)
    {
        printf("\n Kerner version : %s", s1.version);
    


        printf("\n Total RAM : %ld MB \n", (un.totalram));
        printf("\n Free RAM : %ld MB \n", (un.freeram));
        printf("\n Used RAM : %ld MB \n", (un.totalram-un.freeram));

    }
    
    else
    {
        printf("Error");
    }	
    
    return 0;
}

How useful was this post?

5 star mean very useful & 1 star means not useful at all.

Average rating 4.5 / 5. Vote count: 2

No votes so far! Be the first to rate this post.