0
$\begingroup$

I'm using a Raspberry Pi 2 which works with 900MHz. (Asked this question there and they think it belongs to cs)

My question is: since it also runs an operating system in the background, I expect this would take some of the processing power.

So, how significant is the speed reduction due to operating systems? If I run a single code for example, what execution speed should I expect on average? Is it still close to 900MHz, or is it significantly lower?

Furthermore, is there a specific operating system or programming language that I can use to make it run faster?

$\endgroup$
  • 1
    $\begingroup$ Your "code" doesn't run at "900MHz" or anything near that value. There are many factors beyond the processor's clock speed that determine the speed of execution of a piece of code. Asking to quantify execution speed in terms of MHz's doesn't make any sense whatsoever. $\endgroup$ – Tom van der Zanden Oct 19 '15 at 17:04
  • 2
    $\begingroup$ This doesn't feel like a computer science question to me: the answer depends completely on what operating system you're talking about and what the program does. The only way to tell is to benchmark the alternatives. Community opinions? (Sorry to bounce you around, OE1. I know how much it sucks when you post a question somewhere, they say "Post it at X instead" and the people at X start suggesting it's off-topic.) $\endgroup$ – David Richerby Oct 19 '15 at 17:08
  • $\begingroup$ @TomvanderZanden It actually make sense if you do not take it literally. Since operating frequency is proportional with execution speed, there is a relation whether you know it exactly or not. Im aware it depends on the code since execution lines take few periods, however there also is an average. So thats what I am after, I honestly do not think I have to break it down to pieces, what I am asking is clear. You can add a conceptual appendix if you think its necessary, along with the answer if you have one. If you dont have one, well, thanks anyway. $\endgroup$ – ozgeneral Oct 19 '15 at 17:42
  • $\begingroup$ @DavidRicherby Yeah it actually sucks quite a lot :) its still on hold so I'm not sure about the community yet. By the way, I'm just after an order of magnitude. Surely; A operating system takes %30 of the processing power, B takes %60 but has many cool features etc it obviously varies. But I might be overestimating its effect it or it could be even more. I'm just trying to estimate the average because I want to make a real time image processing application and I do not even know if I have a shot with 900MHz, and with operating system it might be even slower... $\endgroup$ – ozgeneral Oct 19 '15 at 17:51
5
$\begingroup$

This question doesn't have a straight forward answer, or rather the answer is very case dependent. (And as some of the comments pointed out, attempting to qualify this as MHz is meaningless, your CPU will run at the same speed regardless {not counting power optimizations}, it's just a case of who's code it's running, yours or the OS's).

An operating system does many things for you so your simple code that does a couple of I/O operations wouldn't be as simple without calls to the operating system. To take the OS out of the equation, you'd have to write more code to replace device driver functionality. Your OS is doing a LOT of work just to accept that letter "A" you typed and display it on a screen.

If your I/O is to a file system, you'd have to write code to replace the file system code provided for you by the OS.

If you expect multiple tasks to run simultaneously or do multithreading, you'll also have to write code to replace the scheduling functionality.

If you allocate and deallocate memory, you'd have to write code to perform those functions.

If you want your program to be notified when an event occurs or keep time or any of a number of other functions, you'll have to supply all that code as well. And that's just PART of what an Operating System is doing.

You also have to consider that all that OS code that you're taking advantage of has been optimized and debugged for you. You're likely to write replacement code that is buggier and slower than the OS code you're replacing.

Then once you've got all that written, you'll have to figure out how to load the program into memory and start execution...

That said, there definitely IS overhead involved in using an operating system. Most OS's are built for a general use case and will have many features and functions that you don't need for your specific program. But most of us are willing to give up a few % of CPU and memory in order to get the convenience that an OS will bring.

As for which OS will make it go faster... again it depends on your application and needs. Some OS's will definitely run some applications faster than others, but which OS runs faster depends on the features being used.

And there are reasons other than speed to choose one over another. Application availability, security, interoperability, device compatibility, availability of programming tools, etc. are all factors to consider.

$\endgroup$
  • $\begingroup$ Welcome! This is one of the best, most detailed "Your question has no answer" answers I've seen. :-) $\endgroup$ – David Richerby Oct 19 '15 at 19:58
  • $\begingroup$ Thanks. I thought it deserved a response even though there isn't a direct answer to the question. $\endgroup$ – Brian Hibbert Oct 19 '15 at 20:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.