Interview Preparation Articles
Interview preparation requires proficient knowledge of C/C++. This article has just been recently written (July 2013) and will be elaborated soon; the articles in RED are waiting to be written. The hope is that this article will be "one-stop-shop" for most common C/C++ interview questions.
Contents
Frequently Asked Topics
- What is a volatile variable?
- What is a static keyword in C/C++?
- Linked List
- Linked List
- About extern keyword in C
C++ Object Oriented Topics
Operating Systems Topics
FreeRTOS Tutorial
FreeRTOS is a real-time OS that has many ports for various different controllers. This is a great system to learn about because it gives you the fundamental knowledge of an operating system while making it incredibly easy to learn the material. Here's a must-read tutorial :
Other OS Topics
Miscellaneous Topics
Bit Fiddling
BSS and Data Segments
What are text,.bss and data sections in an Embedded C program? Where do your program recide?Obviously memory,but how is it organized? In embedded systems ,which are RAM-memory constrained ,memory map is divided into segments called text,data and bss. Text segment:Contains code and constants of the program.Text section is allocated on flash. Eg1: a.out :executable code Eg2:const uint8_t i=8 :contant Eg3: #include <stdio.h> const int global_var=20; int data_variable = 500; static int static_var=10; void foo(){ const int local_constant=100; int local; local = 3; int un_initialized; int another_initialized=0; static int local_static=9; local_static++; printf("local varaible is %d\n", local); } In the above example, executable code of the program is stored in flash and const variable global_var=20 and local_constant=100 are stored in flash. Data segment:Initialized variables are stored in this section. Initially values are stored in flash and copied into RAM during execution through copy down process. Eg: uint8_t j=10; initialized variable In the code given above int data_variable = 500,static int static_var=10,local = 3, and local_static=9 are stored in data segment of flash. .bss segment:Uninitialized variables are stored in bss section. In embedded software, the bss segment is mapped into memory that is initialized to zero by the C run-time system before main() is entered. (wiki :https://en.wikipedia.org/wiki/.bss#BSS_in_C) Eg:int newvar; In the above code un_initialized(after initializing it to zero) and another_initialized are stored in bss section ; Simple example: #include <stdio.h> int main(void) { return 0; } Memory occupied by the above program: $ gcc -o just_main just_main.c $ size just_main.exe text data bss dec hex filename 3153 1976 448 5577 15c9 just_main.exe After modifying the above program with one global variable: #include <stdio.h> int global_var; int main(void) { return 0; } $ gcc -o just_main just_main.c $ size just_main.exe text data bss dec hex filename 3153 1976 464 5593 15d9 just_main.exe bss section is increased by 2 bytes; Modify the above program with global variable initialized to zero; #include <stdio.h> int global_var=0; int main(void) { return 0; } $ gcc -o just_main just_main.c $ size just_main.exe text data bss dec hex filename 3153 1976 480 5609 15e9 just_main.exe bss segment is increased by 32 bits(4 bytes) Modify the above program with global variable initialized to non-zero; #include <stdio.h> int global_var=8; int main(void) { return 0; } $ gcc -o just_main just_main $ size just_main.exe text data bss dec hex filename 3153 1976 448 5577 15c9 just_main.exe bss section is not modified. FAQ: What is the size of bss segment? bss does not take any space in the object file and stores the count of variables that can be given initial values.Hence occupy 4 or 8 bytes depending on the implementation. What is the amount of RAM being used? Memory occupied by bss and data segments added together.
Others
Sorting Topics
Sorting means arrangement of elements in a defined manner(Ascending/Descending order). This is widely used in the complex algorithms to decrease the time complexity. There are six types of sorting algorithms namely, Bubble Sort, Insertion Sort, Merge Sort, Quick Sort, Heap Sort and Selection Sort.
Big O notation
Big O notation is a mathematical way of representing an approximate time required for an expression to complete by checking for its major dependencies. For a example, f(n) = n^5 + n.
As we go on increasing the value of n the dependency on the second half equation on the right-hand side will reduce.
so, we can also say that f(n) = n^5 or complexity is O(n^5) for n equal to infinity.
Note: For comparison of big O complexity for different algorithms, refer following site: http://bigocheatsheet.com/
Source Code
Searching Algorithms
Information retrieval is critical in any computer application. Large sets of records are stored in computer system, from which a particular record is fetched in which required information would be stored. Each record stored in the computer environment would have a key associated to it. Based on the search criteria system scans through the records and extract the matching records only. To Increase the speed or reduce the information retrieval duration, various searching techniques are used.
Below are the basic commonly used searching algorithms.
Embedded C Interview Questions and Answers
The following link would navigate to some questions that are very commonly asked in interviews(Cisco,Intacct,WNI etc.). It encloses some C programs as well.