August 20, 2009

Throughput funda's

I have been quite inconsistent in updating the information presented on this blog. The one things that discourages me like any other new blogger is that very little traffic is seen here and since this is a technical blog, unless i get feedback it is difficult for me to judge if something is good or bad. However, for now i have considered that no feedback is negative feedback. Nevertheless i continue to write.
What is Throughput...This is the weeks question.
Wordweb tells me
Output relative to input; the amount passing through a system from input to output (especially of a computer program over a period of time)

The Throughput that i am talking is the one that embedded engineers often talk about. In simple terms this value is a measure of the CPU load under the worst conditions. What could be the worst conditions? These are basically situations which demand more processing power. For example, Image Stabilization, Red Eye Detection, Smile Detection, Ambient light detection along with Click detection or auto timer ( and image post processing) in a Camera perhaps put a great deal of performance demands on the CPU in a Digital camera and this also determines it worst case performance.
Unfortunately like many other engineering terms a higher value of throughput means that your system is more loaded. Often under some conditions the throughput reaches 100% in systems which means the CPU has almost no idle time and is being utilized all the time to its maximum capacity.
If i look at it from an EMS perspective then startup is the when there is very high CPU loads that are encountered. In an OS based system there are methods to determine for how much time the CPU is free. Usually, some background tasks which are not necessary to be done all the time are done in this free time. ( Example, CRC calculation or RAM Checks etc). In simple scheduler based systems the throughput is just the time remaining in the baseloop after all the tasks have been finished. One more parameter that influences the throughput to a great extent is the Interrupt Rate. A very high interrupt rate will ensure that the CPU loses a lot of time in context switches which are really an overhead and do not contribute in anyway to the functionality of the system.
[ This was my understanding of Throughput. After looking into wiki i think the origin of is term comes from the CPU bandwidth utilization. The term is primarily used for parametrization of Communication channel bandwidths]

How Do we ensure that we never reach 100% throughput?
  • Plan your interrupts and their sources well. You should know the worst case rate of an interrupt beforehand. Example, the Door lock engage interrupt cannot come at say more than 1-2 times a second ( Due to the inertia of the lock).
  • Write your code with throughput in mind. E.g if possible use binary search in place of linear search. Use macros instead of functions judiciously
  • Overuns should be detected in software using some special variables or debug variables. Over-Runs occurs when the throughput goes more than 100%. Which means that you have asked the CPU to more than it is capable of handling in the given time. 
This is very brief and windowed perspective of Throughput. If you have some other inputs as to how this is related to your domain then do put a few lines of comments.
 Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.












Powered by ScribeFire.

July 25, 2009

The IDE and The Compiler

This is a very basic article. I would say for newbie's or for those who are misguided. Also, I was asked this question by some one recently. The question or rather statement "Tourbo C is a nice compiler for it has a very nice gui. Gcc gui is not good."

Well the problem here is that we are getting confused with the compiler and the IDE (Integrated Development Environment). The compiler is usually a parser ( Text paser for simplicity) that runs through a text file ( which we typically name with extensions like .c, .h etc) and feed it to this parser. The job of the parser ( or compiler hence forth) is to parse the file and output another file based on certain rules which should be adhered to by the writer of the text ( or code henceforth ). The other file that is usually output is object file. Note that as intermediate step the compiler generates assembly code which usally not output ( unless you tell the compiler to show you this specifically by a commandline option -S for gcc) . The object code which can be linked to form the executable. COFF & ELF are common object file formats, however compiler writers are free to choose what the want.

Now coming to the IDE. IDE has really got nothing to do with your compiler. The key words are explained here
Integrated: Usually every compiler vendor comes up with his/her own Editor to help the coder to write his code. Why a specific editor? Typically, each compiler provides it own set of special key words etc which the editor can highlight is specific colors and other features like codesense are provided for the ease of the coder.
Development : Yeah! we all write code to do something or develop something
Environment : This is the key term. The IDE provides an environment for the coder where he doesn't need to know the intricacies of compiler and more low level details of how to use it. You can can just take the IDE and start writing your code without bothering about what are the command line arguments that need to be passed to compiler. Also, you need not worry about feeding the include paths etc ( not all IDE's have this feature).

Now i try to defend gcc. I have used gcc with two ( or three??) IDE's and it works great. The simple ones are dev-ccp & code::Blocks. The difficult ones are actually extinct now....codewright.  Note that the best part about gcc is that it is a single compiler that will allow you to compiler with a whole lot of customizations through the command line arguments. I remember a project where i was using gcc only for creating dependency files which used to get fed to a embedded compiler which unfortunately did not have the capability to make dependency files ( Folks at my previous firm will know about this!!).
Why we need dependency file will be explained in another post soon.  Bis dan.....
 Please leave your comment. You can subscribe to this blog by using the links under "Subscribe" section.




Powered by ScribeFire.