1. 2012.01.16 4. stack과 heap에 대하여 설명하라(기술면접)
  2. 2012.01.07 기술면접

What is heap and stack?

What is stack?
The two sections other from the code segment in the memory are used for data. The stack is the section of memory that is allocated for automatic variables within functions.

Data is stored in stack using the Last In First Out (LIFO) method. This means that storage in the memory is allocated and deallocated at only one end of the memory called the top of the stack. Stack is a section of memory and its associated registers that is used for temporary storage of information in which the most recently stored item is the first to be retrieved.

What is heap?
On the other hand, heap is an area of memory used for dynamic memory allocation. Blocks of memory are allocated and freed in this case in an arbitrary order. The pattern of allocation and size of blocks is not known until run time. Heap is usually being used by a program for many different purposes.

The stack is much faster than the heap but also smaller and more expensive. 

difference between data and program memory

Data memory = where you place your variables. You can read and write values.

Program memory = where the application is stored. Some chips allows parts of the program memory to be modified in blocks (segments), but you can't store variables in the program memory. It is normally possible to store constants - i.e. initialized variables that you do not change - in the program memory.

Your PC also has data memory and program memory. But the program memory is very small in the PC - it is just for storage of the BIOS - the boot messages you see when the PC boots, and (often, but not always) the configiguration pages where you define if you have a floppy installed, if the computer should support a USB keyboard etc.


Some chips allows parts of the program memory to be modified in blocks (segments), but you can't store variables in the program memory.

To be honest I am a bit surprised. I thought that program memory was off limits to the user for anything, constants or variables in general.


If you do not store and access constants in the program memory, then you need the startup code to copy the constants from the program memory into the RAM on program startup. But requiring two copies of the variable is obviously a waste of space.

The program memory is non-volatile and keeps its contents after power-off. But newer memory architectures, such as the flash memory in just about every new processor, can be erased and reprogrammed in the system (ISP = in-system-programming) and even by the running application (IAP = In Application Programming).

This allows field upgrades of the processor. But it may also be used to store configuration data in the program memory.

But since it is intended for program memory and for field upgrades of the application, you can normally not write individual bytes. And each write normally takes quite long time and may require a full block to be erased. Because of this, it will not work for normal variables. You can't just do a memory write like you can with the RAM memory.

A number of processors - such as the 8051 - separates program and data memory. This is called a Harward architecture. The processor has one set of instructions to access data memory and another set of instructions to access program memory. This allows the compiler to select suitable instructions when accessing a constant stored in the program memory. But there will not exist any instructions for writing into the program memory.

The solution to the above problem - how to write into the program memory for processors with separated program and data address spaces - is normally to allow special function registers indirectly access and write new data, or to create a double-mapped memory area where you can access a mapped memory block using either data operations or program operations.

Most newer processors unifies the address space for program and data, allowing the same processor instructions to access data or program memory. This is called a von Neumann architecture. It is just the address of the memory access that specifies if the access is within the range of a data memory or a program memory.

But in the end - yes, program memory is off limits. But only for "normal" write instructions. The compiler can produce code to pick up constants from the program memory. And some processors have invented methods to allow blocks of the program memory to be erased and rewritten with new information. 



'나머지' 카테고리의 다른 글

Controller Area Network (CAN or CAN bus)  (0) 2012.01.17
그래픽카드 알아내기  (3) 2012.01.16
4. stack과 heap에 대하여 설명하라(기술면접)  (0) 2012.01.16
PCL이란? @ HP PRINT DRIVER  (0) 2012.01.12
소스관리  (1) 2012.01.11
12(1). 리눅스에서 커널이란?  (0) 2012.01.07


나머지 2012. 1. 7. 15:35

2012년 1월 4일 늦은8시에 본 기술면접


아래는 기술면접때 받았던 12가지 질문

회사에서 기본적으로 알아야되는것들을 면접때 물어본것 같기때문에 블로그에 올릴 생각이다.

1. MSB ( Most Significant Bit ) , LSB ( Least Significant Bit ) 를 설명하라.

2. MSB ( Most Significant Byte ) , LSB ( Least Significant Byte ) 를 설명하라.

3. 엔디안이란? Little Endian, Big Endian에 대하여 설명하시오. ( 시험지에는 없었지만 X86과 ARM은 어떤방식인지 물어보셨다 )

4. stack heap에 대하여 설명하라

5.OSI 7계층에 대하여 설명하라


7. C언어의 포인터에서 '*'와'&'에 대하여 설명하라.

8. int * temp = 0x10;  설명하라.

9. windous OS에서 디바이스 드라이버란 무엇인가?

10. 인터럽트함수와 함수의 차이는?


12.  리눅스에서 커널이란? File Boot System이란?

- 파일시스템에 대하여 설명해보시오.
- 부팅과정을 설명해보시오.
- 바이오스란?
- Linked List에 대하여 칠판을 사용하여 설명하시오.
- pipeline에서 한clock당 한명력이 실행되는지문을 주고 번역