Wednesday, 5 December 2012

Worth Read #24

Q: The circle can rotate clockwise and back. Use minimum hardware to build
a circuit to indicate the direction of rotating. 
A: 2 sensors are required to find out the direction of rotating. They are placed like at the drawing. One of them is connected to the data input of D flip-flop, and the second one - to the clock input. If the circle rotates the way clock sensor sees the light first while D input (second sensor) is zero - the output of the flip-flop equals zero, and if D input sensor "fires" first - the output of the flip-flop becomes high, please go through the link frenz....

enjoy...

Worth Read #23

Critical Frequency (in terms of radio- electronics)

The critical frequency is an important figure that gives an indication of the state of the ionosphere and the resulting HF propagation. It is obtained by sending a signal pulse directly upwards. This is reflected back and can be received by a receiver on the same site as the transmitter. The pulse may be reflected back to earth, and the time measured to give an indication of the height of the layer. As the frequency is increased a point is reached where the signal will pass right through the layer, and on to the next one, or into outer space. The frequency at which this occurs is called the critical frequency.

The equipment used to measure the critical frequency is called an ionosonde. In many respects it resembles a small radar set, but for the HF bands. Using these sets a plot of the reflections against frequency can be generated. This will give an indication of the state of the ionosphere for that area of the world

Worth Read #22

main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("I love U");
else
printf("I hate U");
}

Answer:
I hate U

Explanation:
For floating point numbers (float, double, long double) the values cannot be predicted
exactly. Depending on the number of bytes, the precession with of the value represented varies. Float
takes 4 bytes and long double takes 10 bytes. So float stores 0.9 with less precision than long double.
Rule of Thumb:
Never compare or at-least be cautious when using floating point numbers with relational
operators (== , >, <, <=, >=,!= ) .

Worth Read #21


punter pointer! :D

main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}

Answer:
mmmm
aaaa
nnnn

Explanation:
s[i], *(i+s), *(s+i), i[s] are all different ways of expressing the same idea. Generally array
name is the base address for that array. Here s is the base address. i is the index number/displacement from
the base address. So, indirecting it with * is same as s[i]. i[s] may be surprising. But in the case of C it is
same as s[i].


Worth Read (and answer) #20

49 most important interview questions... 

1. What are static variables?
2. What are volatile variables?
3. What do you mean by const keyword ?
4. What is interrupt latency?
5. How you can optimize it?
6. What is size of character, integer, integer pointer, character pointer?
7. What is NULL pointer and what is its use?
8. What is void pointer and what is its use?
9. What is ISR?
10.What is return type of ISR?
11.Can we use any function inside ISR?
12.Can we use printf inside ISR?
13.Can we put breakpoint inside ISR?
14.How to decide whether given processor is using little endian format or big endian format ?
15.What is Top half & bottom half of a kernel?
16.Difference between RISC and CISC processor.
17.What is RTOS?
18.What is the difference between hard real-time and soft real-time OS?
19.What type of scheduling is there in RTOS?
20.What is priority inversion?
21.What is priority inheritance?
22.How many types of IPC mechanism you know?
23.What is semaphore?
24.What is spin lock?
25.What is difference between binary semaphore and mutex?
26.What is virtual memory?
27.What is kernel paging?
28.Can structures be passed to the functions by value?
29.Why cannot arrays be passed by values to functions?
30.Advantages and disadvantages of using macro and inline functions?
31.What happens when recursion functions are declared inline?
32.#define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives
preprocessor warning. Why?
33.Can you have constant volatile variable? Yes, you can have a volatile pointer?
34.++*ip increments what? it increments what ip points to
35.Operations involving unsigned and signed — unsigned will be converted to signed
36.malloc(sizeof(0)) will return — valid pointer
37.main() {fork();fork();fork();printf("hello world"); } — will print 8 times.
38.Array of pts to functions — void (*fptr[10])()
39.Which way of writing infinite loops is more efficient than others? there are 3ways.
40.Who to know whether system uses big endian or little endian format and how to convert
among them?
41.What is forward reference w.r.t. pointers in c?
42.How is generic list manipulation function written which accepts elements of any kind?
43.What is the difference between embedded systems and the system in which RTOS is running?
44.How can you define a structure with bit field members?
45.How do you write a function which takes 2 arguments - a byte and a field in the byte and
returns the value of the field in that byte?
46.Which parameters decide the size of data type for a processor ?
47.What is job of preprocessor, compiler, assembler and linker ?
48.What is the difference between static linking and dynamic linking ?
49.How to implement a WD timer in software ?

