local-storage

Thread Storage Data, Thread Local Storage

thread마다 독립적인 데이터를 저장할 수 있도록 해줌

Thread Storage Data

Posix 방식

  • 함수
    • pthread_key_create: key 생성
    • pthread_setspecific: 데이터 저장
    • pthread_getspecific: 데이터 가져오기

Thread Local Storage

언어 / compiler가 지원

  • 특징

    • 전역변수처럼 선언하면 thread마다 복사됨
    • 빠름
    • 확장성이 낮음
  • 내부 구현

    • TLS + offset으로 접근
    • tpidr_el0 라는 시스템 register에 TLS 값이 저장되어있음
    • mrs (move register from system)
      • TLS 값을 가져올 수 있음