Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6941923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:56:54+00:00 2026-05-27T12:56:54+00:00

Is there an equivalent api like getloadavg() that can be used within the kernel

  • 0

Is there an equivalent api like getloadavg() that can be used within the kernel i.e. for my own driver ?

I have a driver that is thrashing and I would like to throttle it, and i am looking for a kernel-api to find about the cpu usage.

Thank you.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:56:54+00:00Added an answer on May 27, 2026 at 12:56 pm

    You’re probably looking for the get_avenrun() function in kernel/sched.c. An example of how to use it is in fs/proc/loadavg.c:

    static int loadavg_proc_show(struct seq_file *m, void *v)
    {
            unsigned long avnrun[3];
    
            get_avenrun(avnrun, FIXED_1/200, 0); 
    
            seq_printf(m, "%lu.%02lu %lu.%02lu %lu.%02lu %ld/%d %d\n",
                    LOAD_INT(avnrun[0]), LOAD_FRAC(avnrun[0]),
                    LOAD_INT(avnrun[1]), LOAD_FRAC(avnrun[1]),
                    LOAD_INT(avnrun[2]), LOAD_FRAC(avnrun[2]),
                    nr_running(), nr_threads,
                    task_active_pid_ns(current)->last_pid);
            return 0;
    }
    

    Though I’m a little skeptical of how you can use the load average to modify a driver — the load average is best treated as a heuristic for system administrators to gauge how their system changes over time, not necessarily how “healthy” it might be at any given moment — what specifically in the driver is causing troubles? There’s probably a better mechanism to make it play nicely with the rest of the system.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there equivalent to \Q ... \E in C# Regex? I can't find it.
Is there an equivalent of the OS X Keychain, used to store user passwords,
I see that as of API Level 8, you can request a handle to
I would like to have SIGCHLD functionality on Windows (i.e., notify the parent process
I would like to have SIGCHLD functionality on Windows (i.e., notify the parent process
Is there a Nt or similar (i.e. non-kernelmode-driver) function equivalent for KeQueryInterruptTime or anything
I'm learning the Android api from a book, and it seems like there isn't
I have a carbon C++ application and I would like to programmatically do the
I used Google API version 2 in my previous assignment. There I had used
Possible Duplicate: Graph api and equivalent FQL method give different results? I'd like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.