ENJOYYYYYYYYYYYYYY.................

Worth Read #19

Obscure syntax 

C allows some appalling constructs. Is this construct legal, and if so what does this code do? 

int a = 5, b = 7, c;
c = a+++b;
This question is intended to be a lighthearted end to the quiz, as, believe it or not, this is perfectly legal syntax. The question is how does the compiler treat it? Those poor compiler writers actually debated this issue, and came up with the "maximum munch" rule, which stipulates that the compiler should bite off as big (and legal) a chunk as it can. Hence, this code is treated as:

c = a++ + b;
Thus, after this code is executed, a = 6, b = 7, and c = 12.
If you knew the answer, or guessed correctly, well done. If you didn't know the answer then they wouldn't consider this to be a problem. they find the greatest benefit of this question is that it is good for stimulating questions on coding styles, the value of code reviews, and the benefits of using lint.

Enjoy :)

Worth Read #18

Typedef 
Typedef is frequently used in C to declare synonyms for pre-existing data types. It is also possible to use the preprocessor to do something similar. For instance, consider the following code fragment: 

#define dPS struct s *
typedef struct s * tPS;
The intent in both cases is to define dPS and tPS to be pointers to structure s. Which method, if any, is preferred and why?
This is a very subtle question, and anyone who gets it right (for the right reason) is to be congratulated or condemned ("get a life" springs to mind). The answer is the typedef is preferred. Consider the declarations:

dPS p1,p2;
tPS p3,p4;
The first expands to:

struct s * p1, p2;
which defines p1 to be a pointer to the structure and p2 to be an actual structure, which is probably not what you wanted. The second example correctly defines p3 and p4 to be pointers.

Worth Read #17

Dynamic memory allocation 

Although not as common as in non-embedded computers, embedded systems do still dynamically allocate memory from the heap. What are the problems with dynamic memory allocation in embedded systems? 
Here, I expect the user to mention memory fragmentation, problems with garbage collection, variable execution time, and so on. the question is,
What does the following code fragment output and why?

char *ptr;
if ((ptr = (char *)malloc(0)) == NULL)
else
puts("Got a null pointer");
puts("Got a valid pointer");

This is a fun question. I stumbled across this only recently when a colleague of mine inadvertently passed a value of 0 to malloc and got back a valid pointer! That is, the above code will output "Got a valid pointer." interviewer use this to start a discussion on whether the interviewee thinks this is the correct thing for the library routine to do. Getting the right answer here is not nearly as important as the way you approach the problem and the rationale for your decision.

Worth Read #16

the basic difference between CISC and RISC is, RISC has fixed machine cycles, and CISC, variable machine cycles to execute our asm codes. 

Worth Read #15

static RAM is faster than Dynamic RAM, hence it is used in Cache memory for faster CPU execution. 
read more about SRAM, DRAM and cache memory, it will help greatly...

Worth Read #14

C Preprocessor example: 
Using the #define statement, how would you declare a manifest constant that returns the number of seconds in a year? Disregard leap years in your answer. 

answer:
#define SECONDS_PER_YEAR
(60 * 60 * 24 * 365)UL

Interviewer is looking for several things here:
• Basic knowledge of the #define syntax (for example, no semi-colon at the end, the need to parenthesize, and so on)
• An understanding that the pre-processor will evaluate constant expressions for you. Thus, it is clearer, and penalty-free, to spell out how you are calculating the number of seconds in a year, rather than actually doing the calculation yourself
• A realization that the expression will overflow an integer argument on a 16-bit machine-hence the need for the L, telling the compiler to treat the variable as a Long
• As a bonus, if you modified the expression with a UL (indicating unsigned long), then you are off to a great start. And remember, first impressions count!

frenz, like this there are very minute but very important things about embedded c, which will decide your fate in interview, try getting more and more embedded c concepts in google

Worth Read #13

