Wednesday, 9 April 2014

Hi fellowVectorians...!
               Firstly i HaveBeen Thanking My Parents For Supporting me and Thankful to Director Raju Sir for providing Genuine Placements. and Guru Sir for Exploring The Knowledge On Technical and Lcs Kishore,Tandava RamaKrishna,Sangu Gurung for explaing patiently for what  I Asked...
      I Had Ateended For 6 Companies..
    1) CUPOLA Technologies
          As I Attended in middle Of My Course I dont have Sufficient knowledge to answer Questions Regarding 8051 Micro Controller..
         Written Test 1:   Basic Questions On C,Linux,Tcp/ip 
          Written Test 2: C Programming and TCP/IP Client Server Communication PRogram
           Technical Round : 
 a)Questions On Answers We Written in 1st Round and 2nd Round
 b)Questions  on My B.tech Project In Depth (I am not Able To Explain Well) 
 c)Questions On MicroController Very Depth

2)VVDN Chennai
       Yep,I Dont Have Enough Knowlege To Clear The Written Test Bcz it Contains Electronics....
       remaining Sections C Basics And Apti are very Easy.... 
3) TeraData
        VeryGood Company , Having 7 Rounds in it Selection process and HighPackage around 4.8 Lakh 
              They Are mainly concentrated on Data Structers And Sorting Mechanisms
       I Got Question from Linked list and tree Concepts In Round1
            in 2nd round they focused on Hashmap,Binary Tree and Programs On Strings
             I am Back From This Round......
4)EliteCore
      I Faced 6 Rounds for this company..
      They Are Mainly Focusing on Apti , Puzzles and Programming 
    Wrtitten Test 1: C basics,Apti
    Written Test 2:  Data Structres Programming,Linux Internals
    Technical Round 1 : C Basics ,C programming ,Puzzles
     Technical Round 2: Linux Internals, Tcp/Ip ,Vector Project
    Techinical Round 3: questions from Toatl Vector Course Cirriculam and Answers Which are Written by Us...
     Telephonic Round : itself Mixing Of Technical and HR questions..(I Rejected)
5)Safran Engineering Services,BLR
    i had faced written test and Technical only 
  In Techinical I got Questions From C very Depth
  --> Create Generis Stack which has Able to add Integer or charcter or string or float pr even Structure also..
--> Create Cirular Stack
Ans:
I have a need for a fixed-size (selectable at run-time when creating it, not compile-time) circular buffer which can hold objects of any type and it needs to be very high performance. I don't think there will be resource contention issues since, although it's in a multi-tasking embedded environment, it's a co-operative one so the tasks themselves can manage that.
My initial thought were to store a simple struct in the buffer which would contain the type (simple enum/define) and a void pointer to the payload but I want this to be as fast as possible so I'm open to suggestions that involve bypassing the heap.
Actually I'm happy to bypass any of the standard library for raw speed - from what I've seen of the code, it's not heavily optimized for the CPU : it looks like they just compiled C code for things like strcpy()and such, there's no hand-coded assembly.
Any code or ideas would be greatly appreciated. The operations required are:
  • create a buffer with specific size.
  • put at the tail.
  • get from the head.
  • return the count.
  • delete a buffer.
Program:
typedef struct circular_buffer
{
    void *buffer;     // data buffer
    void *buffer_end; // end of data buffer
    size_t capacity;  // maximum number of items in the buffer
    size_t count;     // number of items in the buffer
    size_t sz;        // size of each item in the buffer
    void *head;       // pointer to head
    void *tail;       // pointer to tail
} circular_buffer;

void cb_init(circular_buffer *cb, size_t capacity, size_t sz)
{
    cb->buffer = malloc(capacity * sz);
    if(cb->buffer == NULL)
        // handle error
    cb->buffer_end = (char *)cb->buffer + capacity * sz;
    cb->capacity = capacity;
    cb->count = 0;
    cb->sz = sz;
    cb->head = cb->buffer;
    cb->tail = cb->buffer;
}

void cb_free(circular_buffer *cb)
{
    free(cb->buffer);
    // clear out other fields too, just to be safe
}

void cb_push_back(circular_buffer *cb, const void *item)
{
    if(cb->count == cb->capacity)
        // handle error
    memcpy(cb->head, item, cb->sz);
    cb->head = (char*)cb->head + cb->sz;
    if(cb->head == cb->buffer_end)
        cb->head = cb->buffer;
    cb->count++;
}

void cb_pop_front(circular_buffer *cb, void *item)
{
    if(cb->count == 0)
        // handle error
    memcpy(item, cb->tail, cb->sz);
    cb->tail = (char*)cb->tail + cb->sz;
    if(cb->tail == cb->buffer_end)
        cb->tail = cb->buffer;
    cb->count--;
}

--> Function Pointers
function pointer (or subroutine pointer or procedure pointer) is a type of pointer supported by third-generation programming languages (such as PL/ICOBOLFortran,dBASE dBL, and C) and object-oriented programming languages (such as C++ and D). Instead of referring to data values, a function pointer points to executable code within memory. When dereferenced, a function pointer can be used to invoke the function it points to and pass it arguments just like a normal function call. Such an invocation is also known as an "indirect" call, because the function is being invoked indirectly through a variable instead of directly through a fixed name or address. Function pointers can be used to simplify code by providing a simple way to select a function to execute based on run-time values.

Wild Pointer,Dangling Pointer
Dangling pointers and wild pointers in computer programming are pointers that do not point to a valid object of the appropriate type. These are special cases of memory safety violations.
Dangling pointers arise when an object is deleted or deallocated, without modifying the value of the pointer, so that the pointer still points to the memory location of the deallocated memory. As the system may reallocate the previously freed memory to another process, if the original program then dereferences the (now) dangling pointer, unpredictable behavior may result, as the memory may now contain completely different data. This is especially the case if the program writes data to memory pointed by a dangling pointer, a silent corruption of unrelated data may result, leading to subtle bugs that can be extremely difficult to find, or cause segmentation faults (UNIX, Linux) orgeneral protection faults (Windows). If the overwritten data is bookkeeping data used by the system's memory allocator, the corruption can cause system instabilities.
Wild pointers arise when a pointer is used prior to initialization to some known state, which is possible in some programming languages. They show the same erratic behaviour as dangling pointers, though they are less likely to stay undetected.
-->  Structure Padding , Holes ,Pragma pack ,find size of structure without using sizeof OPerator
--> Valgrind Tool to find out Memory Leaks
6)American MegaTrends  Inc
 I got Selected In This Company..
 Process:
Written Test 1: Apti,IQ questions(Objective),C questions(Objective),Java Questions(Objective),HR Questions(Descriptive) ,Two Java Progrms
Written Test 2: C and C++ Programming And Theotical Questions
HR Round : Asked me about from myself from my  childhood  to till now.. about 1 Hour...

    Finally I Got Selected in Ami..