운영체제 memory management 파트에서 page table에 대해 공부하다가, memory addressing 개념이 헷갈려서 정리함.

- 메모리 주소 하나로 참조가능한 실제 메모리 bit수?

- int같이 여러 바이트 크기의 값은 어떻게 참조하는지?

 

먼저 메모리 관련 Term들 정리하기 딱 좋은 질문글

- smallest addressable unit

- data register width (32비트, 64비트 시스템)

- address bus width (시스템에서 다루는 메모리 주소 길이)

- alignment

https://stackoverflow.com/questions/63337718/what-is-the-size-of-every-memory-cell-in-the-stack-and-is-it-possible-to-split-o

 

우리가 흔히 알다시피, 포인터로 참조하는 메모리 주소의 기본 단위는(smallest addressable unit) 1Byte임.

그래서, 메모리 주소 크기가 32비트인 시스템에선 총 $2^{32}가지 * 1Byte = 4GiB$ 메모리만 인식한다는 것.

http://melonicedlatte.com/computerarchitecture/2019/03/07/151740.html

 

C언어에서 int형은 4Byte인데, 메모리 4칸을 access하나?

→ ㅇㅇ 이런식으로 chunk 단위로 access하는 듯

https://talkingaboutme.tistory.com/entry/Memory-Memory-Addressing

https://hugoalbertotrujillomartinez.medium.com/how-is-an-integer-value-stored-in-the-memory-in-c-b5e304872c16

 

 

Q. 그럼 smallest addressable unit는 무조건 1Byte? 표준으로 정해진건가?

→ 그건 C implementation standard고, 아닌 시스템이 있을 수도 있다

https://stackoverflow.com/questions/60241538/is-byte-really-the-minimum-addressable-unit

(다만 대부분 프로그램과 시스템이 이를 따르는 것으로 보임. 호환성 때문에? 이게 최적이라? 간단해서?)

 

옛날 컴퓨터는 word(여러 byte)단위로 addressing하던 때가 있었다

byte addressing VS word addressing 

https://en.wikipedia.org/wiki/Word_addressing

다만, 메모리가 귀했고 바이트 단위로(ex. 텍스트) 작업할 일이 별로 없었던 옛날 일이라 요즘 word addressing이란 term은 저 의미로 쓰이진 않는 듯. 이게 요즘 의미

[Memory] Memory Addressing.mhtml
0.31MB

 

 

⭐ data bus vs address bus width를 잘 나타낸 그림과 설명

http://recipes.egloos.com/4980560

 

맨 마지막 설명) 16bit address + 2Byte word addressing인 경우

address bus width 16bit = A0~A15 pin 존재

한번에 16 bit씩 access하는 (즉, word가 16bit씩인 System) System = data bus 16bit = D0~D15 pin 존재

즉, address개수는 $2^{16} = 65536개$, 근데 각 address마다 16bit data를 전송할 수 있다는 소리

따라서, 전체 메모리 크기는 $2^{16}개 * 2Byte = 128KiB$

비슷한 예시

(요즘 컴퓨터는 다 byte addressing이라 개념적으로만 가볍게 이해하기)

임베디드 레시피 _ RAM Memory의 물리적 동작.mhtml
0.80MB

 

요즘 대부분 컴퓨터는 data register width = address bus width라서 둘을 구분할때 헷갈림.

64비트 시스템

= CPU 레지스터 크기 64비트

= 64비트 메모리 주소 다루기 가능

 

하지만 헷갈리지 말자.

레지스터 크기 (32비트, 64비트 시스템)

CPU가 한번에 다룰 수 있는 정보의 가장 큰 크기

≠ addressing scheme (byte addressing, word addressing)

+ Recent posts