C Preprocessor example2: 
Write the "standard" MIN macro-that is, a macro that takes two arguments and returns the smaller of the two arguments.
#define MIN(A,B) ((A)<= (B) ? (A) : (B))

The purpose of this question is to test the following:
• Basic knowledge of the #define directive as used in macros. This is important because until the inline operator becomes part of standard C, macros are the only portable way of generating inline code. Inline code is often necessary in embedded systems in order to achieve the required performance level
• Knowledge of the ternary conditional operator. This operator exists in C because it allows the compiler to produce more optimal code than an if-then-else sequence. Given that performance is normally an issue in embedded systems, knowledge and use of this construct is important
• Understanding of the need to very carefully parenthesize arguments to macros
• I also use this question to start a discussion on the side effects of macros, for example, what happens when you write code such as:
least = MIN(*p++, b);

Worth Read #12

In ECL (emittor coupled logic) transistor never goes into saturation coz it has CML (current mode logic) with negative voltage.
advantages: 1.noise free
2. high speed(400MHz)
3. clock tree generation logic
disadvantages:1.more power consumption

Worth Read #11

Timing hazards occurs when a variable and a its complement is driven to a gate. 
since lack of equal propagation delays the circuit results in timing hazards.
Timing Analysis is hence very important aspect in every design. 

Worth Read #10

There are 4 storage classws in C,
1.auto
2.static
3.volatile
4.extern
please know about what all these actually mean, in every interview u can anticipate questions on these basic concepts

Worth Read #9

(before reading this, plz try to know what is static keyword in C, plz try HONESTLY)

What are the uses of the keyword static? 
This simple question is rarely answered completely. Static has three distinct uses in C: 
• A variable declared static within the body of a function maintains its value between function invocations
• A variable declared static within a module, (but outside the body of a function) is accessible by all functions within that module. It is not accessible by functions within any other module. That is, it is a localized global
• Functions declared static within a module may only be called by other functions within that module. That is, the scope of the function is localized to the module within which it is declared
Most candidates get the first part correct. A reasonable number get the second part correct, while a pitiful number understand the third answer. This is a serious weakness in a candidate, since he obviously doesn't understand the importance and benefits of localizing the scope of both data and code.

so frenz, try to get in depth knowledge of each and every small aspect...

Worth Read #8


clock stretching
During master-slave interaction, if the slave is busy with other activity, master has to be informed to wait, that is,
If a slave cant receive or transmit another complete byte of data until it performs its activity, it holds the SCL(serial clock line) low to force the master into wait state, this phenomenon is called "clock stretching".
Data transfer continues when the slave is ready for another byte of data and releases the SCL line.

Worth Read #7


Property of gray code:
for every increment or decrement, only one bit changes, e.g; 0000, 0001.
This property of gray code makes it suitable for counters and many other sequential circuits, as this sequence involves 1-bit change, it reduces metastability, the condition in which system cant be able to decide whether a value is 1 or 0.
Metastability occurs due to set up or hold time violations in the clocked circuits, while a value of a bit changes, and, at the same time clock is sensing that data.

frenz, google with the word- gray code, metastabiity, set up time, hold time, set up and hold time violation and get clear picture of what i meant to convey, because, THIS IS VERY IMPORTANT!!!

Worth Read #6

What does the keyword const mean? 

As soon as the interviewee says "const means constant," I know I'm dealing with an Every reader of ESP(embedded system programming) should be extremely familiar with what const can and cannot do for you. If you haven't been reading that column, suffice it to say that const means "read-only." Although this answer doesn't really do the subject justice, interviewer may accept it as a correct answer. 
If the candidate gets the answer correct, they'll ask him these supplemental questions: 
What do the following declarations mean?

const int a;
int const a;
const int *a;
int * const a;
int const * a const;

