My interview at Mentor Graphics

Mentor Graphics  is a US based multinational company that deals with electronic design and electrical and hardware based software  related services. I was recently called for interview in its Lahore office after being short listed. It was a technical interview and for job related to Embedded system so most of the questions were about either embedded systems or C language and hardware.hh
Their email described following things


You will be assessed as per following criteria:
  1.  Good programming experience in C and or/Java
  2. Good understanding of hardware Architecture (x86, ARM or MIPS) and Operating Systems Concepts 
  3. Hands-on experience with either of following embedded development environment would be a plus – Keil, RealView MDK, IAR Embedded Workbench, Code Composer Studio, Sourcery Codebench

Following are some questions and answers asked form me by interviewer.



  1. What is Cache memory?
    It is a faster type of memory used in computers while CPU is processing. So contents of memory is first fetched in this memory so that future requests can be served faster.
  2. What is its difference with other memories? Why don't we use RAM as its faster too.
    Cache is much faster than RAM and its is used to make the process fast. It is much costly than other memories. RAM is primary memory and different from RAM.
  3. What are Registers in Embedded systems?
    Registers are type of memory that is used to hold the contents that are going to use in processor. They may hold instructions, variables and things like that.So if CPU wanted to add two numbers, instructions will be first loaded into registers and then given to CPU.
  4. How many registers are there in ARM Cortex M3?
    It has 12 general purpose registers out of which 6 are called low level and other 6 are called high level. Than 4 Control registers PC, LR, SP and . Then two Special purpose registers like Program status register.
  5. Suppose we have a 32 bit register whose first and second bit are used to on and off UART. So if bit 8 is 1,Tx channel is on and if  10 bit is 1, Rx is on. How will you do it?
    By and ORing that with a number. So to set bit 8, we will and that register as follows.
    UART_Reg |=h0000100; // for 8th bit
    UART_Reg |=h0000400; // for 10th bit
  6. How can you do in same instruction?
     UART_Reg |=h0000500; // for 8th and 10 bit
  7. Suppose we have a 32 bit register showing status of a 32 interrupts of 32 ADC channels. Now Suppose a battery is connected at an xth channel. Write a efficient C program that can detect channel Number and return it.
    1. int ChannelFinder(int INT_Reg)
    2. {
    3.     int ch_No,i,temp;
    4.     temp=INT_Reg;
    5.     for(i=0;i<=31;i++)
    6.         {
    7.           temp>>i;
    8.           if(temp==1)
    9.             {
    10.             ch_No=i;
    11.             break;
    12.             }  
    13.            
    14.         }
    15.         return ch_No;
    16. }

  8. Now suppose that more than on interrupts are occurring . Also in the if condition call another routine that will call ISR with Ch_No. Calling this routine will also clear previous Interrupt.
    1. int ChannelFinder(int INT_Reg)
    2. {
    3.     int ch_No,i,temp;
    4.     temp=INT_Reg;
    5.     for(i=0;i<=31;i++)
    6.         {
    7.           temp>>i;
    8.           temp |=1;
    9.           if(temp==1)
    10.             {
    11.             ch_No=i;
    12.            ISR_funct(ch_No);
    13.             break;
    14.             }  
    15.            
    16.         }
    17.        
    18. }
9. This program is checking for interrupt even if there is no interrupt, change it in such a way that it only checks when there is  some interrupt?
  1. int ChannelFinder(int INT_Reg)
  2. {
  3.     int ch_No,i,temp;
  4.     temp=INT_Reg;
  5. if(INT_Reg>=1)
  6. {
  7.     for(i=0;i<=31;i++)
  8.         {
  9.           temp>>i;
  10.           temp |=1;
  11.           if(temp==1)
  12.             {
  13.             ch_No=i;
  14.            ISR_funct(ch_No);
  15.             break;
  16.             }  
  17.            
  18.         }
  19. }
  20. else
  21. break;
  22.        
  23. }
 
  10. See following program

         const int x=9;
        What will happen if i tried to change value of x?
         It will give and error.

   11. Now see this
            int *p;
         p=&x;
        *p=10;
       What will happen in this case?
      Again same error.

   12. What will be output of following?
      
  1.       int *p;
  2.       sizeof(p);
  3.       double *p1;
  4.       sizeof(p1);
      Both pointer will have size of 4 bytes as size of addresses in 32      bit machine is 4 bytes.

  13. If both have same sizes, why can't we use int type pointer for        double type?
     'cause a double type pointer is pointing a double and int type is        pointing int. [Not sure]

  14. How you configured timer in your project?
       In data sheet of the controller, sequence to set bits of relevant          register were given. There were  some parameters like                      overflow  value etc were to be set to start that timer. 
       That registers   were set and it was configured.

  15. How you used timer?
      Timer was used to produce delays and also to sample data at             regular intervals. So We used Sys Tick timer which is 24                   bit timer. We used 80Mhz clock. It was count up timer. Each bit       was count  up after the delay of (1/80M)s so routine was                   made to produce of specific intervals.

 16. What if you can't set value of a timer and you have to produce          some specific interval?
       Then we can set it Reload value. So every time overflow                  occurs,      it will reload with a value relevant     to our delay.

