When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
what's your question?
i need help to solve the cpu.c task
I just can't get it to calculate the value for SPIN_1SEC and then run the program with it
nobody is going to do the assignment for you
if you need help, ask a question that can be answered
what do you need help with?
with this
are there any errors? does the output not match what you expect?
yes, there is a output but not really what i expected
Anyone can ask a question in our programming channels. Following the guide Writing The Perfect Question is recommended.
State your problem clearly and provide all necessary details:
Provide the relevant code in the message, and format it nicely with a code block*. If it's too much for one message, you can upload it:
I can't get the SPIN_1SEC value right
The cpu is used for 1 sec and this time is measured in nanoseconds, I don't know how to calculate and save this value.
SPIN_1SEC describes how often your computer can increment the i variable within a second.
After 1 second has passed you inspect the value of i. You then repeat this a few times and take the average.
If you do not know how to precisely stop time - cause I sure as hell don't - then my approach would be to bruteforce the number.
I would bruteforce it via binary search over all integers (if unsigned int isn't sufficient then of all integers up to 1 << 40 or smth like that). If for a tested number of iterations the computer needs less than 1 second then you look at the bigger half and if it takes more than a second than you look at the lower half.
This question is being automatically marked as stale.
If your question has been answered, run !solved.
If your question is not answered feel free to bump the post or re-ask.
Take a look at !howto ask for tips on improving your question.