강의

멘토링

커뮤니티

Inflearn Community Q&A

codebykim0863's profile image
codebykim0863

asked

[MMORPG Game Development with C++ and Unreal Series] Part 4: Game Server

메모리풀에서 16바이트 정렬에 관해 질문드립니다.

Written on

·

312

0

안녕하세요
강의 공부하던 중 메모리풀에서 16바이트 정렬을 하는 부분이 있었습니다.
다만 왜 구조체를 16바이트 정렬을 하는지.. 16바이트 정렬을 하면 어떻게 되는건지 성능 향상이 있는건지
이런 부분에 대한 궁금증이 생겼습니다. 이에대한 설명 부탁드립니다.
networkMMORPGwindows-server

Answer 1

0

Rookiss님의 프로필 이미지
Rookiss
Instructor

그 부분은 메모리풀과 관련 있다기 보다는
SLIST_ENTRY와 연관성이 있습니다.
강의 코드에서 직접 LockFreeStack을 구현하지 않고
Windows에서 지원하는 LockFreeStack을 사용하고 있는데
그 때 필수 조건이 16바이트 정렬되어 있어야 한다는 것입니다.

On 64-bit platforms, SLIST_ENTRY structures must be 16-byte aligned. Drivers can use DECLSPEC_ALIGN(MEMORY_ALLOCATION_ALIGNMENT) to ensure the proper alignment of SLIST_ENTRY.
All list items must be aligned on a MEMORY_ALLOCATION_ALIGNMENT boundary. Unaligned items can cause unpredictable results. See _aligned_malloc.

https://docs.microsoft.com/en-us/windows/win32/api/winnt/ns-winnt-slist_entry

codebykim0863's profile image
codebykim0863

asked

Ask a question