17. Following is a c Code
     
  1. struct A{
  2.      int var1;
  3.      int *p1;
  4.      int *p2
  5.      };
     How can i declare array of struct A type?
     struct A a1[4]; [He was suspicious about this, he said it will be       then struct of struct, I think he was confused with Cpp]

 18. Now what will happen if i do following a1++?
       [I was confused here, We had argument. He tried to convince           me something may be he was  trying to trap me.                               Unfortunately, I got into trap and I think answered wrong ]
      It will be a compiler error.

 19. What is pipeline in MCU's?
      It is a concept that while one instruction is being loaded, other         will also be loaded to save time.  He asked another                           question but  I said that I dont know deep about this so...

  20. What is const int *p and int int const *p who will be constant           in these?
      It is a famous question in interviews of C. It can be found here.
      http://stackoverflow.com/questions/1143262/what-is-the-                 difference-between-const-int-const-int-    const-and-int-const

21. By what steps program is compiled? [He asked it differently but       I don't remember exact words]
    http://stackoverflow.com/questions/3996651/what-is-compiler-linker-loader

21. What is difference between big endian and little endian?
       Both are ways of storing memory. In little endian, LSB is                  stored in smaller address place and MSB is placed in higher              address places. Vice versa is true in other.

22. Suppose we have a system, a black box, we don't know                     anything about it. How can you know weather its big endian or       little endian?
     We can write a simple program as following
            char var=1;
     int c;
     c=(int) var;
     As we know int is a 4 byte and char is one byte. Now when type     casted, c will have 4 bytes. So if it will be equal to 1 it means      little endian other wise big endian.

23.What is interrupt and what happens when it occurs?
   An interrupt is blockage in flow of main program. I told him               whole process of interrupts what  I          have read in ARM       with all the details.

24. So how NVIC know ISR address.
   I told him that it IPSR register where interrupt number is loaded      form NVIC. All the ISR's are            stored in a memory address       from 0 to top. So after this PC loads that specific  interrupt. But        he was    not convinced.

25. Following is a program
  
  1.  if( Unknown Condition )
  2.       {
  3.      printf("Hellow");
  4.               }
  5.   else
  6.    printf("World");
 how to print Hellow world? What should we write in If condition.

We can write  ~(printf("Hellow")). As return type of printf is number of bytes being printed. So what if condition will be false but print function will print Hellow and then it will go to else and will print World.

  1.  if( ~(printf("Hellow")) )
  2.       {
  3.      printf("Hellow");
  4.               }
  5.   else
  6.    printf("World");

26. Suppose data of an automotive is stored in location like following
 Now suppose at location 0-3 car reg number is stored, on 4-9 something else is saved and so on and so far. Write a C program that takes starting bit, and size and extracts all of them and returns.


  1. int Extractor(int start, int size)
  2. {
  3.     int i,cutter=0;
  4.     int *adres;
  5.     adress=start/32;
  6.    
  7.     for (i=start;i<=size;i=2*i)
  8.     {
  9.         cutter=cutter+i;
  10.     }
  11.    
  12.     return ((*p)&cutter);
  13. }

[I was a bit wrong in this. I told him right algorithm but I was failed to produce right c code for cutter]


27. Suppose a MCU has only 12 registers while a C program is using 20 variables in it. All of them at once. How registers will manage it?

Register are only there to speed up the process of CPU by providing immediate data. In fact these variables are stored in memory. One other way is pushing and then poping when required in stack. 

It was very interesting interview. I imagined it as two nerds discussing most nerdy things. We argued a lot of time during interview. Overall it was best experience.  

3 comments:

  1. I probably shouldn't be saying this here in public honestly, but let me introduce everyone to this experience genuine hacker. He is a professional and the best of hacking any iOS device & iCloud ID, Androids device & Google ID, Mac Book PC, and all Window system. He is called "Hacker Kaspersky" I have used his service and confirm how ethical standard he can handles social network Applications, He help hack my spouse phone, As my phone was linked with access to interact with target device as a remote operator. I can monitor my spouse iPhone11pro, Location, Facebook, Messenger, Instagram, WhatsApp, Hangout chats, Call logs and Notifications. Reach out to him for help via Email: (hackerkasperskytech@gmail.com) Tell him I refer you.

    ReplyDelete
  2. I will suggest hiring a hacker from the deep web on Dark Basin to be precise. Most of the hackers there accept payment only after the job is done. Always make your research as it will help you not to fall into the wrong hands. Sniffingnose (repairman) is always my fav on phone hacks

    ReplyDelete
  3. Mush informative and much usefull content. Expecting obtain the best outcome from your sun-based foundation? Image Pvt is here to serve you with the most capable, down to earth and sensible sun situated game plans. Residential Solar system in Lahore We give the clients re-tried plans and contemplations that will not simply satisfy them, yet make them euphoric and love the things.

    ReplyDelete

Thank you for your response.