The first two mean the same thing, namely a is a const (read-only) integer. The third means a is a pointer to a const integer (that is, the integer isn't modifiable, but the pointer is). The fourth declares a to be a const pointer to an integer (that is, the integer pointed to by a is modifiable, but the pointer is not). The final declaration declares a to be a const pointer to a const integer (that is, neither the integer pointed to by a, nor the pointer itself may be modified). If the candidate correctly answers these questions, interviewer will be impressed. Incidentally, you might wonder why I put so much emphasis on const, since it is easy to write a correctly functioning program without ever using it. I have several reasons:
• The use of const conveys some very useful information to someone reading your code. In effect, declaring a parameter const tells the user about its intended usage. If you spend a lot of time cleaning up the mess left by other people, you'll quickly learn to appreciate this extra piece of information. (Of course, programmers who use const , rarely leave a mess for others to clean up.)
• const has the potential for generating tighter code by giving the optimizer some additional information
• Code that uses const liberally is inherently protected by the compiler against inadvertent coding constructs that result in parameters being changed that should not be. In short, they tend to have fewer bugs.

make sense frenz? plz come to a level that u too are in a level to think like what interviewer is asking, u can increase your competency by working practically n thinking more about C constructs in depth. Its tough but to be an ESP, u must be like that, coz, its not easy...

Worth Read #6

Volatile 
What does the keyword volatile mean? Give three different examples of its use. 

A volatile variable is one that can change unexpectedly. Consequently, the compiler can make no assumptions about the value of the variable. In particular, the optimizer must be careful to reload the variable every time it is used instead of holding a copy in a register. Examples of volatile variables are: 
• Hardware registers in peripherals (for example, status registers)
• Non-automatic variables referenced within an interrupt service routine
• Variables shared by multiple tasks in a multi-threaded application

Candidates who don't know the answer to this question aren't hired!!!... I consider this the most fundamental question that distinguishes between a C programmer and an embedded systems programmer. Embedded folks deal with hardware, interrupts, RTOSes, and the like. All of these require volatile variables. Failure to understand the concept of volatile will lead to disaster.
On the (dubious) assumption that the interviewee gets this question correct, I like to probe a little deeper to see if they really understand the full significance of volatile . In particular, i'll ask you the following additional questions:
• Can a parameter be both const and volatile ? Explain.
• Can a pointer be volatile ? Explain.
• What's wrong with the following function?:

int square(volatile int *ptr)
{
return *ptr * *ptr;
}
The answers are as follows:
• Yes. An example is a read-only status register. It is volatile because it can change unexpectedly. It is const because the program should not attempt to modify it
• Yes, although this is not very common. An example is when an interrupt service routine modifies a pointer to a buffer
• This one is wicked. The intent of the code is to return the square of the value pointed to by *ptr . However, since *ptr points to a volatile parameter, the compiler will generate code that looks something like this:

int square(volatile int *ptr)
{
int a,b;
a = *ptr;
b = *ptr;
return a * b;
}
Because it's possible for the value of *ptr to change unexpectedly, it is possible for a and b to be different. Consequently, this code could return a number that is not a square! The correct way to code this is:

long square(volatile int *ptr)
{
int a;
a = *ptr;
return a * a;
}

Frenz... look at a small variable- volatile, in this one they can ask this much depth, so u shd be in the position to answer like how i mentioned in the answers, so know which level u r and raise to the level a company expects you to be, its tough but u can do it!!!

Enjoy :)

Worth Read #5

Bit manipulation 
Embedded systems always require the user to manipulate bits in registers or variables. Given an integer variable a, write two code fragments. The first should set bit 3 of a. The second should clear bit 3 of a. In both cases, the remaining bits should be unmodified. 
These are the three basic responses to this question: 
• No idea. The interviewee cannot have done any embedded systems work 
• Use bit fields. Bit fields are right up there with trigraphs as the most brain-dead portion of C. Bit fields are inherently non-portable across compilers, and as such guarantee that your code is not reusable.
• Use #defines and bit masks. This is a highly portable method and is the one that should be used. My optimal solution to this problem would be:

#define BIT3 (0x1 << 3)
static int a;
void set_bit3(void) {
a |= BIT3;
}
void clear_bit3(void) {
a &= ~BIT3;
}
Some people prefer to define a mask together with manifest constants for the set and clear values. This is also acceptable. The element that I'm looking for is the use of manifest constants, together with the |= and &= ~ constructs

this is very simple info I've given, but this simple question itself is sufficient for judging whether u r an embedded guy or not anta... so, think of it...

Enjoy...

Worth Read #4

