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 7085383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:25:04+00:00 2026-05-28T07:25:04+00:00

Possible Duplicate: Simulate steady CPU load and spikes I need to write an application

  • 0

Possible Duplicate:
Simulate steady CPU load and spikes

I need to write an application that can simulate high cpu-usage at a pre-set values ( e.g., 30%, 50%, 90% etc) for a certain duration. Meaning it will take two inputs (CPUUsage and duration). Let say i use 50% for CPU-Usage and 2 minutes for Duration). This mean that when I run the application, it should take 50% CPU for 2 minutes. Any ideas how this can be achieved?

  • 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-28T07:25:05+00:00Added an answer on May 28, 2026 at 7:25 am

    You will need to write a spin loop to keep the processor busy for the amount of time desired. Sleep(n) won’t work because while it keeps your thread busy it allows the CPU to do something else.

    Use a thread-based timer (not a message based timer) to schedule regular execution of your load simulator function, say, every 10 seconds. In that function, run your spin loop (a for loop that increments a local variable) until the desired load time (% of 10 seconds) is reached, then exit the function. The timer will call you again in (about) 10 seconds to chew up another timeslice. So, for 30% load, your spin loop should churn for 3 seconds out of each 10 second interval.

    You should also consider the number of executable cores that are present in your system. On a quad core hyperthreaded Intel processor, you should create 8 threads and run your load simulator in each thread.

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

Sidebar

Related Questions

Possible Duplicate: How can I simulate OO-style polymorphism in C? I am newbie to
Possible Duplicate: How can I simulate OO-style polymorphism in C? I'm trying to better
Possible Duplicate: Can you write object oriented code in C? Hi, can someone point
Possible Duplicate: How can I simulate an anchor click via jquery? For some reason
Possible Duplicate: Pre & post increment operator behavior in C, C++, Java, & C#
Possible Duplicate: How can I combine multiple rows into a comma-delimited list in Oracle?
Possible Duplicate: Learning to write a compiler I looked around trying to find out
Possible Duplicate: Can you call Directory.GetFiles() with multiple filters? Does it possible to get
Possible Duplicate: Filetype association with application (C#) I'm writing a C# Windows app to
Possible Duplicate: What is 0x10 in decimal? I notice that Console.WriteLine(18); writes 18, but

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.