Accessing fixed memory locations 
Embedded systems are often characterized by requiring the programmer to access a specific memory location. On a certain project it is required to set an integer variable at the absolute address 0x67a9 to the value 0xaa55. The compiler is a pure ANSI compiler. Write code to accomplish this task. 
This problem tests whether you know that it is legal to typecast an integer to a pointer in order to access an absolute location. The exact syntax varies depending upon one's style. However, I would typically be looking for something like this: 

int *ptr;
ptr = (int *)0x67a9;
*ptr = 0xaa55;
A more obscure approach is:

*(int * const)(0x67a9) = 0xaa55;
Even if your taste runs more to the second solution, I suggest the first solution when you are in an interview situation.

Worth Read #3

Interrupts (MOST IMPORTANT)

Interrupts are an important part of embedded systems. Consequently, many compiler vendors offer an extension to standard C to support interrupts. Typically, this new keyword is __interrupt. The following code uses __interrupt to define an interrupt service routine (ISR). Comment on the code. 

__interrupt double compute_area (double radius)
{
double area = PI * radius *
radius;
printf("\nArea = %f", area);
return area;
}
This function has so much wrong with it, it's hard to know where to start:
• ISRs cannot return a value. If you don't understand this, you aren't hired
• ISRs cannot be passed parameters. See the first item for your employment prospects if you missed this
• On many processors/compilers, floating-point operations are not necessarily re-entrant. In some cases one needs to stack additional registers. In other cases, one simply cannot do floating point in an ISR. Furthermore, given that a general rule of thumb is that ISRs should be short and sweet, one wonders about the wisdom of doing floating-point math here
• In a vein similar to the third point, printf() often has problems with reentrancy and performance. If you missed points three and four, I wouldn't be too hard on you. Needless to say, if you got these last two points, your employment prospects are looking better and better

Worth Read #2

worth read:
Code example
What does the following code output and why? 

void foo(void)

{
unsigned int a = 6;
int b = -20;
(a+b > 6) ? puts("> 6") :
puts("<= 6");
}
This question tests whether you understand the integer promotion rules in C-an area that I find is very poorly understood by many developers. Anyway, the answer is that this outputs "> 6." The reason for this is that expressions involving signed and unsigned types have all operands promoted to unsigned types. Thus ý20 becomes a very large positive integer and the expression evaluates to greater than 6. This is a very important point in embedded systems where unsigned data types should be used frequently (see Reference 2). If you get this one wrong, you are perilously close to not getting the job.

Worth Read #1


Comment on the following code fragment. 

unsigned int zero = 0;
unsigned int compzero = 0xFFFF; 
/*1's complement of zero */
On machines where an int is not 16 bits, this will be incorrect. It should be coded:

unsigned int compzero = ~0;
This question really gets to whether the candidate understands the importance of word length on a computer. In my experience, good embedded programmers are critically aware of the underlying hardware and its limitations, whereas computer programmers tend to dismiss the hardware as a necessary annoyance.
By this stage, candidates are either completely demoralized-or they're on a roll and having a good time. If it's obvious that the candidate isn't very good, then the test is terminated at this point. However, if the candidate is doing well, then interviewer throw in these supplemental questions. These questions are hard, and interviewer expects that only the very best candidates will do well on them. In posing these questions, I'm looking more at the way the candidate tackles the problems, rather than the answers. Anyway, have fun...

enjoy...

Saturday, 16 June 2012

                                                                हम है राही प्यार के 
                                                                फिर मिलेंगे चलते चलते ।

Monday, 28 May 2012

childhood

बार बार आती है मुझको 
मधुर याद बचपन तेरी 
गया ले गया तू जीवन की 
सब से मस्त ख़ुशी मेरी 

Sunday, 27 May 2012

sunrise in my village...


I am waiting for you, in the dark with blind hopes in life like earth waits for the sun rise... waiting for your arrival as sun who splashes the sky with new hopes for a bright start with fresh cool breeze in the chorus of singing birds, to start new life as dawn in my lost life...

vijayanagara empire traces

my village, historical village- eklaspur in the outskirts of raichur, the doab city... the pillar behind is the demolished monument which is used for signalling lomg haul distances if any emergency condition emerges, they used to light up at the tip of the long tower for the main fort... this has been built during golden era of Vijayanagara kingdom, at that times golden ornaments used to sold all along the foot path!!! in terms of kilograms!!!